Skip to content

Commit cb64993

Browse files
iFreilichtmergify[bot]
authored andcommitted
cli: Fix "attribute missing" error when using flake
The final config's attributes have different names than those defined in ./default.nix, so this failed previously.
1 parent eaa5156 commit cb64993

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

cli.nix

+41-17
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,70 @@ let
1414
inherit lib;
1515
};
1616

17+
hasDiskoFile = diskoFile != null;
18+
1719
diskoAttr =
18-
if noDeps then
19-
{
20-
destroy = "_cliDestroyNoDeps";
21-
format = "_cliFormatNoDeps";
22-
mount = "_cliMountNoDeps";
20+
(if noDeps then
21+
(if hasDiskoFile then
22+
{
23+
destroy = "_cliDestroyNoDeps";
24+
format = "_cliFormatNoDeps";
25+
mount = "_cliMountNoDeps";
2326

24-
"format,mount" = "_cliFormatMountNoDeps";
25-
"destroy,format,mount" = "_cliDestroyFormatMountNoDeps";
27+
"format,mount" = "_cliFormatMountNoDeps";
28+
"destroy,format,mount" = "_cliDestroyFormatMountNoDeps";
29+
}
30+
else
31+
{
32+
destroy = "destroyNoDeps";
33+
format = "formatNoDeps";
34+
mount = "mountNoDeps";
2635

36+
"format,mount" = "formatMountNoDeps";
37+
"destroy,format,mount" = "destroyFormatMountNoDeps";
38+
}) // {
2739
# legacy aliases
2840
disko = "diskoScriptNoDeps";
2941
create = "createScriptNoDeps";
3042
zap_create_mount = "diskoScriptNoDeps";
31-
}.${mode}
43+
}
3244
else
33-
{
34-
destroy = "_cliDestroy";
35-
format = "_cliFormat";
36-
mount = "_cliMount";
45+
(if hasDiskoFile then
46+
{
47+
destroy = "_cliDestroy";
48+
format = "_cliFormat";
49+
mount = "_cliMount";
3750

38-
"format,mount" = "_cliFormatMount";
39-
"destroy,format,mount" = "_cliDestroyFormatMount";
51+
"format,mount" = "_cliFormatMount";
52+
"destroy,format,mount" = "_cliDestroyFormatMount";
53+
}
54+
else
55+
{
56+
destroy = "destroy";
57+
format = "format";
58+
mount = "munt";
4059

60+
"format,mount" = "formatMount";
61+
"destroy,format,mount" = "destroyFormatMount";
62+
}) // {
4163
# legacy aliases
4264
disko = "diskoScript";
4365
create = "createScript";
4466
zap_create_mount = "diskoScript";
45-
}.${mode};
67+
}
68+
).${mode};
4669

4770
hasDiskoConfigFlake =
48-
diskoFile != null || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
71+
hasDiskoFile || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
4972

5073
hasDiskoModuleFlake =
5174
lib.hasAttrByPath [ "nixosConfigurations" flakeAttr "config" "disko" "devices" ] (builtins.getFlake flake);
5275

76+
5377
diskFormat =
5478
let
5579
diskoConfig =
56-
if diskoFile != null then
80+
if hasDiskoFile then
5781
import diskoFile
5882
else
5983
(builtins.getFlake flake).diskoConfigurations.${flakeAttr};

0 commit comments

Comments
 (0)