Add support for environment.systemPackages.
This commit is contained in:
parent
c02d43aa97
commit
d5f138f939
5 changed files with 115 additions and 39 deletions
|
|
@ -1,53 +1,61 @@
|
|||
{ lib, ... }: {
|
||||
{ lib, pkgs, ... }: {
|
||||
config = {
|
||||
nixpkgs.hostPlatform = "x86_64-linux";
|
||||
|
||||
services.nginx.enable = true;
|
||||
|
||||
environment.etc = {
|
||||
foo = {
|
||||
text = ''
|
||||
This is just a test!
|
||||
environment = {
|
||||
systemPackages = [
|
||||
pkgs.ripgrep
|
||||
pkgs.fd
|
||||
];
|
||||
|
||||
etc = {
|
||||
foo = {
|
||||
text = ''
|
||||
This is just a test!
|
||||
'';
|
||||
target = "foo_test";
|
||||
};
|
||||
|
||||
"foo.conf".text = ''
|
||||
launch_the_rockets = true
|
||||
'';
|
||||
target = "foo_test";
|
||||
};
|
||||
|
||||
"foo.conf".text = ''
|
||||
launch_the_rockets = true
|
||||
'';
|
||||
"baz/bar/foo2" = {
|
||||
text = ''
|
||||
Another test!
|
||||
'';
|
||||
mode = "symlink";
|
||||
};
|
||||
|
||||
"baz/bar/foo2" = {
|
||||
text = ''
|
||||
Another test!
|
||||
'';
|
||||
mode = "symlink";
|
||||
};
|
||||
foo3 = {
|
||||
text = "boo!";
|
||||
mode = "0700";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
foo3 = {
|
||||
text = "boo!";
|
||||
mode = "0700";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
"a/nested/example/foo3" = {
|
||||
text = "boo!";
|
||||
mode = "0764";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
"a/nested/example/foo3" = {
|
||||
text = "boo!";
|
||||
mode = "0764";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
"a/nested/example2/foo3" = {
|
||||
text = "boo!";
|
||||
mode = "0764";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
"a/nested/example2/foo3" = {
|
||||
text = "boo!";
|
||||
mode = "0764";
|
||||
user = "root";
|
||||
group = "root";
|
||||
};
|
||||
|
||||
out-of-store = {
|
||||
source = "/run/systemd/system/";
|
||||
out-of-store = {
|
||||
source = "/run/systemd/system/";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services =
|
||||
lib.listToAttrs
|
||||
(lib.flip lib.genList 10 (ix:
|
||||
|
|
|
|||
|
|
@ -284,6 +284,13 @@ in
|
|||
cp ${resultImg} $out
|
||||
'';
|
||||
|
||||
mkTestPreamble = node: action: ''
|
||||
${node}.succeed("/system-manager-profile/bin/${action} 2>&1 | tee /tmp/output.log")
|
||||
${node}.succeed("grep -vF 'ERROR' /tmp/output.log")
|
||||
'';
|
||||
|
||||
activateProfileSnippet = node: self.lib.mkTestPreamble node "activate";
|
||||
|
||||
make-vm-test =
|
||||
name:
|
||||
{ system
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
}:
|
||||
{
|
||||
imports = [
|
||||
./environment.nix
|
||||
./etc.nix
|
||||
./systemd.nix
|
||||
./upstream/nixpkgs
|
||||
|
|
@ -16,7 +17,6 @@
|
|||
inherit (lib) types;
|
||||
in
|
||||
{
|
||||
|
||||
nixpkgs = {
|
||||
# TODO: switch to lib.systems.parsedPlatform
|
||||
hostPlatform = lib.mkOption {
|
||||
|
|
|
|||
17
nix/modules/environment.nix
Normal file
17
nix/modules/environment.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ lib, config, pkgs, ... }:
|
||||
|
||||
{
|
||||
options.environment = {
|
||||
systemPackages = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.package;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
environment.etc."profile.d/system-manager-path.sh".source =
|
||||
pkgs.writeShellScript "system-manager-path.sh" ''
|
||||
export PATH=${lib.makeBinPath config.environment.systemPackages}:''${PATH}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ forEachUbuntuImage
|
|||
})
|
||||
)
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
forEachUbuntuImage
|
||||
(imgName: image: lib.nameValuePair
|
||||
|
|
@ -222,3 +222,47 @@ forEachUbuntuImage
|
|||
];
|
||||
})
|
||||
)
|
||||
|
||||
//
|
||||
|
||||
forEachUbuntuImage
|
||||
(imgName: image: lib.nameValuePair
|
||||
"vm-test-system-path-${imgName}"
|
||||
(system-manager.lib.make-vm-test "vm-test-system-path-${imgName}" {
|
||||
inherit system;
|
||||
modules = [
|
||||
({ config, ... }:
|
||||
let
|
||||
inherit (config) hostPkgs;
|
||||
in
|
||||
{
|
||||
nodes = {
|
||||
node1 = { config, ... }: {
|
||||
modules = [
|
||||
../../../examples/example.nix
|
||||
];
|
||||
|
||||
virtualisation.rootImage = system-manager.lib.prepareUbuntuImage {
|
||||
inherit hostPkgs image;
|
||||
nodeConfig = config;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
# Start all machines in parallel
|
||||
start_all()
|
||||
|
||||
${system-manager.lib.activateProfileSnippet "node1"}
|
||||
|
||||
node1.succeed("/system-manager-profile/bin/activate 2>&1 | tee /tmp/output.log")
|
||||
node1.succeed("grep -vF 'ERROR' /tmp/output.log")
|
||||
node1.wait_for_unit("system-manager.target")
|
||||
|
||||
node1.succeed("bash --login -c 'realpath $(which rg) | grep -F ${hostPkgs.ripgrep}/bin/rg'")
|
||||
node1.succeed("bash --login -c 'realpath $(which fd) | grep -F ${hostPkgs.fd}/bin/fd'")
|
||||
'';
|
||||
})
|
||||
];
|
||||
})
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue