Skip to content

Instantly share code, notes, and snippets.

@VTimofeenko
Last active March 29, 2024 20:41
Show Gist options
  • Save VTimofeenko/5b8779fb2afb6e1152d352f55f7b321c to your computer and use it in GitHub Desktop.
Save VTimofeenko/5b8779fb2afb6e1152d352f55f7b321c to your computer and use it in GitHub Desktop.
Flake to check home-manager stuff in a nixos test driver
{
description = "Nixos config flake";
inputs = {
nixpkgs.url = "nixpkgs/nixos-23.11";
home-manager.url = "github:nix-community/home-manager/release-23.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
inputs@{ self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in
{
checks.${system}.test = pkgs.testers.runNixOSTest {
name = "test";
node.specialArgs = {
inherit (self) inputs outputs;
};
nodes.machine1 =
{ config, pkgs, ... }:
{
services.getty.autologinUser = "alice";
imports = [ inputs.home-manager.nixosModules.home-manager ];
users.users.alice = {
isNormalUser = true;
password = "hunter2";
};
home-manager.extraSpecialArgs = {
inherit (self) inputs outputs;
};
home-manager.users.alice =
{ config, ... }: # config is home-manager's config, not the OS one
{
imports = [ ];
home.stateVersion = "23.11";
};
};
testScript = "start_all()";
};
};
}
  1. nix build -L .\#checks.x86_64-linux.test.driverInteractive (or just nix run ... and skip 2.)
  2. ./result/bin/nixos-test-driver
  3. start_all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment