2023-02-06 17:24:34 +03:00
|
|
|
{ pkgs ? import <nixpkgs> { }
|
2023-02-02 16:02:55 +03:00
|
|
|
, lib ? pkgs.lib
|
2022-10-27 01:02:49 +03:00
|
|
|
, mode ? "mount"
|
2022-11-10 01:36:40 +03:00
|
|
|
, flake ? null
|
|
|
|
, flakeAttr ? null
|
|
|
|
, diskoFile ? null
|
2023-01-24 17:57:17 +03:00
|
|
|
, rootMountPoint ? "/mnt"
|
2022-12-01 22:33:03 +03:00
|
|
|
, noDeps ? false
|
2023-02-06 17:24:34 +03:00
|
|
|
, ...
|
|
|
|
}@args:
|
2022-10-27 01:02:49 +03:00
|
|
|
let
|
2022-12-22 13:09:04 +03:00
|
|
|
disko = import ./. {
|
2023-01-24 17:57:17 +03:00
|
|
|
inherit rootMountPoint;
|
2023-02-02 16:02:55 +03:00
|
|
|
inherit lib;
|
2022-12-22 13:09:04 +03:00
|
|
|
};
|
2022-11-10 01:36:40 +03:00
|
|
|
|
2023-05-20 14:55:25 +03:00
|
|
|
diskoAttr =
|
|
|
|
if noDeps then
|
|
|
|
{
|
2023-07-13 18:02:23 +03:00
|
|
|
format = "formatScriptNoDeps";
|
2023-05-20 14:55:25 +03:00
|
|
|
mount = "mountScriptNoDeps";
|
2023-06-23 05:57:57 +03:00
|
|
|
disko = "diskoScriptNoDeps";
|
2023-07-13 18:02:23 +03:00
|
|
|
|
|
|
|
# legacy aliases
|
|
|
|
create = "createScriptNoDeps";
|
|
|
|
zap_create_mount = "diskoScriptNoDeps";
|
2023-05-20 14:55:25 +03:00
|
|
|
}.${mode}
|
|
|
|
else
|
|
|
|
{
|
2023-07-13 18:02:23 +03:00
|
|
|
format = "formatScript";
|
2023-05-20 14:55:25 +03:00
|
|
|
mount = "mountScript";
|
|
|
|
disko = "diskoScript";
|
2023-07-13 18:02:23 +03:00
|
|
|
|
|
|
|
# legacy aliases
|
|
|
|
create = "createScript";
|
|
|
|
zap_create_mount = "diskoScript";
|
2023-05-20 14:55:25 +03:00
|
|
|
}.${mode};
|
|
|
|
|
|
|
|
hasDiskoConfigFlake =
|
|
|
|
diskoFile != null || lib.hasAttrByPath [ "diskoConfigurations" flakeAttr ] (builtins.getFlake flake);
|
|
|
|
|
|
|
|
hasDiskoModuleFlake =
|
|
|
|
lib.hasAttrByPath [ "nixosConfigurations" flakeAttr "config" "disko" "devices" ] (builtins.getFlake flake);
|
|
|
|
|
2023-02-06 17:24:34 +03:00
|
|
|
diskFormat =
|
2023-05-20 14:55:25 +03:00
|
|
|
let
|
|
|
|
diskoConfig =
|
|
|
|
if diskoFile != null then
|
|
|
|
import diskoFile
|
|
|
|
else
|
|
|
|
(builtins.getFlake flake).diskoConfigurations.${flakeAttr};
|
|
|
|
in
|
|
|
|
if builtins.isFunction diskoConfig then
|
|
|
|
diskoConfig ({ inherit lib; } // args)
|
2022-12-01 22:33:03 +03:00
|
|
|
else
|
2023-05-20 14:55:25 +03:00
|
|
|
diskoConfig;
|
2023-02-06 17:24:34 +03:00
|
|
|
|
|
|
|
diskoEval =
|
2023-05-20 14:55:25 +03:00
|
|
|
disko.${diskoAttr} diskFormat pkgs;
|
|
|
|
|
|
|
|
diskoScript =
|
|
|
|
if hasDiskoConfigFlake then
|
|
|
|
diskoEval
|
|
|
|
else if (lib.traceValSeq hasDiskoModuleFlake) then
|
|
|
|
(builtins.getFlake flake).nixosConfigurations.${flakeAttr}.config.system.build.${diskoAttr}
|
2022-12-01 22:33:03 +03:00
|
|
|
else
|
2023-05-20 14:55:25 +03:00
|
|
|
(builtins.abort "neither diskoConfigurations.${flakeAttr} nor nixosConfigurations.${flakeAttr} found");
|
|
|
|
|
2023-02-06 17:24:34 +03:00
|
|
|
in
|
2023-05-20 14:55:25 +03:00
|
|
|
diskoScript
|