diff --git a/hosts/2maccabees/default.nix b/hosts/2maccabees/default.nix index 951b96f..4f5c077 100644 --- a/hosts/2maccabees/default.nix +++ b/hosts/2maccabees/default.nix @@ -7,8 +7,7 @@ ./home-assistant.nix ./networking.nix ./vhosts.nix - ../../profiles/rpi4.nix - ../../profiles/home.nix ]; networking.hostName = "2maccabees"; + greg.rpi4.enable = true; } diff --git a/hosts/2maccabees/hardware-configuration.nix b/hosts/2maccabees/hardware-configuration.nix index 50db628..242c146 100755 --- a/hosts/2maccabees/hardware-configuration.nix +++ b/hosts/2maccabees/hardware-configuration.nix @@ -4,28 +4,28 @@ { config, lib, pkgs, modulesPath, ... }: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" "uas" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ ]; - boot.extraModulePackages = [ ]; + boot.initrd.availableKernelModules = [ "xhci_pci" "usbhid" "usb_storage" "uas" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/35f9a49a-b557-4eb3-a013-2afca7a990e4"; - fsType = "btrfs"; - }; + fileSystems."/" ={ + device = "/dev/disk/by-uuid/35f9a49a-b557-4eb3-a013-2afca7a990e4"; + fsType = "btrfs"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/A982-C8A3"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/A982-C8A3"; + fsType = "vfat"; + }; - swapDevices = - [ { device = "/dev/disk/by-uuid/4b6f2dc4-d845-4ec4-81f2-4f61bb3f282d"; } - ]; + swapDevices = [ { + device = "/dev/disk/by-uuid/4b6f2dc4-d845-4ec4-81f2-4f61bb3f282d"; + } ]; - powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; + powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand"; } diff --git a/hosts/linode/default.nix b/hosts/linode/default.nix index f322017..2ab58f5 100644 --- a/hosts/linode/default.nix +++ b/hosts/linode/default.nix @@ -3,12 +3,13 @@ { imports = [ ./hardware-configuration.nix - ../../profiles/linode.nix ./nextcloud.nix ./nginx.nix ./postgres.nix ./synapse.nix ]; + greg.home = false; + greg.linode.enable = true; networking.hostName = "linode"; networking.domain = "thehellings.com"; } diff --git a/modules/default.nix b/modules/default.nix index 0259dc0..cddba76 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,6 +2,9 @@ { imports = [ + ./home.nix + ./linode.nix ./proxy.nix + ./rpi4.nix ]; } diff --git a/modules/home.nix b/modules/home.nix new file mode 100644 index 0000000..8040dce --- /dev/null +++ b/modules/home.nix @@ -0,0 +1,18 @@ +{ config, lib, ... }: + +let + cfg = config.greg.home; + +in with lib; +{ + options.greg.home = mkOption { + type = types.bool; + default = true; + description = "Sets the device up to be part of my home network"; + }; + + config = mkIf cfg { + time.timeZone = "America/Chicago"; + networking.domain = "thehellings.lan"; + }; +} diff --git a/modules/linode.nix b/modules/linode.nix new file mode 100644 index 0000000..dd5bdb4 --- /dev/null +++ b/modules/linode.nix @@ -0,0 +1,44 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.greg.linode; + +in with lib; +{ + options.greg.linode = { + enable = mkEnableOption "Set sensible defaults for a Linode host"; + + bootTimeout = mkOption { + type = types.int; + default = 15; + description = "Set bootloader timeout in seconds."; + }; + }; + + config = mkIf cfg.enable { + # Enables connection over Linode consoles + boot.kernelParams = [ "console=ttyS0,19200n8" ]; + boot.loader.grub = { + device = "nodev"; + extraConfig = '' +serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1; +terminal_input serial; +terminal_output serial; +''; + }; + + # Tells grub to ignore partion-free device warnings, since we are on Linode + boot.loader.timeout = 15; + + networking.usePredictableInterfaceNames = false; # Use old style eth0 names + networking.useDHCP = false; + networking.interfaces.eth0.useDHCP = true; + + # Suggested diagnostic tools + environment.systemPackages = with pkgs; [ + inetutils + mtr + sysstat + ]; + }; +} diff --git a/modules/rpi4.nix b/modules/rpi4.nix new file mode 100644 index 0000000..fd77bb8 --- /dev/null +++ b/modules/rpi4.nix @@ -0,0 +1,43 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.greg.rpi4; + +in with lib; { + options = { + greg.rpi4 = { + enable = mkEnableOption "Enable support for Raspberry Pi 4s"; + }; + }; + + config = mkIf cfg.enable { + boot = { + # This prevents us from having to compile our own kernel + kernelPackages = pkgs.linuxPackages_rpi4; + kernelParams = [ + "8250.nr_uarts=1" + "console=ttyAMA0,115200" + "console=tty1" + "cma=128M" + ]; + + loader = { + raspberryPi = { + enable = true; + version = 4; + }; + + # Use the extlinux boot loader. (NixOS wants to enable GRUB by default) + grub.enable = false; + + # Enables the generation of /boot/extlinux/extlinux.conf + #generic-extlinux-compatible.enable = true; + }; + }; + + environment.systemPackages = with pkgs; [ + raspberrypifw + usbutils + ]; + }; +} diff --git a/profiles/home.nix b/profiles/home.nix deleted file mode 100644 index 86bf6d3..0000000 --- a/profiles/home.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ config, ... }: - -{ - time.timeZone = "America/Chicago"; - networking.domain = "thehellings.lan"; -} diff --git a/profiles/linode.nix b/profiles/linode.nix deleted file mode 100644 index 4681d96..0000000 --- a/profiles/linode.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ pkgs, ... }: - -{ - # Enables connection over Linode consoles - boot.kernelParams = [ "console=ttyS0,19200n8" ]; - boot.loader.grub = { - device = "nodev"; - extraConfig = '' -serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1; -terminal_input serial; -terminal_output serial; -''; - }; - - # Tells grub to ignore partion-free device warnings, since we are on Linode - boot.loader.timeout = 15; - - networking.usePredictableInterfaceNames = false; # Use old style eth0 names - networking.useDHCP = false; - networking.interfaces.eth0.useDHCP = true; - - # Suggested diagnostic tools - environment.systemPackages = with pkgs; [ - inetutils - mtr - sysstat - ]; -} diff --git a/profiles/rpi4.nix b/profiles/rpi4.nix deleted file mode 100755 index e3e97dc..0000000 --- a/profiles/rpi4.nix +++ /dev/null @@ -1,33 +0,0 @@ -# Base configurations for Raspberry Pi 4s -{ config, pkgs, ... }: - -{ - boot = { - # This prevents us from having to compile our own kernel - kernelPackages = pkgs.linuxPackages_rpi4; - kernelParams = [ - "8250.nr_uarts=1" - "console=ttyAMA0,115200" - "console=tty1" - "cma=128M" - ]; - - loader = { - raspberryPi = { - enable = true; - version = 4; - }; - - # Use the extlinux boot loader. (NixOS wants to enable GRUB by default) - grub.enable = false; - - # Enables the generation of /boot/extlinux/extlinux.conf - #generic-extlinux-compatible.enable = true; - }; - }; - - environment.systemPackages = with pkgs; [ - raspberrypifw - usbutils - ]; -}