diff --git a/flake.lock b/flake.lock index 4d61306..15c333f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,25 @@ { "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1766150702, + "narHash": "sha256-P0kM+5o+DKnB6raXgFEk3azw8Wqg5FL6wyl9jD+G5a4=", + "owner": "nix-community", + "repo": "disko", + "rev": "916506443ecd0d0b4a0f4cf9d40a3c22ce39b378", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "hardware": { "locked": { "lastModified": 1767070591, @@ -92,6 +112,7 @@ }, "root": { "inputs": { + "disko": "disko", "hardware": "hardware", "home-manager": "home-manager", "impermanence": "impermanence", diff --git a/flake.nix b/flake.nix index 85efaee..f818c42 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,11 @@ inputs.home-manager.follows = "home-manager"; }; + disko = { + url = "github:nix-community/disko"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + sops-nix = { url = "github:mic92/sops-nix"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/hosts/common/optional/ephemeral-btrfs.nix b/hosts/common/optional/ephemeral-btrfs.nix new file mode 100644 index 0000000..0395aaf --- /dev/null +++ b/hosts/common/optional/ephemeral-btrfs.nix @@ -0,0 +1,5 @@ +{ + +}: { + +} diff --git a/hosts/orpheus/hardware-configuration.nix b/hosts/orpheus/hardware-configuration.nix index a8717a4..c29aafa 100644 --- a/hosts/orpheus/hardware-configuration.nix +++ b/hosts/orpheus/hardware-configuration.nix @@ -1,44 +1,93 @@ -# 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 + "/installer/scan/not-detected.nix") - ]; +{inputs, ... }: { + imports = [ + inputs.disko.nixosModules.disko + ../common/optional/ephermal-btrfs.nix + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-amd" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = - { device = "/dev/disk/by-uuid/cdcfbbfa-ae65-48ff-acfd-1ceba3376f2f"; - fsType = "ext4"; + boot = { + initrd = { + availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usb_storage" + "usbhid" + "sd_mod" + ]; + kernelModules = ["kvm-amd"]; }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/7C92-2CC6"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; + loader = { + systemd-boot = { + enable = true; + consoleMode = "max"; + }; + efi.canTouchEfiVariables = true; }; + }; - swapDevices = - [ { device = "/dev/disk/by-uuid/f8b826c3-629d-4e11-a902-d076d16be33b"; } - ]; - - # 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.enp3s0.useDHCP = lib.mkDefault true; - # networking.interfaces.enp4s0.useDHCP = lib.mkDefault true; - # networking.interfaces.enp5s0f0np0.useDHCP = lib.mkDefault true; - # networking.interfaces.enp5s0f1np1.useDHCP = lib.mkDefault true; - # networking.interfaces.wlp6s0.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; + disko.devices.disk.main = { + device = "/dev/nvme0n1"; + type = "disk"; + content = { + type = "gpt"; + partions = { + boot = { + size = "1M"; + type = "EF02"; + }; + esp = { + name = "ESP"; + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + luks = { + size = "100%"; + content = { + name = "root"; + type = "luks"; + settings.allowDiscards = true; + content = { + type = "btrfs"; + postCreateHook = '' + MNTPOINT=$(mktemp -d) + mount -t btrfs "$device" "$MNTPOINT" + trap 'umount $MNTPOINT; rm -d $MNTPOINT' EXIT + btrfs subvolume snapshot -r $MNTPOINT/root $MNTPOINT/root-blank + ''; + subvolumes = { + "/root" = { + mountOptions = ["compress=zstd"]; + mountpoint = "/"; + }; + "/nix" = { + mountOptions = ["compress=zstd" "noatime"]; + mountpoint = "/nix"; + }; + "/persist" = { + mountOptions = ["compress=zstd"]; + mountpoint = "/persist"; + }; + "/swap" = { + mountOptions = ["compress=zstd" "noatime"]; + mountpoint = "/swap"; + swap.swapfile = { + size = "60G"; + path = "swapfile"; + }; + }; + }; + }; + }; + }; + }; + }; + }; } + +