mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-30 17:43:42 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
108 lines
2.9 KiB
Nix
108 lines
2.9 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
|
|
cfg = config.boot.swraid;
|
|
|
|
mdadm_conf = config.environment.etc."mdadm.conf";
|
|
|
|
enable_implicitly_for_old_state_versions = lib.versionOlder config.system.stateVersion "23.11";
|
|
|
|
minimum_config_is_set =
|
|
config_text: (builtins.match ".*(MAILADDR|PROGRAM).*" mdadm_conf.text) != null;
|
|
|
|
in
|
|
{
|
|
imports = [
|
|
(lib.mkRenamedOptionModule
|
|
[ "boot" "initrd" "services" "swraid" "enable" ]
|
|
[ "boot" "swraid" "enable" ]
|
|
)
|
|
(lib.mkRenamedOptionModule
|
|
[ "boot" "initrd" "services" "swraid" "mdadmConf" ]
|
|
[ "boot" "swraid" "mdadmConf" ]
|
|
)
|
|
];
|
|
|
|
options.boot.swraid = {
|
|
enable = lib.mkEnableOption "swraid support using mdadm" // {
|
|
description = ''
|
|
Whether to enable support for Linux MD RAID arrays.
|
|
|
|
When this is enabled, mdadm will be added to the system path,
|
|
and MD RAID arrays will be detected and activated
|
|
automatically, both in stage-1 (initramfs) and in stage-2 (the
|
|
final NixOS system).
|
|
|
|
This should be enabled if you want to be able to access and/or
|
|
boot from MD RAID arrays. {command}`nixos-generate-config`
|
|
should detect it correctly in the standard installation
|
|
procedure.
|
|
'';
|
|
default = enable_implicitly_for_old_state_versions;
|
|
defaultText = "`true` if stateVersion is older than 23.11";
|
|
};
|
|
|
|
mdadmConf = lib.mkOption {
|
|
description = "Contents of {file}`/etc/mdadm.conf`.";
|
|
type = lib.types.lines;
|
|
default = "";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
warnings =
|
|
lib.mkIf (!enable_implicitly_for_old_state_versions && !minimum_config_is_set mdadm_conf)
|
|
[
|
|
"mdadm: Neither MAILADDR nor PROGRAM has been set. This will cause the `mdmon` service to crash."
|
|
];
|
|
|
|
environment.systemPackages = [ pkgs.mdadm ];
|
|
|
|
environment.etc."mdadm.conf".text = lib.mkAfter cfg.mdadmConf;
|
|
|
|
services.udev.packages = [ pkgs.mdadm ];
|
|
|
|
systemd.packages = [ pkgs.mdadm ];
|
|
|
|
boot.initrd = {
|
|
availableKernelModules = [
|
|
"md_mod"
|
|
"raid0"
|
|
"raid1"
|
|
"raid10"
|
|
"raid456"
|
|
];
|
|
|
|
extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
|
cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
|
|
'';
|
|
|
|
extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
|
# Add RAID mdadm tool.
|
|
copy_bin_and_libs ${pkgs.mdadm}/sbin/mdadm
|
|
copy_bin_and_libs ${pkgs.mdadm}/sbin/mdmon
|
|
'';
|
|
|
|
extraUtilsCommandsTest = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
|
$out/bin/mdadm --version
|
|
'';
|
|
|
|
extraFiles."/etc/mdadm.conf".source = pkgs.writeText "mdadm.conf" mdadm_conf.text;
|
|
|
|
systemd = {
|
|
contents."/etc/mdadm.conf".text = mdadm_conf.text;
|
|
|
|
packages = [ pkgs.mdadm ];
|
|
initrdBin = [ pkgs.mdadm ];
|
|
};
|
|
|
|
services.udev.packages = [ pkgs.mdadm ];
|
|
};
|
|
};
|
|
}
|