mirror of
https://github.com/nix-community/disko
synced 2024-11-10 06:14:14 +00:00
4ba8181319
As discussed in [this comment](https://github.com/nix-community/disko/pull/143#discussion_r1097912402), as a blanket rule converting everything possible to `inherit` like statements can hurt readability. Add config file for statix to disable these checks and fixes, then rerun the autofix with these options.
58 lines
2.1 KiB
Nix
58 lines
2.1 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
let
|
|
types = import ./types {
|
|
inherit lib;
|
|
rootMountPoint = config.disko.rootMountPoint;
|
|
};
|
|
cfg = config.disko;
|
|
in
|
|
{
|
|
options.disko = {
|
|
devices = lib.mkOption {
|
|
type = types.devices;
|
|
default = { };
|
|
description = "The devices to set up";
|
|
};
|
|
rootMountPoint = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "/mnt";
|
|
description = "Where the device tree should be mounted by the mountScript";
|
|
};
|
|
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;
|
|
};
|
|
};
|
|
config = lib.mkIf (cfg.devices.disk != { }) {
|
|
system.build.formatScript = pkgs.writers.writeBash "disko-create" ''
|
|
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
|
${types.diskoLib.create cfg.devices}
|
|
'';
|
|
|
|
system.build.mountScript = pkgs.writers.writeBash "disko-mount" ''
|
|
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
|
${types.diskoLib.mount cfg.devices}
|
|
'';
|
|
|
|
system.build.disko = pkgs.writers.writeBash "disko" ''
|
|
export PATH=${lib.makeBinPath (types.diskoLib.packages cfg.devices pkgs)}:$PATH
|
|
${types.diskoLib.zapCreateMount cfg.devices}
|
|
'';
|
|
|
|
# This is useful to skip copying executables uploading a script to an in-memory installer
|
|
system.build.diskoNoDeps = pkgs.writeScript "disko" ''
|
|
#!/usr/bin/env bash
|
|
${types.diskoLib.zapCreateMount cfg.devices}
|
|
'';
|
|
|
|
# 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)));
|
|
swapDevices = lib.mkIf cfg.enableConfig (lib.mkMerge (lib.catAttrs "swapDevices" (types.diskoLib.config cfg.devices)));
|
|
};
|
|
}
|