new system config i001

This commit is contained in:
RingOfStorms (Joshua Bell) 2025-12-07 18:17:19 -06:00
parent a211913169
commit ae6a2d9cd5
10 changed files with 1454 additions and 0 deletions

View file

@ -0,0 +1,120 @@
# 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, ... }:
let
NIXBOOT = "/dev/disk/by-uuid/641A-6BDB";
NIXROOT ="/dev/disk/by-uuid/ae94db42-ec46-4e2f-a98a-118359428a68";
cryptroot = "/dev/disk/by-uuid/49f11bf1-d4b7-4188-9203-4d7a42569afa";
USB_KEY = "/dev/disk/by-uuid/9985-EBD1";
in
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" "sdhci_pci" "ehci_pci" "uas" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/boot" =
{ device = NIXBOOT;
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};
boot.initrd.luks.devices."cryptroot" = {
device = NIXROOT;
# Auto decrypt
keyFile = USB_KEY;
keyFileSize = 5000;
keyFileOffset = 5443;
tryEmptyPassphrase = true;
fallbackToPassword = true;
crypttabExtraOpts = [ "tries=2" ];
};
fileSystems."/" =
{ device = cryptroot;
fsType = "btrfs";
options = [ "subvol=@root" "compress=zstd" ];
};
fileSystems."/nix" =
{ device = cryptroot;
fsType = "btrfs";
options = [ "subvol=@nix" "compress=zstd" "noatime" ];
};
fileSystems."/persist" =
{ device = cryptroot;
neededForBoot = true;
fsType = "btrfs";
options = [ "subvol=@persist" "compress=zstd" ];
};
fileSystems."/.swap" =
{ device = cryptroot;
fsType = "btrfs";
options = [ "subvol=@swap" "noatime" ];
};
fileSystems."/.snapshots" =
{ device = cryptroot;
fsType = "btrfs";
options = [ "subvol=@snapshots" "compress=zstd" "noatime"];
};
services.btrfs.autoScrub = {
enable = true;
# syntax as defined by https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Event s
interval = "monthly";
fileSystems = ["/"];
};
swapDevices = [{
device = "/.swap/swapfile";
size = 8*1024; # Creates an 8GB swap file
}];
boot.initrd.postResumeCommands = lib.mkAfter ''
mkdir /btrfs_tmp
mount ${cryptroot} /btrfs_tmp
if [[ -e /btrfs_tmp/@root ]]; then
mkdir -p /btrfs_tmp/old_roots
timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/@root)" "+%Y-%m-%-d_%H:%M:%S")
mv /btrfs_tmp/@root "/btrfs_tmp/old_roots/$timestamp"
fi
delete_subvolume_recursively() {
IFS=$'\n'
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
delete_subvolume_recursively "/btrfs_tmp/$i"
done
btrfs subvolume delete "$1"
}
for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do
delete_subvolume_recursively "$i"
done
btrfs subvolume create /btrfs_tmp/@root
umount /btrfs_tmp
'';
# 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.enp1s0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp3s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}