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:
parent
63eb786e04
commit
d00c6f6d0a
6 changed files with 77 additions and 95 deletions
|
@ -1,14 +1,10 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
nix = { package = config.lib.test.mkStubPackage { }; };
|
||||
nix = { package = config.lib.test.mkStubPackage { }; };
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/nix
|
||||
assertPathNotExists home-files/.nix-defexpr/50-home-manager
|
||||
'';
|
||||
};
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/nix
|
||||
assertPathNotExists home-files/.nix-defexpr/50-home-manager
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -9,21 +9,19 @@ let
|
|||
}
|
||||
'';
|
||||
in {
|
||||
config = {
|
||||
nix = {
|
||||
package = config.lib.test.mkStubPackage {
|
||||
version = lib.getVersion pkgs.nixVersions.stable;
|
||||
};
|
||||
channels.example = exampleChannel;
|
||||
settings.use-xdg-base-directories = true;
|
||||
nix = {
|
||||
package = config.lib.test.mkStubPackage {
|
||||
version = lib.getVersion pkgs.nixVersions.stable;
|
||||
};
|
||||
|
||||
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
|
||||
'';
|
||||
channels.example = exampleChannel;
|
||||
settings.use-xdg-base-directories = true;
|
||||
};
|
||||
|
||||
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
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -9,18 +9,16 @@ let
|
|||
}
|
||||
'';
|
||||
in {
|
||||
config = {
|
||||
nix = {
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
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
|
||||
'';
|
||||
nix = {
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
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
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1,25 +1,21 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
nix = {
|
||||
registry = {
|
||||
nixpkgs = {
|
||||
to = {
|
||||
type = "github";
|
||||
owner = "my-org";
|
||||
repo = "my-nixpkgs";
|
||||
};
|
||||
nix = {
|
||||
registry = {
|
||||
nixpkgs = {
|
||||
to = {
|
||||
type = "github";
|
||||
owner = "my-org";
|
||||
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}
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1,38 +1,34 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
config = {
|
||||
nix = {
|
||||
package = config.lib.test.mkStubPackage {
|
||||
version = lib.getVersion pkgs.nixVersions.stable;
|
||||
buildScript = ''
|
||||
target=$out/bin/nix
|
||||
mkdir -p "$(dirname "$target")"
|
||||
nix = {
|
||||
package = config.lib.test.mkStubPackage {
|
||||
version = lib.getVersion pkgs.nixVersions.stable;
|
||||
buildScript = ''
|
||||
target=$out/bin/nix
|
||||
mkdir -p "$(dirname "$target")"
|
||||
|
||||
echo -n "true" > "$target"
|
||||
echo -n "true" > "$target"
|
||||
|
||||
chmod +x "$target"
|
||||
'';
|
||||
};
|
||||
|
||||
nixPath = [ "/a" "/b/c" ];
|
||||
|
||||
settings = {
|
||||
use-sandbox = true;
|
||||
show-trace = true;
|
||||
system-features = [ "big-parallel" "kvm" "recursive-nix" ];
|
||||
};
|
||||
chmod +x "$target"
|
||||
'';
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent \
|
||||
home-files/.config/nix/nix.conf \
|
||||
${./example-settings-expected.conf}
|
||||
nixPath = [ "/a" "/b/c" ];
|
||||
|
||||
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'export NIX_PATH="/a:/b/c''${NIX_PATH:+:$NIX_PATH}"'
|
||||
'';
|
||||
settings = {
|
||||
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}"'
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
{ config, ... }:
|
||||
|
||||
{
|
||||
config = {
|
||||
nix = {
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
nixPath = [ "/a" "/b/c" ];
|
||||
keepOldNixPath = false;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'export NIX_PATH="/a:/b/c"'
|
||||
'';
|
||||
nix = {
|
||||
package = config.lib.test.mkStubPackage { };
|
||||
nixPath = [ "/a" "/b/c" ];
|
||||
keepOldNixPath = false;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains home-path/etc/profile.d/hm-session-vars.sh \
|
||||
'export NIX_PATH="/a:/b/c"'
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue