From 50e116bca759d3c6353c09e0dbeff10f4837626c Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 29 Aug 2024 09:14:27 -0400 Subject: [PATCH] System: Make RAID a common module and allow other systems to mount it --- hosts/Dimaga/default.nix | 8 ++++---- hosts/Dimaga/hardware-configuration.nix | 9 --------- hosts/Khanda/default.nix | 3 +++ hosts/Shura/default.nix | 3 +++ modules/common.nix | 2 ++ modules/system/raid.nix | 26 +++++++++++++++++++++++++ 6 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 modules/system/raid.nix diff --git a/hosts/Dimaga/default.nix b/hosts/Dimaga/default.nix index 6dfafef..f07d919 100644 --- a/hosts/Dimaga/default.nix +++ b/hosts/Dimaga/default.nix @@ -96,10 +96,10 @@ in }; }; - packages = [ - start-services - pkgs.htop - ]; + packages = [ start-services ]; + + # Enable support for primary RAID array + raid.sapana.enable = true; # Change how long old generations are kept for. retentionPeriod = "30d"; diff --git a/hosts/Dimaga/hardware-configuration.nix b/hosts/Dimaga/hardware-configuration.nix index f3029df..943f41e 100644 --- a/hosts/Dimaga/hardware-configuration.nix +++ b/hosts/Dimaga/hardware-configuration.nix @@ -28,15 +28,6 @@ in kernelModules = [ "kvm-intel" ]; extraModulePackages = [ ]; - # Enable mdadm for Sapana (RAID 5 primary storage). - swraid = { - enable = true; - mdadmConf = '' - ARRAY /dev/md/Sapana metadata=1.2 UUID=51076daf:efdb34dd:bce48342:3b549fcb - MAILADDR ${config.secrets.users.aires.email} - ''; - }; - # Enable support for building ARM64 packages binfmt.emulatedSystems = [ "aarch64-linux" ]; }; diff --git a/hosts/Khanda/default.nix b/hosts/Khanda/default.nix index 8871d75..e8410f4 100644 --- a/hosts/Khanda/default.nix +++ b/hosts/Khanda/default.nix @@ -45,6 +45,9 @@ in # Enable GPU support. gpu.intel.enable = true; + # Enable support for primary RAID array (just in case) + raid.sapana.enable = true; + # Change how long old generations are kept for. retentionPeriod = "14d"; diff --git a/hosts/Shura/default.nix b/hosts/Shura/default.nix index 7d57fcf..6b94920 100644 --- a/hosts/Shura/default.nix +++ b/hosts/Shura/default.nix @@ -55,6 +55,9 @@ in keepassxc # Use native instead of Flatpak due to weird performance issues ]; + # Enable support for primary RAID array (just in case) + raid.sapana.enable = true; + # Keep old generations for two weeks. retentionPeriod = "14d"; diff --git a/modules/common.nix b/modules/common.nix index 0a02172..7f254fe 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -15,6 +15,8 @@ aux.system = { packages = with pkgs; [ fastfetch # Show a neat system statistics screen when opening a terminal + htop + mdadm # RAID management nh # Nix Helper: https://github.com/viperML/nh zellij # Terminal multiplexer ]; diff --git a/modules/system/raid.nix b/modules/system/raid.nix new file mode 100644 index 0000000..db8e920 --- /dev/null +++ b/modules/system/raid.nix @@ -0,0 +1,26 @@ +# Configures bluetooth. +{ lib, config, ... }: + +let + cfg = config.aux.system.raid; +in +{ + + options = { + aux.system.raid = { + enable = lib.mkEnableOption "Enables RAID support."; + sapana.enable = lib.mkEnableOption "Enables support for the Sapana/storage array."; + }; + }; + + config = lib.mkMerge [ + (lib.mkIf cfg.enable { boot.swraid.enable = true; }) + (lib.mkIf cfg.sapana.enable { + aux.system.raid.enable = true; + boot.swraid.mdadmConf = '' + ARRAY /dev/md/Sapana metadata=1.2 UUID=51076daf:efdb34dd:bce48342:3b549fcb + MAILADDR ${config.secrets.users.aires.email} + ''; + }) + ]; +}