summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2020-08-11 12:12:13 +0200
committermakefu <github@syntax-fehler.de>2020-08-11 12:12:13 +0200
commit4cb0ff12ba563693b6be7aac3c7cc8c6ce7a003c (patch)
tree2eceb32d72c1799938bce57240566ba576c2c3b4 /lib
parent93606315b99a2540c5859d93eb2377ae32fa6506 (diff)
parentf556a302f62434e0a47ef23db7e569bdb9c489f6 (diff)
Merge remote-tracking branch 'lass/master'
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix3
-rw-r--r--lib/types.nix14
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 5a948bbf3..f02959bba 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -8,6 +8,9 @@ let
krebs = import ./krebs lib;
krops = import ../submodules/krops/lib;
shell = import ./shell.nix { inherit lib; };
+ systemd = {
+ encodeName = replaceChars ["/"] ["\\x2f"];
+ };
types = nixpkgs-lib.types // import ./types.nix { inherit lib; };
xml = import ./xml.nix { inherit lib; };
diff --git a/lib/types.nix b/lib/types.nix
index 16ccb145e..1eb4d947c 100644
--- a/lib/types.nix
+++ b/lib/types.nix
@@ -238,7 +238,7 @@ rec {
secret-file = submodule ({ config, ... }: {
options = {
name = mkOption {
- type = filename;
+ type = pathname;
default = config._module.args.name;
};
path = mkOption {
@@ -256,6 +256,10 @@ rec {
type = str;
default = "root";
};
+ service = mkOption {
+ type = systemd.unit-name;
+ default = "secret-${lib.systemd.encodeName config.name}.service";
+ };
source-path = mkOption {
type = str;
default = toString <secrets> + "/${config.name}";
@@ -526,6 +530,14 @@ rec {
merge = mergeOneOption;
};
+ systemd.unit-name = mkOptionType {
+ name = "systemd unit name";
+ check = x:
+ test "^[0-9A-Za-z:_.\\-]+@?\\.(service|socket|device|mount|automount|swap|target|path|timer|slice|scope)$" x &&
+ stringLength x <= 256;
+ merge = mergeOneOption;
+ };
+
# RFC952, B. Lexical grammar, <hname>
hostname = mkOptionType {
name = "hostname";