diff --git a/nix/ci.nix b/nix/ci.nix index 4726fd9..f44c5e2 100644 --- a/nix/ci.nix +++ b/nix/ci.nix @@ -13,18 +13,23 @@ dimension "Nixpkgs version" { nixpkgsSource = "nixos-19.03"; enableDoc = false; nixosTestIsPerl = true; + dockerSupportsSystemd = true; + nixosHasPodmanDockerSocket = false; }; "nixos-20_09" = { nixpkgsSource = "nixos-20.09"; isReferenceNixpkgs = true; enableDoc = true; + dockerSupportsSystemd = true; + nixosHasPodmanDockerSocket = false; }; "nixos-unstable" = { nixpkgsSource = "nixos-unstable"; enableDoc = true; }; } ( - _name: { nixpkgsSource, isReferenceNixpkgs ? false, enableDoc ? true, nixosTestIsPerl ? false }: + _name: { nixpkgsSource, isReferenceNixpkgs ? false, enableDoc ? true, + nixosTestIsPerl ? false, dockerSupportsSystemd ? false, nixosHasPodmanDockerSocket ? true }: dimension "System" { @@ -34,7 +39,7 @@ dimension "Nixpkgs version" { system: { isReferenceTarget ? false, enableNixOSTests ? true }: let pkgs = import ./. { - inherit system nixosTestIsPerl; + inherit system nixosTestIsPerl dockerSupportsSystemd nixosHasPodmanDockerSocket; nixpkgsSrc = sources.${nixpkgsSource}; }; in diff --git a/nix/default.nix b/nix/default.nix index a824a53..a880f2c 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -3,6 +3,8 @@ , nixpkgsSrc ? sources.${nixpkgsName} , system ? builtins.currentSystem , nixosTestIsPerl ? false +, dockerSupportsSystemd ? false +, nixosHasPodmanDockerSocket ? true , ... }: @@ -11,8 +13,12 @@ import nixpkgsSrc ({ config = { }; overlays = [ - # all the packages are defined there: - (_: _: { inherit nixosTestIsPerl; }) + (_: _: { + inherit nixosTestIsPerl; + arionTestingFlags = { + inherit nixosTestIsPerl dockerSupportsSystemd nixosHasPodmanDockerSocket; + }; + }) (import ./overlay.nix) ]; inherit system; diff --git a/nix/sources.json b/nix/sources.json index 47e0e6c..d68b5da 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -36,15 +36,15 @@ "url_template": "https://github.com///archive/.tar.gz" }, "nixos-unstable": { - "branch": "nixos-unstable", + "branch": "wip-arion-prs", "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", "homepage": "https://github.com/NixOS/nixpkgs", - "owner": "NixOS", + "owner": "hercules-ci", "repo": "nixpkgs", - "rev": "296793637b22bdb4d23b479879eba0a71c132a66", - "sha256": "0j09yih9693w5vjx64ikfxyja1ha7pisygrwrpg3wfz3sssglg69", + "rev": "4f5e5257f4385bb178f2b14393c06bada5fdb65e", + "sha256": "0m60fvajhx90hamn6arl3ifvbzfwrl2c80v5j44lwcl6n2bjgcmb", "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/296793637b22bdb4d23b479879eba0a71c132a66.tar.gz", + "url": "https://github.com/hercules-ci/nixpkgs/archive/4f5e5257f4385bb178f2b14393c06bada5fdb65e.tar.gz", "url_template": "https://github.com///archive/.tar.gz", "version": "" }, diff --git a/src/haskell/testdata/Arion/NixSpec/arion-compose.json b/src/haskell/testdata/Arion/NixSpec/arion-compose.json index 479fe96..83d62fc 100644 --- a/src/haskell/testdata/Arion/NixSpec/arion-compose.json +++ b/src/haskell/testdata/Arion/NixSpec/arion-compose.json @@ -2,14 +2,14 @@ "services": { "webserver": { "command": [ - "/nix/store/b9w61w4g8sqgrm3rid6ca22krslqghb3-nixos-system-unnamed-19.03.173100.e726e8291b2/init" + "/usr/sbin/init" ], "environment": { "NIX_REMOTE": "", "PATH": "/usr/bin:/run/current-system/sw/bin/", "container": "docker" }, - "image": "arion-base:", + "image": "webserver:", "ports": [ "8000:80" ], @@ -23,8 +23,7 @@ "tty": true, "volumes": [ "/sys/fs/cgroup:/sys/fs/cgroup:ro", - "/nix/store:/nix/store:ro", - "/nix/store/pssdmhzjnhflawv7rwk1yw39350iv40g-container-system-env:/run/system:ro" + "/nix/store:/nix/store:ro" ] } }, @@ -32,8 +31,8 @@ "x-arion": { "images": [ { - "image": "", - "imageName": "arion-base", + "imageExe": "", + "imageName": "webserver", "imageTag": "" } ], diff --git a/src/nix/modules/service/nixos-init.nix b/src/nix/modules/service/nixos-init.nix index d152f0c..38a23a7 100644 --- a/src/nix/modules/service/nixos-init.nix +++ b/src/nix/modules/service/nixos-init.nix @@ -24,7 +24,13 @@ in ../nixos/default-shell.nix (pkgs.path + "/nixos/modules/profiles/minimal.nix") ]; - image.command = [ "${config.nixos.build.toplevel}/init" ]; + image.command = [ "/usr/sbin/init" ]; + image.contents = [ + (pkgs.runCommand "root-init" {} '' + mkdir -p $out/usr/sbin + ln -s ${config.nixos.build.toplevel}/init $out/usr/sbin/init + '') + ]; service.environment.container = "docker"; service.environment.PATH = "/usr/bin:/run/current-system/sw/bin/"; service.volumes = [ diff --git a/tests/arion-test/default.nix b/tests/arion-test/default.nix index dcbd376..e34ff93 100644 --- a/tests/arion-test/default.nix +++ b/tests/arion-test/default.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ usePodman ? false, pkgs, lib, ... }: let # To make some prebuilt derivations available in the vm @@ -6,14 +6,26 @@ let inherit modules; inherit pkgs; }; + + inherit (lib) + optionalAttrs + optionalString + ; + + haveSystemd = usePodman || pkgs.arionTestingFlags.dockerSupportsSystemd; + in { name = "arion-test"; machine = { pkgs, lib, ... }: { environment.systemPackages = [ pkgs.arion - ]; - virtualisation.docker.enable = true; + ] ++ lib.optional usePodman pkgs.docker; + virtualisation.docker.enable = !usePodman; + virtualisation.podman = optionalAttrs usePodman { + enable = true; + dockerSocket.enable = true; + }; # no caches, because no internet nix.binaryCaches = lib.mkForce []; @@ -38,6 +50,7 @@ in ]; virtualisation.memorySize = 1024; + virtualisation.diskSize = 8000; }; testScript = '' machine.fail("curl --fail localhost:8000") @@ -71,6 +84,7 @@ in # machine.succeed("cd work && NIX_PATH= arion down") # machine.wait_until_fails("curl --fail localhost:8000") + ${optionalString haveSystemd '' # Tests # - arion exec # - examples/full-nixos @@ -95,6 +109,7 @@ in "cd work && NIX_PATH=nixpkgs='${pkgs.path}' arion down" ) machine.wait_until_fails("curl --fail localhost:8000") + ''} # Tests # - examples/nixos-unit diff --git a/tests/default.nix b/tests/default.nix index cc9ad49..e134b37 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,4 +1,4 @@ -{ pkgs ? import ../pkgs.nix, nixosTestIsPerl ? false }: +{ pkgs ? import ../pkgs.nix, nixosTestIsPerl ? false, arionTestingFlags ? {} }: let inherit (pkgs) nixosTest recurseIntoAttrs arion; in @@ -6,6 +6,10 @@ in recurseIntoAttrs { test = if nixosTestIsPerl then nixosTest ./arion-test-perl else nixosTest ./arion-test; + testWithPodman = + if arionTestingFlags.nixosHasPodmanDockerSocket + then nixosTest (pkgs.callPackage ./arion-test { usePodman = true; }) + else {}; testBuild = arion.build {