summaryrefslogtreecommitdiffstats
path: root/cli.nix
blob: 006779e0eaae7f997752d8974c0be3d300fb7ed1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ pkgs ? import <nixpkgs> {}
, mode ? "mount"
, flake ? null
, flakeAttr ? null
, diskoFile ? null
, noDeps ? false
, ... }@args:
let
  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;

  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"
  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.zapCreateMount diskFormat pkgs
    else
      builtins.abort "invalid mode"
  ;
in diskoEval