summaryrefslogtreecommitdiffstats
path: root/default.nix
blob: ada33e47ea6bb5b71b3fe3e11f98677160385bcb (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
38
39
40
41
42
43
44
45
46
47
48
49
{ lib ? import <nixpkgs/lib> }:
let
  types = import ./types.nix { inherit lib; };
  eval = cfg: lib.evalModules {
    modules = lib.singleton {
      # _file = toString input;
      imports = lib.singleton { devices = cfg; };
      options = {
        devices = lib.mkOption {
          type = types.devices;
        };
      };
    };
  };
in {
  types = types;
  create = cfg: types.diskoLib.create (eval cfg).config.devices;
  createScript = cfg: pkgs: pkgs.writeScript "disko-create" ''
    #!/usr/bin/env bash
    export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
    ${types.diskoLib.create (eval cfg).config.devices}
  '';
  createScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-create" ''
    #!/usr/bin/env bash
    ${types.diskoLib.create (eval cfg).config.devices}
  '';
  mount = cfg: types.diskoLib.mount (eval cfg).config.devices;
  mountScript = cfg: pkgs: pkgs.writeScript "disko-mount" ''
    #!/usr/bin/env bash
    export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
    ${types.diskoLib.mount (eval cfg).config.devices}
  '';
  mountScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-mount" ''
    #!/usr/bin/env bash
    ${types.diskoLib.mount (eval cfg).config.devices}
  '';
  zapCreateMount = cfg: types.diskoLib.zapCreateMount (eval cfg).config.devices;
  zapCreateMountScript = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" ''
    #!/usr/bin/env bash
    export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}:$PATH
    ${types.diskoLib.zapCreateMount (eval cfg).config.devices}
  '';
  zapCreateMountScriptNoDeps = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" ''
    #!/usr/bin/env bash
    ${types.diskoLib.zapCreateMount (eval cfg).config.devices}
  '';
  config = cfg: { imports = types.diskoLib.config (eval cfg).config.devices; };
  packages = cfg: types.diskoLib.packages (eval cfg).config.devices;
}