mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
Fixes #871 Previously, if a user used v2.10.0 (currently unreleased master), an error like this would be displayed: error: attribute '_cliDestroyFormatMount' missing at /nix/store/fbqgaij9d3b373rq1iav5glzr4dy77qf-disko/share/disko/cli.nix:73:7: 72| else if (lib.traceValSeq hasDiskoModuleFlake) then 73| (builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr} | ^ 74| else This situation now produces a more helpful error: Error: Attribute `nixosConfigurations.testmachine.config.system.build._cliDestroyFormatMount` not found in flake `/home/felix/repos-new/disko`! This is probably caused by the locked version of disko in the flake being different from the version of disko you executed. EITHER set the `disko` input of your flake to `github:nix-community/disko/latest`, run `nix flake update disko` in the flake directory and then try again, OR run `nix run github:nix-community/disko/v1.9.0 -- --help` and use one of its modes.
89 lines
2.7 KiB
Nix
89 lines
2.7 KiB
Nix
{ pkgs ? import <nixpkgs> { }
|
|
, lib ? pkgs.lib
|
|
, mode ? "mount"
|
|
, flake ? null
|
|
, flakeAttr ? null
|
|
, diskoFile ? null
|
|
, rootMountPoint ? "/mnt"
|
|
, noDeps ? false
|
|
, ...
|
|
}@args:
|
|
let
|
|
disko = import ./. {
|
|
inherit rootMountPoint;
|
|
inherit lib;
|
|
};
|
|
|
|
diskoAttr =
|
|
if noDeps then
|
|
{
|
|
destroy = "_cliDestroyNoDeps";
|
|
format = "_cliFormatNoDeps";
|
|
mount = "_cliMountNoDeps";
|
|
|
|
"format,mount" = "_cliFormatMountNoDeps";
|
|
"destroy,format,mount" = "_cliDestroyFormatMountNoDeps";
|
|
|
|
# legacy aliases
|
|
disko = "diskoScriptNoDeps";
|
|
create = "createScriptNoDeps";
|
|
zap_create_mount = "diskoScriptNoDeps";
|
|
}.${mode}
|
|
else
|
|
{
|
|
destroy = "_cliDestroy";
|
|
format = "_cliFormat";
|
|
mount = "_cliMount";
|
|
|
|
"format,mount" = "_cliFormatMount";
|
|
"destroy,format,mount" = "_cliDestroyFormatMount";
|
|
|
|
# legacy aliases
|
|
disko = "diskoScript";
|
|
create = "createScript";
|
|
zap_create_mount = "diskoScript";
|
|
}.${mode};
|
|
|
|
hasDiskoConfigFlake =
|
|
diskoFile != null || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
|
|
|
|
hasDiskoModuleFlake =
|
|
lib.hasAttrByPath [ "nixosConfigurations" flakeAttr "config" "disko" "devices" ] (builtins.getFlake flake);
|
|
|
|
diskFormat =
|
|
let
|
|
diskoConfig =
|
|
if diskoFile != null then
|
|
import diskoFile
|
|
else
|
|
(builtins.getFlake flake).diskoConfigurations.${flakeAttr};
|
|
in
|
|
if builtins.isFunction diskoConfig then
|
|
diskoConfig ({ inherit lib; } // args)
|
|
else
|
|
diskoConfig;
|
|
|
|
diskoEval =
|
|
disko.${diskoAttr} diskFormat pkgs;
|
|
|
|
diskoScript =
|
|
if hasDiskoConfigFlake then
|
|
diskoEval
|
|
else if (lib.traceValSeq hasDiskoModuleFlake) then
|
|
(builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr} or (
|
|
pkgs.writeShellScriptBin "disko-compat-error" ''
|
|
echo 'Error: Attribute `nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}` >&2
|
|
echo ' not found in flake `${flake}`!' >&2
|
|
echo ' This is probably caused by the locked version of disko in the flake' >&2
|
|
echo ' being different from the version of disko you executed.' >&2
|
|
echo 'EITHER set the `disko` input of your flake to `github:nix-community/disko/latest`,' >&2
|
|
echo ' run `nix flake update disko` in the flake directory and then try again,' >&2
|
|
echo 'OR run `nix run github:nix-community/disko/v1.9.0 -- --help` and use one of its modes.' >&2
|
|
exit 1;''
|
|
)
|
|
else
|
|
(builtins.abort "couldn't find `diskoConfigurations.${flakeAttr}` or `nixosConfigurations.${flakeAttr}.config.disko.devices`");
|
|
|
|
in
|
|
diskoScript
|