disko/cli.nix

25 lines
649 B
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-10-26 22:02:49 +00:00
, ... }@args:
let
disko = import ./. { };
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-10-26 22:02:49 +00:00
diskoEval = 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
2022-10-26 22:02:49 +00:00
else
builtins.abort "invalid mode"
;
in diskoEval