mirror of
https://github.com/nix-community/disko.git
synced 2026-12-02 05:53:28 +01:00
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.
This commit is contained in:
1 parent
eaa51560df
commit
cb64993826
1 file changed
+41
-17
@@ -14,46 +14,70 @@ let
|
|||||||
inherit lib;
|
inherit lib;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hasDiskoFile = diskoFile != null;
|
||||||
|
|
||||||
diskoAttr =
|
diskoAttr =
|
||||||
if noDeps then
|
(if noDeps then
|
||||||
{
|
(if hasDiskoFile then
|
||||||
destroy = "_cliDestroyNoDeps";
|
{
|
||||||
format = "_cliFormatNoDeps";
|
destroy = "_cliDestroyNoDeps";
|
||||||
mount = "_cliMountNoDeps";
|
format = "_cliFormatNoDeps";
|
||||||
|
mount = "_cliMountNoDeps";
|
||||||
|
|
||||||
"format,mount" = "_cliFormatMountNoDeps";
|
"format,mount" = "_cliFormatMountNoDeps";
|
||||||
"destroy,format,mount" = "_cliDestroyFormatMountNoDeps";
|
"destroy,format,mount" = "_cliDestroyFormatMountNoDeps";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
destroy = "destroyNoDeps";
|
||||||
|
format = "formatNoDeps";
|
||||||
|
mount = "mountNoDeps";
|
||||||
|
|
||||||
|
"format,mount" = "formatMountNoDeps";
|
||||||
|
"destroy,format,mount" = "destroyFormatMountNoDeps";
|
||||||
|
}) // {
|
||||||
# legacy aliases
|
# legacy aliases
|
||||||
disko = "diskoScriptNoDeps";
|
disko = "diskoScriptNoDeps";
|
||||||
create = "createScriptNoDeps";
|
create = "createScriptNoDeps";
|
||||||
zap_create_mount = "diskoScriptNoDeps";
|
zap_create_mount = "diskoScriptNoDeps";
|
||||||
}.${mode}
|
}
|
||||||
else
|
else
|
||||||
{
|
(if hasDiskoFile then
|
||||||
destroy = "_cliDestroy";
|
{
|
||||||
format = "_cliFormat";
|
destroy = "_cliDestroy";
|
||||||
mount = "_cliMount";
|
format = "_cliFormat";
|
||||||
|
mount = "_cliMount";
|
||||||
|
|
||||||
"format,mount" = "_cliFormatMount";
|
"format,mount" = "_cliFormatMount";
|
||||||
"destroy,format,mount" = "_cliDestroyFormatMount";
|
"destroy,format,mount" = "_cliDestroyFormatMount";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
destroy = "destroy";
|
||||||
|
format = "format";
|
||||||
|
mount = "munt";
|
||||||
|
|
||||||
|
"format,mount" = "formatMount";
|
||||||
|
"destroy,format,mount" = "destroyFormatMount";
|
||||||
|
}) // {
|
||||||
# legacy aliases
|
# legacy aliases
|
||||||
disko = "diskoScript";
|
disko = "diskoScript";
|
||||||
create = "createScript";
|
create = "createScript";
|
||||||
zap_create_mount = "diskoScript";
|
zap_create_mount = "diskoScript";
|
||||||
}.${mode};
|
}
|
||||||
|
).${mode};
|
||||||
|
|
||||||
hasDiskoConfigFlake =
|
hasDiskoConfigFlake =
|
||||||
diskoFile != null || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
|
hasDiskoFile || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
|
||||||
|
|
||||||
hasDiskoModuleFlake =
|
hasDiskoModuleFlake =
|
||||||
lib.hasAttrByPath [ "nixosConfigurations" flakeAttr "config" "disko" "devices" ] (builtins.getFlake flake);
|
lib.hasAttrByPath [ "nixosConfigurations" flakeAttr "config" "disko" "devices" ] (builtins.getFlake flake);
|
||||||
|
|
||||||
|
|
||||||
diskFormat =
|
diskFormat =
|
||||||
let
|
let
|
||||||
diskoConfig =
|
diskoConfig =
|
||||||
if diskoFile != null then
|
if hasDiskoFile then
|
||||||
import diskoFile
|
import diskoFile
|
||||||
else
|
else
|
||||||
(builtins.getFlake flake).diskoConfigurations.${flakeAttr};
|
(builtins.getFlake flake).diskoConfigurations.${flakeAttr};
|
||||||
|
|||||||
Reference in new issue
Block a user