Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions lib/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ let
(module:
mapAttrs
(n: value:
map (config: { inherit (module) file; inherit config; }) (pushDownProperties value)
map (config: { inherit (module) file; inherit config; }) (
builtins.addErrorContext "while processing definitions from `${module.file}`" (pushDownProperties value)
)
)
module.config
)
Expand Down Expand Up @@ -999,15 +1001,15 @@ let

: 1\. Function argument
*/
pushDownProperties = cfg:
if cfg._type or "" == "merge" then
concatMap pushDownProperties cfg.contents
else if cfg._type or "" == "if" then
map (mapAttrs (n: v: mkIf cfg.condition v)) (pushDownProperties cfg.content)
else if cfg._type or "" == "override" then
map (mapAttrs (n: v: mkOverride cfg.priority v)) (pushDownProperties cfg.content)
else # FIXME: handle mkOrder?
[ cfg ];
pushDownProperties =
let
matchProperties = {
"merge" = { _type, contents }: concatMap pushDownProperties contents;
"if" = { _type, condition, content }: map (mapAttrs (n: v: mkIf condition v)) (pushDownProperties content);
"override" = { _type, priority, content }: map (mapAttrs (n: v: mkOverride priority v)) (pushDownProperties content);
};
in
cfg: (matchProperties.${cfg._type or ""} or (cfg: [ cfg ])) cfg;

/**
Given a config value, expand mkMerge properties, and discharge
Expand All @@ -1027,19 +1029,25 @@ let

: 1\. Function argument
*/
dischargeProperties = def:
if def._type or "" == "merge" then
concatMap dischargeProperties def.contents
else if def._type or "" == "if" then
if isBool def.condition then
if def.condition then
dischargeProperties def.content
else
[ ]
else
throw "‘mkIf’ called with a non-Boolean condition"
else
[ def ];
dischargeProperties =
let
matchProperties = {
"merge" =
# Handle mkMerge attributes (error if unknown attributes are present)
{ _type, contents }: concatMap dischargeProperties contents;
"if" =
# Handle mkIf attributes (error if unknown attributes are present)
{ _type, condition, content }:
if isBool condition then
if condition then
dischargeProperties content
else
[ ]
else
throw "‘mkIf’ called with a non-Boolean condition";
};
in
def: (matchProperties.${def._type or ""} or (def: [ def ])) def;

/**
Given a list of config values, process the mkOverride properties,
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/services/web-apps/movim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ in
};

nginx =
mkIf (cfg.nginx != null) {
mkIf (cfg.nginx != null) ({
enable = true;
recommendedOptimisation = mkDefault true;
recommendedProxySettings = true;
Expand Down Expand Up @@ -677,7 +677,7 @@ in
}
// lib.optionalAttrs (cfg.precompressStaticFiles.brotli.enable) {
recommendedBrotliSettings = mkDefault true;
};
});

mysql = mkIf (cfg.database.createLocally && cfg.database.type == "mysql") {
enable = mkDefault true;
Expand Down
Loading