From ccb78369834d6622f5b4fc3c79ed1f203b589e74 Mon Sep 17 00:00:00 2001 From: NullBite Date: Wed, 27 Dec 2023 02:37:46 -0500 Subject: [PATCH] Add initial flake holy shit nixos is magic :3 --- flake.nix | 20 ++++++++ hardware-configuration.nix | 62 +++++++++++++++++++++++++ host-configuration.nix | 95 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 flake.nix create mode 100644 hardware-configuration.nix create mode 100644 host-configuration.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1bf3d9b --- /dev/null +++ b/flake.nix @@ -0,0 +1,20 @@ +{ + description = "NixOS Configuration"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + # ^^^^^^^^^^^^^ this part is optional + }; + + outputs = { self, nixpkgs }: + let + lib = nixpkgs.lib; + in { + nixosConfigurations = { + slab = lib.nixosSystem { + system = "x86_64-linux"; + modules = [ ./configuration.nix ]; + }; + }; + }; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..1f2ed37 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,62 @@ +# 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" "usbhid" "sdhci_pci" ]; + boot.initrd.kernelModules = [ "dm-snapshot" "amdgpu" ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/5723dafa-81df-4bb4-a039-7f52b61cbb02"; + fsType = "btrfs"; + options = [ "subvol=nixos/@root" ]; + }; + + # fileSystems."/boot" = + # { device = "/dev/disk/by-uuid/b9813c1d-5b6c-4026-9ee3-53ba80b90dc4"; + # fsType = "ext4"; + # }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/4E1B-8BEE"; + fsType = "vfat"; + }; + + fileSystems."/.btrfsroot" = + { device = "/dev/disk/by-uuid/5723dafa-81df-4bb4-a039-7f52b61cbb02"; + fsType = "btrfs"; + options = [ "subvol=/" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/5723dafa-81df-4bb4-a039-7f52b61cbb02"; + fsType = "btrfs"; + options = [ "subvol=@home" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/9360890a-4050-4326-bf5f-8fa2bdc6744a"; } + ]; + + # 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.br-6b5c424872ae.useDHCP = lib.mkDefault true; + # networking.interfaces.docker0.useDHCP = lib.mkDefault true; + # networking.interfaces.enp3s0.useDHCP = lib.mkDefault true; + # networking.interfaces.tailscale0.useDHCP = lib.mkDefault true; + # networking.interfaces.virbr0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp4s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/host-configuration.nix b/host-configuration.nix new file mode 100644 index 0000000..302aff3 --- /dev/null +++ b/host-configuration.nix @@ -0,0 +1,95 @@ +# vim: set ts=2 sw=2 et: +{ config, lib, pkgs, modulesPath, ... }: + +{ + networking.hostName = "slab"; + + # cryptsetup + boot.initrd.luks.devices = { + lvmroot = { + device="/dev/disk/by-uuid/2872c0f0-e544-45f0-9b6c-ea022af7805a"; + allowDiscards = true; + fallbackToPassword = true; + preLVM = true; + }; + }; + + # bootloader setup + boot.loader = { + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + # grub = { + # enable = true; + # efiSupport = true; + # device = "nodev"; + # }; + systemd-boot = { + enable = true; + netbootxyz.enable = true; + memtest86.enable = true; + }; + }; + + services.supergfxd.enable = true; + + # Enable OpenGL + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + # Load nvidia driver for Xorg and Wayland + services.xserver.videoDrivers = ["amdgpu" "nvidia"]; + + hardware.nvidia = { + + # Modesetting is required. + modesetting.enable = false; + + # Nvidia power management. Experimental, and can cause sleep/suspend to fail. + powerManagement.enable = false; + # Fine-grained power management. Turns off GPU when not in use. + # Experimental and only works on modern Nvidia GPUs (Turing or newer). + powerManagement.finegrained = false; + + # Use the NVidia open source kernel module (not to be confused with the + # independent third-party "nouveau" open source driver). + # Support is limited to the Turing and later architectures. Full list of + # supported GPUs is at: + # https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus + # Only available from driver 515.43.04+ + # Currently alpha-quality/buggy, so false is currently the recommended setting. + open = false; + + # Enable the Nvidia settings menu, + # accessible via `nvidia-settings`. + nvidiaSettings = true; + + # Optionally, you may need to select the appropriate driver version for your specific GPU. + package = config.boot.kernelPackages.nvidiaPackages.stable; + + prime = { + offload = { + enable = true; + enableOffloadCmd = true; + }; + amdgpuBusId = "PCI:07:00:0"; + nvidiaBusId = "PCI:01:00:0"; + }; + }; + + services.syncthing = { + enable = true; + user = "nullbite"; + dataDir = "/home/nullbite/Documents"; + configDir = "/home/nullbite/.config/syncthing"; + }; + + hardware.bluetooth = { + enable = true; + powerOnBoot = true; + }; +}