disko/cli.nix

45 lines
1.2 KiB
Nix
Raw Normal View History

{ pkgs ? import <nixpkgs> { }
2023-02-02 16:02:55 +03:00
, lib ? pkgs.lib
2022-10-27 01:02:49 +03:00
, mode ? "mount"
, flake ? null
, flakeAttr ? null
, diskoFile ? null
, rootMountPoint ? "/mnt"
2022-12-01 22:33:03 +03:00
, noDeps ? false
, ...
}@args:
2022-10-27 01:02:49 +03:00
let
2022-12-22 13:09:04 +03:00
disko = import ./. {
inherit rootMountPoint;
2023-02-02 16:02:55 +03:00
inherit lib;
2022-12-22 13:09:04 +03:00
};
diskFormat =
if flake != null then
(pkgs.lib.attrByPath [ "diskoConfigurations" flakeAttr ] (builtins.abort "${flakeAttr} does not exist") (builtins.getFlake flake)) args
2022-12-01 22:33:03 +03:00
else
import diskoFile ({ inherit lib; } // args);
diskoEval =
if noDeps then
if (mode == "create") then
disko.createScriptNoDeps diskFormat pkgs
else if (mode == "mount") then
disko.mountScriptNoDeps diskFormat pkgs
else if (mode == "zap_create_mount") then
disko.zapCreateMountScriptNoDeps diskFormat pkgs
else
builtins.abort "invalid mode"
2022-12-01 22:33:03 +03:00
else
if (mode == "create") then
disko.createScript diskFormat pkgs
else if (mode == "mount") then
disko.mountScript diskFormat pkgs
else if (mode == "zap_create_mount") then
disko.zapCreateMountScript diskFormat pkgs
else
builtins.abort "invalid mode"
2022-10-27 01:02:49 +03:00
;
in
diskoEval