disko/default.nix

54 lines
2.5 KiB
Nix
Raw Permalink Normal View History

{ lib ? import <nixpkgs/lib>
, rootMountPoint ? "/mnt"
, checked ? false
}:
2022-08-24 20:24:33 +00:00
let
2023-05-16 11:40:03 +00:00
diskoLib = import ./lib { inherit lib rootMountPoint; };
eval = cfg: lib.evalModules {
modules = lib.singleton {
# _file = toString input;
imports = lib.singleton { disko.devices = cfg.disko.devices; };
options = {
disko.devices = lib.mkOption {
2023-05-16 11:40:03 +00:00
type = diskoLib.devices;
};
};
2022-08-25 13:08:26 +00:00
};
};
in
{
2023-05-16 11:40:03 +00:00
lib = diskoLib;
create = cfg: diskoLib.create (eval cfg).config.disko.devices;
createScript = cfg: pkgs: (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-create" ''
export PATH=${lib.makeBinPath (diskoLib.packages (eval cfg).config.disko.devices pkgs)}:$PATH
${diskoLib.create (eval cfg).config.disko.devices}
2022-10-26 22:02:37 +00:00
'';
2023-05-16 11:40:03 +00:00
createScriptNoDeps = cfg: pkgs: (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-create" ''
${diskoLib.create (eval cfg).config.disko.devices}
2022-12-01 19:33:03 +00:00
'';
2023-05-16 11:40:03 +00:00
mount = cfg: diskoLib.mount (eval cfg).config.disko.devices;
mountScript = cfg: pkgs: (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-mount" ''
export PATH=${lib.makeBinPath (diskoLib.packages (eval cfg).config.disko.devices pkgs)}:$PATH
${diskoLib.mount (eval cfg).config.disko.devices}
2022-10-26 22:02:37 +00:00
'';
2023-05-16 11:40:03 +00:00
mountScriptNoDeps = cfg: pkgs: (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-mount" ''
${diskoLib.mount (eval cfg).config.disko.devices}
2022-12-01 19:33:03 +00:00
'';
disko = cfg: diskoLib.zapCreateMount (eval cfg).config.disko.devices;
diskoScript = cfg: pkgs: (diskoLib.writeCheckedBash { inherit pkgs checked; }) "disko-zap-create-mount" ''
2023-06-23 02:58:08 +00:00
export PATH=${lib.makeBinPath ((diskoLib.packages (eval cfg).config.disko.devices pkgs) ++ [ pkgs.bash ])}:$PATH
2023-05-16 11:40:03 +00:00
${diskoLib.zapCreateMount (eval cfg).config.disko.devices}
'';
2023-06-23 02:57:57 +00:00
# we keep this old output for backwards compatibility
diskoNoDeps = cfg: pkgs: builtins.trace "the .diskoNoDeps output is deprecated, plase use .diskoScriptNoDeps instead" (
(diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-zap-create-mount" ''
${diskoLib.zapCreateMount (eval cfg).config.disko.devices}
''
);
diskoScriptNoDeps = cfg: pkgs: (diskoLib.writeCheckedBash { inherit pkgs checked; noDeps = true; }) "disko-zap-create-mount" ''
2023-05-16 11:40:03 +00:00
${diskoLib.zapCreateMount (eval cfg).config.disko.devices}
2022-12-01 19:33:03 +00:00
'';
2023-05-16 11:40:03 +00:00
config = cfg: { imports = diskoLib.config (eval cfg).config.disko.devices; };
packages = cfg: diskoLib.packages (eval cfg).config.disko.devices;
2018-09-11 18:52:12 +00:00
}