From 2f3ed7e377b714f36e4a250befaac83782f3ae47 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 1 Apr 2025 02:11:38 +0200 Subject: [PATCH] ljdsalkjdaslkj --- hosts/nixos/bjarte/configuration.nix | 2 +- hosts/nixos/nord/configuration.nix | 9 +++++++-- hosts/nixos/nord/hardware-configuration.nix | 7 ++++--- hosts/nixos/sopp/configuration.nix | 11 ++++++++--- hosts/nixos/sopp/hardware-configuration.nix | 7 ++++--- lib.nix | 18 ++++++++++++++---- 6 files changed, 38 insertions(+), 16 deletions(-) diff --git a/hosts/nixos/bjarte/configuration.nix b/hosts/nixos/bjarte/configuration.nix index ace8b44..b0227fb 100644 --- a/hosts/nixos/bjarte/configuration.nix +++ b/hosts/nixos/bjarte/configuration.nix @@ -5,8 +5,8 @@ boot.loader.efi.canTouchEfiVariables = true; #boot.kernel.sysctl."vm.swappiness" = lib.mkDefault 10; # 0-100, commonly 60 - zramSwap.enable = true; + # swapDevices = lib.mkForce []; # for testing only, not for building boot.binfmt.addEmulatedSystemsToNixSandbox = false; diff --git a/hosts/nixos/nord/configuration.nix b/hosts/nixos/nord/configuration.nix index eb39829..14b727a 100644 --- a/hosts/nixos/nord/configuration.nix +++ b/hosts/nixos/nord/configuration.nix @@ -5,14 +5,19 @@ boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.efiSysMountPoint = "/boot/efi"; + #boot.kernel.sysctl."vm.swappiness" = lib.mkDefault 10; # 0-100, commonly 60 + zramSwap.enable = true; + swapDevices = lib.mkForce []; + + # amdgpu audio fix when at 4k@60fps + boot.kernelPackages = pkgs.linuxPackages_latest; + services.displayManager.autoLogin.enable = true; services.displayManager.autoLogin.user = "pbsds"; # tmp: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229 systemd.services."getty@tty1".enable = false; systemd.services."autovt@tty1".enable = false; - boot.kernelPackages = pkgs.linuxPackages_latest; # amdgpu audio fix when at 4k@60fps - imports = [ ./hardware-configuration.nix ../../../profiles/sshd diff --git a/hosts/nixos/nord/hardware-configuration.nix b/hosts/nixos/nord/hardware-configuration.nix index 5cdbe56..ed0e102 100644 --- a/hosts/nixos/nord/hardware-configuration.nix +++ b/hosts/nixos/nord/hardware-configuration.nix @@ -23,9 +23,10 @@ fsType = "vfat"; }; - swapDevices = - [ { device = "/dev/disk/by-uuid/cd7b72b7-738a-4399-a887-ad69f6aa6ec9"; } - ]; + swapDevices = [{ + device = "/dev/disk/by-uuid/cd7b72b7-738a-4399-a887-ad69f6aa6ec9"; + # randomEncryption.enable = true; + }]; # 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 diff --git a/hosts/nixos/sopp/configuration.nix b/hosts/nixos/sopp/configuration.nix index 390c997..0583442 100644 --- a/hosts/nixos/sopp/configuration.nix +++ b/hosts/nixos/sopp/configuration.nix @@ -5,6 +5,14 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + # add driver to stage-1 to make the usb dock not prevent boot + # https://github.com/NixOS/nixpkgs/issues/171625#issuecomment-2068283656 + boot.kernelModules = [ "xhci_pci" ]; + + #boot.kernel.sysctl."vm.swappiness" = lib.mkDefault 10; # 0-100, commonly 60 + zramSwap.enable = true; + swapDevices = lib.mkForce []; + # for testing only, not for building boot.binfmt.addEmulatedSystemsToNixSandbox = false; boot.binfmt.emulatedSystems = [ @@ -15,9 +23,6 @@ #nix.settings.system = "x86_64-linux"; #nix.settings.extra-platforms = [ "i686-linux" ]; - boot.kernel.sysctl."vm.swappiness" = lib.mkDefault 10; # 0-100, commonly 60 - boot.kernelModules = [ "xhci_pci" ]; # add driver to stage-1 to make the usb dock not prevent boot - https://github.com/NixOS/nixpkgs/issues/171625#issuecomment-2068283656 - services.displayManager.autoLogin.enable = true; services.displayManager.autoLogin.user = "pbsds"; # tmp: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229 diff --git a/hosts/nixos/sopp/hardware-configuration.nix b/hosts/nixos/sopp/hardware-configuration.nix index 3f24246..e8cf53a 100644 --- a/hosts/nixos/sopp/hardware-configuration.nix +++ b/hosts/nixos/sopp/hardware-configuration.nix @@ -23,9 +23,10 @@ fsType = "vfat"; }; - swapDevices = - [ { device = "/dev/disk/by-uuid/e9b56879-e406-44c7-ab60-fcd374fdf0ea"; } - ]; + swapDevices = [{ + device = "/dev/disk/by-uuid/e9b56879-e406-44c7-ab60-fcd374fdf0ea"; + # randomEncryption.enable = true; + }]; # 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 diff --git a/lib.nix b/lib.nix index 56961b5..3755138 100644 --- a/lib.nix +++ b/lib.nix @@ -65,10 +65,20 @@ let "container" else null; - mounts = lib.pipe cfg.fileSystems [ - (lib.filterAttrs (mount: fs: fs.fsType != "nfs")) # spammy - (lib.mapAttrs (mount: fs: "${fs.fsType}://${fs.device}")) - ]; + mounts = + lib.pipe cfg.fileSystems [ + (lib.filterAttrs (mount: fs: fs.fsType != "nfs")) # spammy + (lib.mapAttrs (mount: fs: "${fs.fsType}://${fs.device}")) + ] + // lib.pipe cfg.swapDevices [ + (lib.map (s: s.device or s.label)) + ( + sx: + lib.optionalAttrs (sx != [ ]) { + swap = if lib.length sx == 1 then lib.head sx else sx; + } + ) + ]; } // lib.optionalAttrs cfg.services.nginx.enable { nginx-vhosts = lib.pipe cfg.services.nginx.virtualHosts [