From bb61531df1d3fb1f257c51543b83d31d1d912695 Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Thu, 11 Jan 2024 01:13:42 +0100 Subject: [PATCH] WIP framenix --- common/default.nix | 2 +- hosts/framenix/default.nix | 36 +++++++++++++++++++ hosts/framenix/hardware-configuration.nix | 26 ++++++++++++++ hosts/framenix/storage.nix | 44 +++++++++++++++++++++++ hosts/framenix/swap.nix | 12 +++++++ 5 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 hosts/framenix/default.nix create mode 100644 hosts/framenix/hardware-configuration.nix create mode 100644 hosts/framenix/storage.nix create mode 100644 hosts/framenix/swap.nix diff --git a/common/default.nix b/common/default.nix index 2fdf524..31c6593 100644 --- a/common/default.nix +++ b/common/default.nix @@ -48,7 +48,7 @@ in programs.adb.enable = true; - # programs.mtr.enable = true; + programs.mtr.enable = true; # programs.gnupg.agent = { enable = true; enableSSHSupport = true; }; # List services that you want to enable: diff --git a/hosts/framenix/default.nix b/hosts/framenix/default.nix new file mode 100644 index 0000000..bde4c32 --- /dev/null +++ b/hosts/framenix/default.nix @@ -0,0 +1,36 @@ +{ config, lib, pkgs, inputs, ...}: +{ + imports = [ + ../../common + + ./hardware-configuration.nix + ./storage.nix + ./swap.nix + ]; + + networking.hostName = "framenix"; # Define your hostname. + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # This option defines the first version of NixOS you have installed on this particular machine, + # and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions. + # + # Most users should NEVER change this value after the initial install, for any reason, + # even if you've upgraded your system to a new NixOS release. + # + # This value does NOT affect the Nixpkgs version your packages and OS are pulled from, + # so changing it will NOT upgrade your system. + # + # This value being lower than the current NixOS release does NOT mean your system is + # out of date, out of support, or vulnerable. + # + # Do NOT change this value unless you have manually inspected all the changes it would make to your configuration, + # and migrated your data accordingly. + # + # For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion . + system.stateVersion = "23.11"; # Did you read the comment? + + hardware.enableRedistributableFirmware = true; +} + diff --git a/hosts/framenix/hardware-configuration.nix b/hosts/framenix/hardware-configuration.nix new file mode 100644 index 0000000..a731402 --- /dev/null +++ b/hosts/framenix/hardware-configuration.nix @@ -0,0 +1,26 @@ +# 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") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + + # 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.enp193s0f3u1c2.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp1s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/framenix/storage.nix b/hosts/framenix/storage.nix new file mode 100644 index 0000000..3efa655 --- /dev/null +++ b/hosts/framenix/storage.nix @@ -0,0 +1,44 @@ +{ config, lib, pkgs, ... }: +let + fsOptions = [ "noatime" "ssd" "compress=zstd" ]; +in +{ + boot.initrd.luks = { + devices = + # allow discards on all devices + builtins.mapAttrs (name: val: val // {allowDiscards = true;}) + { + "system".device = "/dev/disk/by-uuid/1838cdc5-9b0b-4c46-9f23-9465549eeb92"; + "cryptswap".device = "/dev/disk/by-uuid/ded7d649-ab3a-42ee-ae4a-f8c4ba029e9c"; + }; + reusePassphrases = true; + }; + + fileSystems = { + "/" = { + device = "/dev/disk/by-uuid/22388786-4285-403b-9994-e9aae1f11172"; + fsType = "btrfs"; + options = fsOptions ++ [ "subvol=nixos_root" ]; + }; + + "/home" = { + device = "/dev/disk/by-uuid/22388786-4285-403b-9994-e9aae1f11172"; + fsType = "btrfs"; + options = fsOptions ++ [ "subvol=home" ]; + }; + + "/boot" = { + device = "/dev/disk/by-uuid/AF8E-E9E6"; + fsType = "vfat"; + options = [ "discard" ]; + }; + }; + + services.fstrim.enable = true; + services.btrfs.autoScrub = { + enable = true; + fileSystems = [ "/" "/home" ]; + }; + + boot.tmp.useTmpfs = true; +} diff --git a/hosts/framenix/swap.nix b/hosts/framenix/swap.nix new file mode 100644 index 0000000..262809c --- /dev/null +++ b/hosts/framenix/swap.nix @@ -0,0 +1,12 @@ +{ + swapDevices = + [ { device = "/dev/disk/by-uuid/24c47f3d-0d3e-4575-92a2-174b5a6b6086"; } + ]; + + zramSwap = { + enable = true; + memoryPercent = 20; + }; + + boot.kernel.sysctl."vm.swappiness" = 9; +}