From 9b292c4ddb097e2ed66e16db6deab4c0009797ac Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Fri, 5 Jul 2024 02:43:33 +0530 Subject: [PATCH] rico*: put pi specific stuff in a module --- hosts/rico0/default.nix | 9 +-------- hosts/rico0/hardware/default.nix | 6 +----- hosts/rico0/programs/default.nix | 2 -- hosts/rico1/default.nix | 9 +-------- hosts/rico1/hardware/default.nix | 6 +----- hosts/rico1/programs/default.nix | 2 -- hosts/rico2/default.nix | 9 +-------- hosts/rico2/hardware/default.nix | 6 +----- hosts/rico2/programs/default.nix | 2 -- modules/default.nix | 1 + modules/pi.nix | 33 ++++++++++++++++++++++++++++++++ 11 files changed, 40 insertions(+), 45 deletions(-) create mode 100644 modules/pi.nix diff --git a/hosts/rico0/default.nix b/hosts/rico0/default.nix index 59c4244..71a6804 100644 --- a/hosts/rico0/default.nix +++ b/hosts/rico0/default.nix @@ -11,16 +11,9 @@ _: { nodeconfig = { minimize = true; nix.auto-gc = true; + is-pi = true; }; - # https://github.com/NixOS/nixpkgs/issues/126755#issuecomment-869149243 - nixpkgs.overlays = [ - (final: super: { - makeModulesClosure = x: - super.makeModulesClosure (x // { allowMissing = true; }); - }) - ]; - i18n = { defaultLocale = "en_US.UTF-8"; extraLocaleSettings = { diff --git a/hosts/rico0/hardware/default.nix b/hosts/rico0/hardware/default.nix index d62b7f8..c2cffa3 100644 --- a/hosts/rico0/hardware/default.nix +++ b/hosts/rico0/hardware/default.nix @@ -1,15 +1,11 @@ -{ lib, pkgs, ... }: { +{ lib, ... }: { imports = [ ./filesystem.nix ]; - hardware.enableRedistributableFirmware = true; - boot = { consoleLogLevel = 3; initrd = { - availableKernelModules = [ "xhci_pci" ]; systemd.enable = true; }; - kernelPackages = lib.mkDefault pkgs.linuxPackages_rpi4; kernel.sysctl = { "vm.swappiness" = 10; "vm.dirty_ratio" = 3; diff --git a/hosts/rico0/programs/default.nix b/hosts/rico0/programs/default.nix index 3bc319f..0dc90ba 100644 --- a/hosts/rico0/programs/default.nix +++ b/hosts/rico0/programs/default.nix @@ -12,8 +12,6 @@ environment.systemPackages = with pkgs; [ sops age - libraspberrypi - raspberrypi-eeprom ]; } diff --git a/hosts/rico1/default.nix b/hosts/rico1/default.nix index 59c4244..71a6804 100644 --- a/hosts/rico1/default.nix +++ b/hosts/rico1/default.nix @@ -11,16 +11,9 @@ _: { nodeconfig = { minimize = true; nix.auto-gc = true; + is-pi = true; }; - # https://github.com/NixOS/nixpkgs/issues/126755#issuecomment-869149243 - nixpkgs.overlays = [ - (final: super: { - makeModulesClosure = x: - super.makeModulesClosure (x // { allowMissing = true; }); - }) - ]; - i18n = { defaultLocale = "en_US.UTF-8"; extraLocaleSettings = { diff --git a/hosts/rico1/hardware/default.nix b/hosts/rico1/hardware/default.nix index d62b7f8..c2cffa3 100644 --- a/hosts/rico1/hardware/default.nix +++ b/hosts/rico1/hardware/default.nix @@ -1,15 +1,11 @@ -{ lib, pkgs, ... }: { +{ lib, ... }: { imports = [ ./filesystem.nix ]; - hardware.enableRedistributableFirmware = true; - boot = { consoleLogLevel = 3; initrd = { - availableKernelModules = [ "xhci_pci" ]; systemd.enable = true; }; - kernelPackages = lib.mkDefault pkgs.linuxPackages_rpi4; kernel.sysctl = { "vm.swappiness" = 10; "vm.dirty_ratio" = 3; diff --git a/hosts/rico1/programs/default.nix b/hosts/rico1/programs/default.nix index 3bc319f..0dc90ba 100644 --- a/hosts/rico1/programs/default.nix +++ b/hosts/rico1/programs/default.nix @@ -12,8 +12,6 @@ environment.systemPackages = with pkgs; [ sops age - libraspberrypi - raspberrypi-eeprom ]; } diff --git a/hosts/rico2/default.nix b/hosts/rico2/default.nix index 59c4244..71a6804 100644 --- a/hosts/rico2/default.nix +++ b/hosts/rico2/default.nix @@ -11,16 +11,9 @@ _: { nodeconfig = { minimize = true; nix.auto-gc = true; + is-pi = true; }; - # https://github.com/NixOS/nixpkgs/issues/126755#issuecomment-869149243 - nixpkgs.overlays = [ - (final: super: { - makeModulesClosure = x: - super.makeModulesClosure (x // { allowMissing = true; }); - }) - ]; - i18n = { defaultLocale = "en_US.UTF-8"; extraLocaleSettings = { diff --git a/hosts/rico2/hardware/default.nix b/hosts/rico2/hardware/default.nix index d62b7f8..c2cffa3 100644 --- a/hosts/rico2/hardware/default.nix +++ b/hosts/rico2/hardware/default.nix @@ -1,15 +1,11 @@ -{ lib, pkgs, ... }: { +{ lib, ... }: { imports = [ ./filesystem.nix ]; - hardware.enableRedistributableFirmware = true; - boot = { consoleLogLevel = 3; initrd = { - availableKernelModules = [ "xhci_pci" ]; systemd.enable = true; }; - kernelPackages = lib.mkDefault pkgs.linuxPackages_rpi4; kernel.sysctl = { "vm.swappiness" = 10; "vm.dirty_ratio" = 3; diff --git a/hosts/rico2/programs/default.nix b/hosts/rico2/programs/default.nix index 3bc319f..0dc90ba 100644 --- a/hosts/rico2/programs/default.nix +++ b/hosts/rico2/programs/default.nix @@ -12,8 +12,6 @@ environment.systemPackages = with pkgs; [ sops age - libraspberrypi - raspberrypi-eeprom ]; } diff --git a/modules/default.nix b/modules/default.nix index 9e79ce3..cbbc4cb 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,5 +2,6 @@ _: { imports = [ ./general.nix ./nix.nix + ./pi.nix ]; } diff --git a/modules/pi.nix b/modules/pi.nix new file mode 100644 index 0000000..63503d1 --- /dev/null +++ b/modules/pi.nix @@ -0,0 +1,33 @@ +{ lib, config, pkgs, ... }: +let cfg = config.nodeconfig; in { + options.nodeconfig = { + is-pi = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + description = "Is the node a Raspberry Pi?"; + }; + }; + + config = lib.mkIf cfg.is-pi { + # https://github.com/NixOS/nixpkgs/issues/126755#issuecomment-869149243 + nixpkgs.overlays = [ + (final: super: { + makeModulesClosure = x: + super.makeModulesClosure (x // { allowMissing = true; }); + }) + ]; + + boot = { + kernelPackages = lib.mkDefault pkgs.linuxPackages_rpi4; + initrd.availableKernelModules = [ "xhci_pci" ]; + }; + + environment.systemPackages = with pkgs; [ + libraspberrypi + raspberrypi-eeprom + ]; + + hardware.enableRedistributableFirmware = true; + }; +}