Skip to content

Commit e43530c

Browse files
committed
fix(module-functions): properly handle if disabled
1 parent 8026f28 commit e43530c

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

lib/module-functions.nix

+12-20
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
contentIfEnabled ? {},
1111
contentIfDisabled ? {},
1212
contentFinally ? {},
13-
negate ? false,
1413
root ? false,
1514
}: let
1615
config1 =
@@ -27,10 +26,7 @@
2726
then content config2
2827
else content;
2928

30-
condition =
31-
if !negate
32-
then config2.enable or true
33-
else !config2.enable or true;
29+
condition = config2.enable or true;
3430
in {
3531
imports = [
3632
{
@@ -39,7 +35,7 @@
3935
content = wrapContent contentIfEnabled;
4036
}
4137
{
42-
inherit condition;
38+
condition = !condition;
4339
_type = "if";
4440
content = wrapContent contentIfDisabled;
4541
}
@@ -51,19 +47,17 @@
5147
moduleRaw {
5248
inherit type name contentIfEnabled;
5349
};
54-
moduleIfDisabled = type: name: contentIfEnabled:
50+
moduleIfDisabled = type: name: contentIfDisabled:
5551
moduleRaw {
56-
inherit type name contentIfEnabled;
57-
negate = true;
52+
inherit type name contentIfDisabled;
5853
};
5954
moduleIfEnabledFinally = type: name: contentIfEnabled: contentFinally:
6055
moduleRaw {
6156
inherit type name contentIfEnabled contentFinally;
6257
};
63-
moduleIfDisabledFinally = type: name: contentIfEnabled: contentFinally:
58+
moduleIfDisabledFinally = type: name: contentIfDisabled: contentFinally:
6459
moduleRaw {
65-
inherit type name contentIfEnabled contentFinally;
66-
negate = true;
60+
inherit type name contentIfDisabled contentFinally;
6761
};
6862
moduleIfElse = type: name: contentIfEnabled: contentIfDisabled:
6963
moduleRaw {
@@ -74,26 +68,24 @@
7468
inherit type name contentIfEnabled contentIfDisabled contentFinally;
7569
};
7670

77-
rootModuleIfEnabled = type: name: contentIfEnabled:
71+
rootModuleIfEnabled = type: name: contentIfDisabled:
7872
moduleRaw {
79-
inherit type name contentIfEnabled;
73+
inherit type name contentIfDisabled;
8074
root = true;
8175
};
82-
rootModuleIfDisabled = type: name: contentIfEnabled:
76+
rootModuleIfDisabled = type: name: contentIfDisabled:
8377
moduleRaw {
84-
inherit type name contentIfEnabled;
85-
negate = true;
78+
inherit type name contentIfDisabled;
8679
root = true;
8780
};
8881
rootModuleIfEnabledFinally = type: name: contentIfEnabled: contentFinally:
8982
moduleRaw {
9083
inherit type name contentIfEnabled contentFinally;
9184
root = true;
9285
};
93-
rootModuleIfDisabledFinally = type: name: contentIfEnabled: contentFinally:
86+
rootModuleIfDisabledFinally = type: name: contentIfDisabled: contentFinally:
9487
moduleRaw {
95-
inherit type name contentIfEnabled contentFinally;
96-
negate = true;
88+
inherit type name contentIfDisabled contentFinally;
9789
root = true;
9890
};
9991
rootModuleIfElse = type: name: contentIfEnabled: contentIfDisabled:

0 commit comments

Comments
 (0)