diff options
author | lassulus <lassulus@lassul.us> | 2022-10-23 12:29:30 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2022-10-29 13:23:31 +0200 |
commit | 4184cbcd037b79ed627aca20798810518cb328ac (patch) | |
tree | b732656e97f273add7f325a319bb3fcfc43f9859 /module.nix | |
parent | c777d1ca4ff0f759a6517eb2a4d7e9bae1fa9fd2 (diff) |
add module
Diffstat (limited to 'module.nix')
-rw-r--r-- | module.nix | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/module.nix b/module.nix new file mode 100644 index 0000000..611d681 --- /dev/null +++ b/module.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: +let + types = import ./types.nix { inherit lib; }; + cfg = config.disko; +in { + options.disko = { + devices = lib.mkOption { + type = types.devices; + }; + enableConfig = lib.mkOption { + description = '' + configure nixos with the specified devices + should be true if the system is booted with those devices + should be false on an installer image etc. + ''; + type = lib.types.bool; + default = true; + }; + addScripts = lib.mkOption { + description = '' + add disko-create and disko-mount scripts to systemPackages. + ''; + type = lib.types.bool; + default = true; + }; + }; + config = { + environment.systemPackages = (lib.optionals cfg.addScripts [ + (pkgs.writers.writeDashBin "disko-create" '' + export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)} + ${types.diskoLib.create cfg.devices} + '') + (pkgs.writers.writeDashBin "disko-mount" '' + export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)} + ${types.diskoLib.mount cfg.devices} + '') + ]) ++ lib.optionals cfg.enableConfig (types.diskoLib.packages cfg.devices pkgs); + + # Remember to add config keys here if they are added to types + fileSystems = lib.mkIf cfg.enableConfig (lib.mkMerge (lib.catAttrs "fileSystems" (types.diskoLib.config cfg.devices))); + boot = lib.mkIf cfg.enableConfig (lib.mkMerge (lib.catAttrs "boot" (types.diskoLib.config cfg.devices))); + }; +} |