From b9cbddf44c93bf707d018d351eb86398729ebf85 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Sun, 18 Feb 2024 15:07:48 -0600 Subject: [PATCH] initial nas config --- configuration-nas.nix | 215 ++++++++++++++++++++++++++++++++++++++++++ flake.lock | 16 ++++ flake.nix | 9 +- impermanence.nix | 21 +++++ 4 files changed, 256 insertions(+), 5 deletions(-) create mode 100644 configuration-nas.nix create mode 100644 impermanence.nix diff --git a/configuration-nas.nix b/configuration-nas.nix new file mode 100644 index 0000000..89d676d --- /dev/null +++ b/configuration-nas.nix @@ -0,0 +1,215 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: +let + user = "admin"; + password = "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06"; + hostname = "jallen-nas"; + timezone = "America/Chicago"; +in +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration-nas.nix + ]; + + # Enable nix flakes and nix-command tools + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Configure bootloader with lanzaboot and secureboot + boot = { + loader = { + systemd-boot = { + enable = true; + configurationLimit = 2; + }; + + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + }; + + # Override kernel to latest + kernelPackages = pkgs.linuxPackages_latest; + + kernelParams = [ + # none for now + ]; + + consoleLogLevel = 3; + bootspec.enable = true; + }; + + # Hardware configs + hardware = { + # Bluetooth + bluetooth.enable = true; + + # Enable all firmware + enableAllFirmware = true; + + # Disable pulse audio in favor of pipewire + pulseaudio.enable = false; + + # Nvidia + nvidia = { + package = config.boot.kernelPackages.nvidiaPackages.beta; + + # Modesetting is required. + modesetting.enable = true; + + # Nvidia power management. Experimental, and can cause sleep/suspend to fail. + powerManagement.enable = true; + + # Fine-grained power management. Turns off GPU when not in use. + # Experimental and only works on modern Nvidia GPUs (Turing or newer). + powerManagement.finegrained = true; + + # 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; + }; + + # Enable OpenGL + opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + }; + + # Services configs + services = { + # Enable firmware updates + fwupd.enable = true; + + # Enable the X11 windowing system. + xserver = { + enable = true; + + # Load nvidia driver for Xorg and Wayland + videoDrivers = ["nvidia"]; + + # Enable the Plasma 6 Desktop Environment. + displayManager = { + sddm.enable = true; + defaultSession = "plasma"; + }; + desktopManager.plasma6.enable = true; + }; + + # Enable CUPS to print documents. + printing.enable = true; + + # configure pipewire + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + # enable auto discovery of printers + avahi = { + enable = true; + nssmdns4 = true; + openFirewall = true; + }; + + # Enable Flatpak + flatpak.enable = false; + }; + + # Networking configs + networking = { + hostName = hostname; + + # Enable Network Manager + networkmanager.enable = true; + }; + + # Time config + time = { + # Set your time zone. + timeZone = timezone; + }; + + # Configure environment + environment = { + # List packages installed in system profile. To search, run: + # $ nix search wget + systemPackages = with pkgs; [ + vim + wget + nano + efibootmgr + sbctl + pciutils + vulkan-tools + clinfo + ]; + }; + + # Configure programs + programs = { + fish.enable = true; + }; + + # Configure nixpkgs + nixpkgs = { + config = { + # Enable non free + allowUnfree = true; + }; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users."${user}" = { + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user. + shell = pkgs.fish; + packages = with pkgs; [ + neofetch + git + parted + aspell + aspellDicts.en + aspellDicts.en-computers + aspellDicts.en-science + aha + papirus-icon-theme + ]; + }; + + # 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? + +} + diff --git a/flake.lock b/flake.lock index a83ee2d..81443df 100644 --- a/flake.lock +++ b/flake.lock @@ -186,6 +186,21 @@ "type": "github" } }, + "impermanence": { + "locked": { + "lastModified": 1706639736, + "narHash": "sha256-CaG4j9+UwBDfinxxvJMo6yOonSmSo0ZgnbD7aj2Put0=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "cd13c2917eaa68e4c49fea0ff9cada45440d7045", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, "kde": { "inputs": { "flake-utils": "flake-utils", @@ -390,6 +405,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "impermanence": "impermanence", "kde": "kde", "lanzaboote": "lanzaboote", "nix-flatpak": "nix-flatpak", diff --git a/flake.nix b/flake.nix index 5ab77b9..73b7dc8 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ # Desktop kde.url = "github:nix-community/kde2nix"; nix-flatpak.url = "github:gmodena/nix-flatpak"; -# impermanence.url = "github:nix-community/impermanence"; + impermanence.url = "github:nix-community/impermanence"; home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; lanzaboote = { @@ -20,19 +20,18 @@ nixos-hardware.url = "github:NixOS/nixos-hardware/master"; }; -# outputs = { self, nixpkgs, impermanence, lanzaboote } @ inputs: { - outputs = { self, nixpkgs, lanzaboote, kde, nix-flatpak, home-manager, nixos-hardware } @ inputs: { + outputs = { self, nixpkgs, lanzaboote, impermanence, kde, nix-flatpak, home-manager, nixos-hardware } @ inputs: { nixosConfigurations = { # Desktop "matt-nixos" = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ -# impermanence.nixosModules.impermanence + impermanence.nixosModules.impermanence lanzaboote.nixosModules.lanzaboote kde.nixosModules.plasma6 nix-flatpak.nixosModules.nix-flatpak ./configuration.nix - # ./impermanence.nix + ./impermanence.nix home-manager.nixosModules.home-manager { home-manager.useGlobalPkgs = true; diff --git a/impermanence.nix b/impermanence.nix new file mode 100644 index 0000000..5083590 --- /dev/null +++ b/impermanence.nix @@ -0,0 +1,21 @@ +{ pkgs, lib, LT, config, utils, inputs, ... }@args: + +{ +# Set up impernance configuration for things like bluetooth +# In this configuration with /etc and /var/log being persistent, only directories outside of that need to be done here. See hardware configuration for all mountpoints. + + environment.persistence."/nix/persist/system" = { + hideMounts = true; + directories = [ + "/var/lib/bluetooth" + "/var/lib/nixos" + "/var/lib/systemd/coredump" + "/etc/NetworkManager/system-connections" + "/etc/secureboot" + { directory = "/var/lib/colord"; user = "colord"; group = "colord"; mode = "u=rwx,g=rx,o="; } + ]; + files = [ + { file = "/etc/nix/id_rsa"; parentDirectory = { mode = "u=rwx,g=,o="; }; } + ]; + }; +} \ No newline at end of file