blob: 4e7a59554652a2c7738cb429d4a174d862773b22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{ lib, pkgs, ... }:
with builtins // lib;
basePath:
rec {
option = mkOption {
type = fileType;
default = {};
description = "Files relative to ${basePath}";
};
type = types.attrsOf (types.submodule ({ name, config, ... }: {
options = {
enable = mkEnableOption name // { default = text != ""; };
target = mkOption {
type = types.str;
default = name;
apply = p: if basePath == "" || isPrefix basePath p then p else "${basePath}/${p}";
};
executable = mkOption {
type = with types; nullOr bool;
default = null;
};
source = mkOption {
type = types.path;
};
text = mkOption {
type = with types; nullOr lines;
default = null;
};
};
config = mkMerge [
(mkIf (config.text != null) {
source = mkDefault pkgs.writeTextFile {
inherit name;
inherit (config) text;
executable = config.executable == true;
};
})
];
}))
}
|