diff options
Diffstat (limited to 'hosts/snorlax')
-rw-r--r-- | hosts/snorlax/configuration.nix | 9 | ||||
-rw-r--r-- | hosts/snorlax/disk-config.nix | 80 | ||||
-rw-r--r-- | hosts/snorlax/flake.nix | 44 | ||||
-rw-r--r-- | hosts/snorlax/hardware-configuration.nix | 32 |
4 files changed, 165 insertions, 0 deletions
diff --git a/hosts/snorlax/configuration.nix b/hosts/snorlax/configuration.nix new file mode 100644 index 0000000..c130114 --- /dev/null +++ b/hosts/snorlax/configuration.nix @@ -0,0 +1,9 @@ +{ ... }: +{ + imports = [ + ./hardware-configuration.nix + ../../roles/server.nix + ]; + + system.stateVersion = "24.05"; +} diff --git a/hosts/snorlax/disk-config.nix b/hosts/snorlax/disk-config.nix new file mode 100644 index 0000000..9087825 --- /dev/null +++ b/hosts/snorlax/disk-config.nix @@ -0,0 +1,80 @@ +# USAGE in your configuration.nix. +# Update devices to match your hardware. +# { +# imports = [ ./disko-config.nix ]; +# disko.devices.disk.main.device = "/dev/sda"; +# } +{ + disko.devices = { + disk = { + main = { + type = "disk"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "1G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + zfs = { + size = "100%"; + content = { + type = "zfs"; + pool = "zroot"; + }; + }; + }; + }; + }; + }; + zpool = { + zroot = { + type = "zpool"; + rootFsOptions = { + # https://wiki.archlinux.org/title/Install_Arch_Linux_on_ZFS + acltype = "posixacl"; + atime = "off"; + compression = "zstd"; + mountpoint = "none"; + xattr = "sa"; + }; + options.ashift = "12"; + + datasets = { + "local" = { + type = "zfs_fs"; + options.mountpoint = "none"; + }; + "local/home" = { + type = "zfs_fs"; + mountpoint = "/home"; + # Used by services.zfs.autoSnapshot options. + options."com.sun:auto-snapshot" = "true"; + }; + "local/nix" = { + type = "zfs_fs"; + mountpoint = "/nix"; + options."com.sun:auto-snapshot" = "false"; + }; + "local/persist" = { + type = "zfs_fs"; + mountpoint = "/persist"; + options."com.sun:auto-snapshot" = "false"; + }; + "local/root" = { + type = "zfs_fs"; + mountpoint = "/"; + options."com.sun:auto-snapshot" = "false"; + postCreateHook = "zfs list -t snapshot -H -o name | grep -E '^zroot/local/root@blank$' || zfs snapshot zroot/local/root@blank"; + }; + }; + }; + }; + }; +} diff --git a/hosts/snorlax/flake.nix b/hosts/snorlax/flake.nix new file mode 100644 index 0000000..49f2c4f --- /dev/null +++ b/hosts/snorlax/flake.nix @@ -0,0 +1,44 @@ +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.disko.url = "github:nix-community/disko"; + inputs.disko.inputs.nixpkgs.follows = "nixpkgs"; + inputs.nixos-facter-modules.url = "github:numtide/nixos-facter-modules"; + + outputs = + { + nixpkgs, + disko, + nixos-facter-modules, + ... + }: + { + # Use this for all other targets + # nixos-anywhere --flake .#generic-nixos-facter --generate-hardware-config nixos-generate-config ./hardware-configuration.nix <hostname> + nixosConfigurations.generic = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + disko.nixosModules.disko + ./configuration.nix + ./hardware-configuration.nix + ]; + }; + + # Slightly experimental: Like generic, but with nixos-facter (https://github.com/numtide/nixos-facter) + # nixos-anywhere --flake .#generic-nixos-facter --generate-hardware-config nixos-facter facter.json <hostname> + nixosConfigurations.generic-nixos-facter = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + disko.nixosModules.disko + ./configuration.nix + nixos-facter-modules.nixosModules.facter + { + config.facter.reportPath = + if builtins.pathExists ./facter.json then + ./facter.json + else + throw "Have you forgotten to run nixos-anywhere with `--generate-hardware-config nixos-facter ./facter.json`?"; + } + ]; + }; + }; +} diff --git a/hosts/snorlax/hardware-configuration.nix b/hosts/snorlax/hardware-configuration.nix new file mode 100644 index 0000000..77df044 --- /dev/null +++ b/hosts/snorlax/hardware-configuration.nix @@ -0,0 +1,32 @@ +# 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, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "uas" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/f8724a86-f440-49a2-a6df-8183b451449c"; + fsType = "ext4"; + }; + + swapDevices = [ ]; + + # 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.<interface>.useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.eno1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} |