1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

nix: simplify tests

This commit is contained in:
Robert Helgesson 2024-12-06 12:24:37 +01:00
parent 63eb786e04
commit d00c6f6d0a
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
6 changed files with 77 additions and 95 deletions

View file

@ -1,14 +1,10 @@
{ config, lib, pkgs, ... }: { config, ... }:
with lib;
{ {
config = { nix = { package = config.lib.test.mkStubPackage { }; };
nix = { package = config.lib.test.mkStubPackage { }; };
nmt.script = '' nmt.script = ''
assertPathNotExists home-files/.config/nix assertPathNotExists home-files/.config/nix
assertPathNotExists home-files/.nix-defexpr/50-home-manager assertPathNotExists home-files/.nix-defexpr/50-home-manager
''; '';
};
} }

View file

@ -9,21 +9,19 @@ let
} }
''; '';
in { in {
config = { nix = {
nix = { package = config.lib.test.mkStubPackage {
package = config.lib.test.mkStubPackage { version = lib.getVersion pkgs.nixVersions.stable;
version = lib.getVersion pkgs.nixVersions.stable;
};
channels.example = exampleChannel;
settings.use-xdg-base-directories = true;
}; };
channels.example = exampleChannel;
nmt.script = '' settings.use-xdg-base-directories = true;
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export NIX_PATH="/home/hm-user/.local/state/nix/defexpr/50-home-manager''${NIX_PATH:+:$NIX_PATH}"'
assertFileContent \
home-files/.local/state/nix/defexpr/50-home-manager/example/default.nix \
${exampleChannel}/default.nix
'';
}; };
nmt.script = ''
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export NIX_PATH="/home/hm-user/.local/state/nix/defexpr/50-home-manager''${NIX_PATH:+:$NIX_PATH}"'
assertFileContent \
home-files/.local/state/nix/defexpr/50-home-manager/example/default.nix \
${exampleChannel}/default.nix
'';
} }

View file

@ -9,18 +9,16 @@ let
} }
''; '';
in { in {
config = { nix = {
nix = { package = config.lib.test.mkStubPackage { };
package = config.lib.test.mkStubPackage { }; channels.example = exampleChannel;
channels.example = exampleChannel;
};
nmt.script = ''
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export NIX_PATH="/home/hm-user/.nix-defexpr/50-home-manager''${NIX_PATH:+:$NIX_PATH}"'
assertFileContent \
home-files/.nix-defexpr/50-home-manager/example/default.nix \
${exampleChannel}/default.nix
'';
}; };
nmt.script = ''
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export NIX_PATH="/home/hm-user/.nix-defexpr/50-home-manager''${NIX_PATH:+:$NIX_PATH}"'
assertFileContent \
home-files/.nix-defexpr/50-home-manager/example/default.nix \
${exampleChannel}/default.nix
'';
} }

View file

@ -1,25 +1,21 @@
{ config, lib, pkgs, ... }: { ... }:
with lib;
{ {
config = { nix = {
nix = { registry = {
registry = { nixpkgs = {
nixpkgs = { to = {
to = { type = "github";
type = "github"; owner = "my-org";
owner = "my-org"; repo = "my-nixpkgs";
repo = "my-nixpkgs";
};
}; };
}; };
}; };
nmt.script = ''
assertFileContent \
home-files/.config/nix/registry.json \
${./example-registry-expected.json}
'';
}; };
nmt.script = ''
assertFileContent \
home-files/.config/nix/registry.json \
${./example-registry-expected.json}
'';
} }

View file

@ -1,38 +1,34 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
{ {
config = { nix = {
nix = { package = config.lib.test.mkStubPackage {
package = config.lib.test.mkStubPackage { version = lib.getVersion pkgs.nixVersions.stable;
version = lib.getVersion pkgs.nixVersions.stable; buildScript = ''
buildScript = '' target=$out/bin/nix
target=$out/bin/nix mkdir -p "$(dirname "$target")"
mkdir -p "$(dirname "$target")"
echo -n "true" > "$target" echo -n "true" > "$target"
chmod +x "$target" chmod +x "$target"
''; '';
};
nixPath = [ "/a" "/b/c" ];
settings = {
use-sandbox = true;
show-trace = true;
system-features = [ "big-parallel" "kvm" "recursive-nix" ];
};
}; };
nmt.script = '' nixPath = [ "/a" "/b/c" ];
assertFileContent \
home-files/.config/nix/nix.conf \
${./example-settings-expected.conf}
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \ settings = {
'export NIX_PATH="/a:/b/c''${NIX_PATH:+:$NIX_PATH}"' use-sandbox = true;
''; show-trace = true;
system-features = [ "big-parallel" "kvm" "recursive-nix" ];
};
}; };
nmt.script = ''
assertFileContent \
home-files/.config/nix/nix.conf \
${./example-settings-expected.conf}
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export NIX_PATH="/a:/b/c''${NIX_PATH:+:$NIX_PATH}"'
'';
} }

View file

@ -1,16 +1,14 @@
{ config, ... }: { config, ... }:
{ {
config = { nix = {
nix = { package = config.lib.test.mkStubPackage { };
package = config.lib.test.mkStubPackage { }; nixPath = [ "/a" "/b/c" ];
nixPath = [ "/a" "/b/c" ]; keepOldNixPath = false;
keepOldNixPath = false;
};
nmt.script = ''
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export NIX_PATH="/a:/b/c"'
'';
}; };
nmt.script = ''
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
'export NIX_PATH="/a:/b/c"'
'';
} }