diff --git a/nixos/flake.nix b/nixos/flake.nix index e6a679e..31056f8 100644 --- a/nixos/flake.nix +++ b/nixos/flake.nix @@ -34,10 +34,12 @@ utils.lib.mkFlake { inherit self inputs; - channelsConfig = { - allowUnfree.allowUnfreePredicate = pkg: builtins.elem (utils.lib.getName pkg) [ - ]; - }; + channelsConfig.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ + "nvidia-x11" + "nvidia-settings" + "corefonts" + "vista-fonts" + ]; sharedOverlays = [ (import ./overlays/letter) @@ -51,6 +53,10 @@ specialArgs = { pkgs-unstable = import nixpkgs-unstable { inherit system; + config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ + "obsidian" + "spotify" + ]; }; }; diff --git a/nixos/hosts/Tibo-NixDesk/hardware-configuration.nix b/nixos/hosts/Tibo-NixDesk/hardware-configuration.nix index 571525e..a5ae163 100644 --- a/nixos/hosts/Tibo-NixDesk/hardware-configuration.nix +++ b/nixos/hosts/Tibo-NixDesk/hardware-configuration.nix @@ -31,6 +31,7 @@ "/nix" = { device = "/dev/disk/by-label/NIX-STORE"; fsType = "ext4"; + options = [ "noatime" ]; }; "/mnt/Nextcloud" = { diff --git a/nixos/hosts/Tibo-NixFat/default.nix b/nixos/hosts/Tibo-NixFat/default.nix index 1cea7fa..7712d12 100644 --- a/nixos/hosts/Tibo-NixFat/default.nix +++ b/nixos/hosts/Tibo-NixFat/default.nix @@ -3,13 +3,15 @@ { imports = [ ./hardware-configuration.nix - ../../modules-old/hardware/nvidia.nix ../../modules-old ]; sisyphus = { users.tdpeuter.enable = true; + hardware.nvidia.enable = true; + hardware.nvidia.model = "T2000"; + programs = { home-manager.enable = true; sops.enable = true; diff --git a/nixos/modules-old/default.nix b/nixos/modules-old/default.nix index ec66e24..35fb80f 100644 --- a/nixos/modules-old/default.nix +++ b/nixos/modules-old/default.nix @@ -1,15 +1,26 @@ { inputs, lib, config, pkgs, ... }: { - # Nix Flakes - nix.package = pkgs.nixFlakes; - nix.extraOptions = '' - experimental-features = nix-command flakes - keep-outputs = true - keep-derivations = true - ''; + nix = { + # Allow Nix Flakes + # Keep derivations so shells don't break (direnv) + # If the disk has less than 100MiB, free up to 2GiB by garbage-collecting. + extraOptions = '' + experimental-features = nix-command flakes + keep-outputs = true + keep-derivations = true + min-free = ${toString (100 * 1024 * 1024)} + max-free = ${toString (2048 * 1024 * 1024)} + ''; + # Scheduled garbage-collect + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 30d"; + }; + package = pkgs.nixFlakes; + }; - # Select internationalisation properties. i18n.defaultLocale = "en_GB.UTF-8"; console = { # font = "Lat2-Terminus16"; diff --git a/nixos/modules-old/hardware/nvidia.nix b/nixos/modules-old/hardware/nvidia.nix deleted file mode 100644 index 1473758..0000000 --- a/nixos/modules-old/hardware/nvidia.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ inputs, lib, config, pkgs, ... }: - -let - nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' - export __NV_PRIME_RENDER_OFFLOAD=1 - export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 - export __GLX_VENDOR_LIBRARY_NAME=nvidia - export __VK_LAYER_NV_optimus=NVIDIA_only - exec "$@" - ''; -in -{ - nixpkgs.config.allowUnfree = true; - - services.xserver.videoDrivers = [ "nvidia" ]; - - hardware = { - opengl.enable = true; - nvidia = { - open = true; - package = config.boot.kernelPackages.nvidiaPackages.stable; - modesetting.enable = true; - }; - }; - - # Offloading - # environment.systemPackages = [ nvidia-offload ]; - # hardware.nvidia.prime = { - # offload.enable = true; - # intelBusId = "PCI::00:02:0"; - # nvidiaBusId = "PCI:01:00:0"; - # }; -} diff --git a/nixos/modules/default.nix b/nixos/modules/default.nix index c7dbaae..5f5812b 100644 --- a/nixos/modules/default.nix +++ b/nixos/modules/default.nix @@ -1,5 +1,6 @@ { imports = [ + ./hardware ./programs ./services ./virtualisation diff --git a/nixos/modules/hardware/default.nix b/nixos/modules/hardware/default.nix new file mode 100644 index 0000000..efa0833 --- /dev/null +++ b/nixos/modules/hardware/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./nvidia + ]; +} diff --git a/nixos/modules/hardware/nvidia/default.nix b/nixos/modules/hardware/nvidia/default.nix new file mode 100644 index 0000000..34ba4e6 --- /dev/null +++ b/nixos/modules/hardware/nvidia/default.nix @@ -0,0 +1,46 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.sisyphus.hardware.nvidia; + + nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" '' + export __NV_PRIME_RENDER_OFFLOAD=1 + export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0 + export __GLX_VENDOR_LIBRARY_NAME=nvidia + export __VK_LAYER_NV_optimus=NVIDIA_only + exec "$@" + ''; +in { + options.sisyphus.hardware.nvidia = { + enable = lib.mkEnableOption "NVIDIA GPU support"; + model = lib.mkOption { + type = lib.types.enum [ "" "T2000" "RTX 2060" ]; + default = ""; + example = "T2000"; + description = lib.mdDoc "The model of NVIDIA GPU card"; + }; + }; + + config = lib.mkIf cfg.enable { + services.xserver.videoDrivers = [ "nvidia" ]; + + hardware = { + opengl.enable = true; + nvidia = { + open = true; + package = config.boot.kernelPackages.nvidiaPackages.stable; + modesetting.enable = true; + + prime = lib.mkIf (cfg.model == "T2000") { + offload.enable = true; + intelBusId = "PCI::00:02:0"; + nvidiaBusId = "PCI:01:00:0"; + }; + }; + }; + + environment.systemPackages = lib.mkIf (cfg.model != "") [ + nvidia-offload + ]; + }; +} diff --git a/nixos/users/tdpeuter/default.nix b/nixos/users/tdpeuter/default.nix index 0be8d05..56f51b8 100644 --- a/nixos/users/tdpeuter/default.nix +++ b/nixos/users/tdpeuter/default.nix @@ -60,10 +60,8 @@ in { libreoffice-fresh nextcloud-client nsxiv # Lightweight image viewer - obsidian oh-my-zsh qalculate-gtk # Calculator - spotify tea # Gitea CLI unzip vifm # File manager @@ -74,6 +72,8 @@ in { zsh-syntax-highlighting ]) ++ (with pkgs-unstable; [ mpv + obsidian + spotify ]) ++ (with pkgs.vimPlugins; [ statix vim-plug