diff options
author | Franz Pletz <fpletz@fnordicwalking.de> | 2018-03-04 17:10:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-04 17:10:27 +0000 |
commit | 0f78afdf253e3f53e76ec3379518d208a18c568c (patch) | |
tree | 7524e34c1ac817f8d5d507b7dbc07b6a87d8eac5 /nixos | |
parent | 431d05cff73138babc64e0ef95ee0eaa8b9084d7 (diff) | |
parent | 58895aa1cb752198b8ab89aacfe51e6a8a69e326 (diff) | |
download | nixlib-0f78afdf253e3f53e76ec3379518d208a18c568c.tar nixlib-0f78afdf253e3f53e76ec3379518d208a18c568c.tar.gz nixlib-0f78afdf253e3f53e76ec3379518d208a18c568c.tar.bz2 nixlib-0f78afdf253e3f53e76ec3379518d208a18c568c.tar.lz nixlib-0f78afdf253e3f53e76ec3379518d208a18c568c.tar.xz nixlib-0f78afdf253e3f53e76ec3379518d208a18c568c.tar.zst nixlib-0f78afdf253e3f53e76ec3379518d208a18c568c.zip |
Merge pull request #32248 from awakesecurity/parnell/fetchdocker
Support fetching docker images from V2 registries
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/release.nix | 1 | ||||
-rw-r--r-- | nixos/tests/hocker-fetchdocker/default.nix | 15 | ||||
-rw-r--r-- | nixos/tests/hocker-fetchdocker/hello-world-container.nix | 19 | ||||
-rw-r--r-- | nixos/tests/hocker-fetchdocker/machine.nix | 26 |
4 files changed, 61 insertions, 0 deletions
diff --git a/nixos/release.nix b/nixos/release.nix index d092a5b7552b..1db2da511441 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -274,6 +274,7 @@ in rec { tests.hibernate = callTest tests/hibernate.nix {}; tests.home-assistant = callTest tests/home-assistant.nix { }; tests.hound = callTest tests/hound.nix {}; + tests.hocker-fetchdocker = callTest tests/hocker-fetchdocker {}; tests.i3wm = callTest tests/i3wm.nix {}; tests.initrd-network-ssh = callTest tests/initrd-network-ssh {}; tests.installer = callSubTests tests/installer.nix {}; diff --git a/nixos/tests/hocker-fetchdocker/default.nix b/nixos/tests/hocker-fetchdocker/default.nix new file mode 100644 index 000000000000..4f30f01e4032 --- /dev/null +++ b/nixos/tests/hocker-fetchdocker/default.nix @@ -0,0 +1,15 @@ +import ../make-test.nix ({ pkgs, ...} : { + name = "test-hocker-fetchdocker"; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ ixmatus ]; + }; + + machine = import ./machine.nix; + + testScript = '' + startAll; + + $machine->waitForUnit("sockets.target"); + $machine->waitUntilSucceeds("docker run registry-1.docker.io/v2/library/hello-world:latest"); + ''; +}) diff --git a/nixos/tests/hocker-fetchdocker/hello-world-container.nix b/nixos/tests/hocker-fetchdocker/hello-world-container.nix new file mode 100644 index 000000000000..a127875264e9 --- /dev/null +++ b/nixos/tests/hocker-fetchdocker/hello-world-container.nix @@ -0,0 +1,19 @@ +{ fetchDockerConfig, fetchDockerLayer, fetchdocker }: +fetchdocker rec { + name = "hello-world"; + registry = "https://registry-1.docker.io/v2/"; + repository = "library"; + imageName = "hello-world"; + tag = "latest"; + imageConfig = fetchDockerConfig { + inherit tag registry repository imageName; + sha256 = "1ivbd23hyindkahzfw4kahgzi6ibzz2ablmgsz6340vc6qr1gagj"; + }; + imageLayers = let + layer0 = fetchDockerLayer { + inherit registry repository imageName; + layerDigest = "ca4f61b1923c10e9eb81228bd46bee1dfba02b9c7dac1844527a734752688ede"; + sha256 = "1plfd194fwvsa921ib3xkhms1yqxxrmx92r2h7myj41wjaqn2kya"; + }; + in [ layer0 ]; + } diff --git a/nixos/tests/hocker-fetchdocker/machine.nix b/nixos/tests/hocker-fetchdocker/machine.nix new file mode 100644 index 000000000000..12c58a012243 --- /dev/null +++ b/nixos/tests/hocker-fetchdocker/machine.nix @@ -0,0 +1,26 @@ +{ config, pkgs, ... }: +{ nixpkgs.config.packageOverrides = pkgs': { + hello-world-container = pkgs'.callPackage ./hello-world-container.nix { }; + }; + + virtualisation.docker = { + enable = true; + package = pkgs.docker; + }; + + systemd.services.docker-load-fetchdocker-image = { + description = "Docker load hello-world-container"; + wantedBy = [ "multi-user.target" ]; + wants = [ "docker.service" "local-fs.target" ]; + after = [ "docker.service" "local-fs.target" ]; + + script = '' + ${pkgs.hello-world-container}/compositeImage.sh | ${pkgs.docker}/bin/docker load + ''; + + serviceConfig = { + Type = "oneshot"; + }; + }; +} + |