Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

dockerRegistry module: re-init with new underlying software

+112 -2
+1
nixos/modules/module-list.nix
··· 235 235 ./services/misc/dictd.nix 236 236 ./services/misc/dysnomia.nix 237 237 ./services/misc/disnix.nix 238 + ./services/misc/docker-registry.nix 238 239 ./services/misc/emby.nix 239 240 ./services/misc/errbot.nix 240 241 ./services/misc/etcd.nix
-2
nixos/modules/rename.nix
··· 156 156 "See the 16.09 release notes for more information.") 157 157 (mkRemovedOptionModule [ "services" "phpfpm" "phpIni" ] "") 158 158 (mkRemovedOptionModule [ "services" "dovecot2" "package" ] "") 159 - (mkRemovedOptionModule [ "services" "dockerRegistry" ] 160 - "docker-registry has been deprecated upstream since a long time.") 161 159 ]; 162 160 }
+66
nixos/modules/services/misc/docker-registry.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.dockerRegistry; 7 + 8 + in { 9 + options.services.dockerRegistry = { 10 + enable = mkEnableOption "Docker Registry"; 11 + 12 + listenAddress = mkOption { 13 + description = "Docker registry host or ip to bind to."; 14 + default = "127.0.0.1"; 15 + type = types.str; 16 + }; 17 + 18 + port = mkOption { 19 + description = "Docker registry port to bind to."; 20 + default = 5000; 21 + type = types.int; 22 + }; 23 + 24 + storagePath = mkOption { 25 + type = types.path; 26 + default = "/var/lib/docker-registry"; 27 + description = "Docker registry storage path."; 28 + }; 29 + 30 + extraConfig = mkOption { 31 + description = '' 32 + Docker extra registry configuration via environment variables. 33 + ''; 34 + default = {}; 35 + type = types.attrsOf types.str; 36 + }; 37 + }; 38 + 39 + config = mkIf cfg.enable { 40 + systemd.services.docker-registry = { 41 + description = "Docker Container Registry"; 42 + wantedBy = [ "multi-user.target" ]; 43 + after = [ "network.target" ]; 44 + 45 + environment = { 46 + REGISTRY_HTTP_ADDR = "${cfg.listenAddress}:${toString cfg.port}"; 47 + REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY = cfg.storagePath; 48 + } // cfg.extraConfig; 49 + 50 + script = '' 51 + ${pkgs.docker-distribution}/bin/registry serve \ 52 + ${pkgs.docker-distribution.out}/share/go/src/github.com/docker/distribution/cmd/registry/config-example.yml 53 + ''; 54 + 55 + serviceConfig = { 56 + User = "docker-registry"; 57 + WorkingDirectory = cfg.storagePath; 58 + }; 59 + }; 60 + 61 + users.extraUsers.docker-registry = { 62 + createHome = true; 63 + home = cfg.storagePath; 64 + }; 65 + }; 66 + }
+45
nixos/tests/docker-registry.nix
··· 1 + # This test runs docker-registry and check if it works 2 + 3 + import ./make-test.nix ({ pkgs, ...} : { 4 + name = "docker-registry"; 5 + meta = with pkgs.stdenv.lib.maintainers; { 6 + maintainers = [ globin ]; 7 + }; 8 + 9 + nodes = { 10 + registry = { config, pkgs, ... }: { 11 + services.dockerRegistry.enable = true; 12 + services.dockerRegistry.port = 8080; 13 + services.dockerRegistry.listenAddress = "0.0.0.0"; 14 + networking.firewall.allowedTCPPorts = [ 8080 ]; 15 + }; 16 + 17 + client1 = { config, pkgs, ...}: { 18 + virtualisation.docker.enable = true; 19 + virtualisation.docker.socketActivation = false; 20 + virtualisation.docker.extraOptions = "--insecure-registry registry:8080"; 21 + }; 22 + 23 + client2 = { config, pkgs, ...}: { 24 + virtualisation.docker.enable = true; 25 + virtualisation.docker.socketActivation = false; 26 + virtualisation.docker.extraOptions = "--insecure-registry registry:8080"; 27 + }; 28 + }; 29 + 30 + testScript = '' 31 + $client1->start(); 32 + $client1->waitForUnit("docker.service"); 33 + $client1->succeed("tar cv --files-from /dev/null | docker import - scratch"); 34 + $client1->succeed("docker tag scratch registry:8080/scratch"); 35 + 36 + $registry->start(); 37 + $registry->waitForUnit("docker-registry.service"); 38 + $client1->succeed("docker push registry:8080/scratch"); 39 + 40 + $client2->start(); 41 + $client2->waitForUnit("docker.service"); 42 + $client2->succeed("docker pull registry:8080/scratch"); 43 + $client2->succeed("docker images | grep scratch"); 44 + ''; 45 + })