-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.nix
29 lines (29 loc) · 884 Bytes
/
config.nix
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
pkgs: configContent: configRoot: prefix: { key, structure }:
let
parsedConfig = builtins.fromTOML configContent;
subConfig = pkgs.lib.mapAttrsRecursive
(name: value:
if
(configRoot != null
&& builtins.isString value
&& builtins.substring 0 2 value == "./"
) then
builtins.path
{
name = "nedryland-config-${builtins.concatStringsSep "-" name}";
path = configRoot + "/${value}";
} else value)
(if builtins.hasAttr key parsedConfig then builtins.getAttr key parsedConfig else { });
in
with builtins;
pkgs.lib.mapAttrsRecursiveCond
builtins.isAttrs
(
path:
let
envVarValue = getEnv "${prefix}_${key}_${builtins.concatStringsSep "_" path}";
in
value:
if envVarValue != "" then envVarValue else (pkgs.lib.attrByPath path value subConfig)
)
structure