nixos/docker-registry: Allow use of non-filesystem storage

Previously this module precluded use of storage backends other than
`filesystem`. It is now possible to configure another storage backend
manually by setting `services.dockerRegistry.storagePath` to `null` and
configuring the other backend via `extraConfig`.
This commit is contained in:
Ben Gamari 2019-03-12 17:32:29 -04:00 committed by Robin Gloster
parent d828bf7a10
commit 2036550a46

View File

@ -14,9 +14,10 @@ let
log.fields.service = "registry"; log.fields.service = "registry";
storage = { storage = {
cache.blobdescriptor = blobCache; cache.blobdescriptor = blobCache;
filesystem.rootdirectory = cfg.storagePath;
delete.enabled = cfg.enableDelete; delete.enabled = cfg.enableDelete;
}; } // (if cfg.storagePath != null
then { filesystem.rootdirectory = cfg.storagePath; }
else {});
http = { http = {
addr = "${cfg.listenAddress}:${builtins.toString cfg.port}"; addr = "${cfg.listenAddress}:${builtins.toString cfg.port}";
headers.X-Content-Type-Options = ["nosniff"]; headers.X-Content-Type-Options = ["nosniff"];
@ -61,9 +62,12 @@ in {
}; };
storagePath = mkOption { storagePath = mkOption {
type = types.path; type = types.nullOr types.path;
default = "/var/lib/docker-registry"; default = "/var/lib/docker-registry";
description = "Docker registry storage path."; description = ''
Docker registry storage path for the filesystem storage backend. Set to
null to configure another backend via extraConfig.
'';
}; };
enableDelete = mkOption { enableDelete = mkOption {
@ -140,9 +144,12 @@ in {
startAt = optional cfg.enableGarbageCollect cfg.garbageCollectDates; startAt = optional cfg.enableGarbageCollect cfg.garbageCollectDates;
}; };
users.users.docker-registry = { users.users.docker-registry =
createHome = true; if cfg.storagePath != null
home = cfg.storagePath; then {
}; createHome = true;
home = cfg.storagePath;
}
else {};
}; };
} }