disko/cli.nix

38 lines
1 KiB
Nix
Raw Normal View History

2022-10-26 22:02:49 +00:00
{ pkgs ? import <nixpkgs> {}
, mode ? "mount"
, flake ? null
, flakeAttr ? null
, diskoFile ? null
2022-12-01 19:33:03 +00:00
, noDeps ? false
2022-10-26 22:02:49 +00:00
, ... }@args:
let
2022-12-22 10:09:04 +00:00
disko = import ./. {
lib = pkgs.lib;
};
diskFormat = if flake != null then
(pkgs.lib.attrByPath [ "diskoConfigurations" flakeAttr ] (builtins.abort "${flakeAttr} does not exist") (builtins.getFlake flake)) args
else
import diskoFile args;
2022-12-01 19:33:03 +00:00
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-10-26 22:02:49 +00:00
else
2022-12-01 19:33:03 +00:00
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.zapCreateMount diskFormat pkgs
else
builtins.abort "invalid mode"
2022-10-26 22:02:49 +00:00
;
in diskoEval