From 02b736cc0c2b048ee3a9f6959e76952e80d76fe5 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 25 Jan 2025 13:53:42 +0000 Subject: [PATCH] add cloudnix config --- flake.nix | 11 +++++ hosts/cloudnix/default.nix | 57 +++++++++++++++++++++++ hosts/cloudnix/hardware-configuration.nix | 41 ++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 hosts/cloudnix/default.nix create mode 100644 hosts/cloudnix/hardware-configuration.nix diff --git a/flake.nix b/flake.nix index 7d0b500..0e697b8 100644 --- a/flake.nix +++ b/flake.nix @@ -130,6 +130,17 @@ modules = [ ./hosts/citadel + home-manager.nixosModules.home-manager + { + home-manager.extraSpecialArgs = specialArgs; + } + ]; + }; + cloudnix = nixpkgs.lib.nixosSystem { + inherit specialArgs; + modules = [ + ./hosts/cloudnix + home-manager.nixosModules.home-manager { home-manager.extraSpecialArgs = specialArgs; diff --git a/hosts/cloudnix/default.nix b/hosts/cloudnix/default.nix new file mode 100644 index 0000000..0100eae --- /dev/null +++ b/hosts/cloudnix/default.nix @@ -0,0 +1,57 @@ +{ + configVars, + outputs, + ... +}: let + user = "admin"; + merlinIp = configVars.networking.addresses.merlin.ip; +in { + imports = [ + # Create users for this host + ../common/users/${user} + + # Import core options + ./hardware-configuration.nix + ../common/core + + # Import optional options + ../common/optional/persistence.nix + ../common/optional/openssh.nix + + ../common/optional/distributed-builds/local-machine.nix + + outputs.nixosModules.nixosAutoUpgrade + ]; + + boot = { + loader = { + grub.enable = true; + }; + }; + + services = { + earlyoom = { + enable = true; + freeMemThreshold = 5; # <%5 free + }; + }; + + system.services.nixosAutoUpgrade = { + enable = true; + persistent = true; + remote = "remotebuild@${merlinIp}"; + reboot = false; + pushUpdates = false; + configDir = "/etc/nixos"; + onCalendar = "*-*-* 06:00:00"; + user = "sam"; + }; + + networking = { + hostName = "cloudnix"; + nameservers = ["8.8.8.8"]; + firewall.enable = true; + }; + + services.libinput.enable = true; +} diff --git a/hosts/cloudnix/hardware-configuration.nix b/hosts/cloudnix/hardware-configuration.nix new file mode 100644 index 0000000..ab544bc --- /dev/null +++ b/hosts/cloudnix/hardware-configuration.nix @@ -0,0 +1,41 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/e12d0dfd-9753-44d4-b65f-dc5549db3edf"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/c29f698d-eb89-4618-be8b-046b4907aed8"; + fsType = "ext4"; + }; + + swapDevices = [ + { + device = "/.swapfile"; + size = 2 * 1024; + } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +}