From 88b1681dcbcb191ae19062a8742b6abeb9103b1d Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 15 Dec 2023 18:31:08 +0100 Subject: [PATCH 1/7] added config for nvidia/intel gpus and settings file --- hardware/amdgpu.nix | 13 ++++++++++++- hardware/default.nix | 12 +++++++++--- hardware/intelgpu.nix | 16 ++++++++++++++++ hardware/nvidia.nix | 8 ++++++++ settings.nix | 7 +++++++ 5 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 hardware/intelgpu.nix create mode 100644 hardware/nvidia.nix create mode 100644 settings.nix diff --git a/hardware/amdgpu.nix b/hardware/amdgpu.nix index cce5773..cfe9d4f 100644 --- a/hardware/amdgpu.nix +++ b/hardware/amdgpu.nix @@ -1,8 +1,14 @@ -{ pkgs, config, ... }: { +{ pkgs, lib, ... }: +{ + # Adapted from: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix # Make the kernel use the correct driver early boot.initrd.kernelModules = [ "amdgpu" ]; + # Make sure Xserver uses the `amdgpu` driver + services.xserver.enable = true; + services.xserver.videoDrivers = [ "amdgpu" ]; + # For 32 bit applications hardware.opengl.driSupport32Bit = true; @@ -12,6 +18,11 @@ rocmPackages.clr.icd ]; + # For 32 bit applications + hardware.opengl.extraPackages32 = with pkgs; [ + driversi686Linux.amdvlk + ]; + environment.systemPackages = with pkgs; [ nvtop-amd clinfo diff --git a/hardware/default.nix b/hardware/default.nix index 3c7f6bd..9a266ec 100644 --- a/hardware/default.nix +++ b/hardware/default.nix @@ -1,5 +1,11 @@ +{ lib, ... }: +let + settings = import ./../settings.nix; +in { - imports = [ - ./amdgpu.nix - ]; + # Optionally import modules for specific hardware + imports = + lib.optionals settings.hardware.amdgpu [ ./amdgpu.nix ] + ++ lib.optionals settings.hardware.intelgpu [ ./intelgpu.nix ] + ++ lib.optionals settings.hardware.nvidiagpu [ ./nvidiagpu.nix ]; } diff --git a/hardware/intelgpu.nix b/hardware/intelgpu.nix new file mode 100644 index 0000000..7677c3d --- /dev/null +++ b/hardware/intelgpu.nix @@ -0,0 +1,16 @@ +{ pkgs, lib, ... }: +{ + # Excerpt: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/intel/default.nix + + boot.initrd.kernelModules = [ "i915" ]; + + environment.variables = { + VDPAU_DRIVER = lib.mkIf config.hardware.opengl.enable (lib.mkDefault "va_gl"); + }; + + hardware.opengl.extraPackages = with pkgs; [ + (if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then vaapiIntel else intel-vaapi-driver) + libvdpau-va-gl + intel-media-driver + ]; +} diff --git a/hardware/nvidia.nix b/hardware/nvidia.nix new file mode 100644 index 0000000..abaa388 --- /dev/null +++ b/hardware/nvidia.nix @@ -0,0 +1,8 @@ +{ pkgs, lib, ... }: +{ + # Excerpt from: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/nvidia/default.nix + services.xserver.videoDrivers = lib.mkDefault [ "nvidia" ]; + hardware.opengl.extraPackages = with pkgs; [ + vaapiVdpau + ]; +} diff --git a/settings.nix b/settings.nix new file mode 100644 index 0000000..af53d02 --- /dev/null +++ b/settings.nix @@ -0,0 +1,7 @@ +{ + hardware = { + amdgpu = true; + intelgpu = false; + nvidiagpu = false; + }; +} -- 2.40.1 From eca53b8eb52addaf62ef0eeb72c1aab4559e6bbf Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 15 Dec 2023 18:49:12 +0100 Subject: [PATCH 2/7] added extra to settings --- extra/default.nix | 16 ++++++++++------ extra/yubikey.nix | 15 ++++++++------- settings.nix | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/extra/default.nix b/extra/default.nix index 2697f2e..73f60d5 100644 --- a/extra/default.nix +++ b/extra/default.nix @@ -1,8 +1,12 @@ +{ lib, ... }: +let + settings = import ./../settings.nix; +in { - imports = [ - ./bluray.nix - ./dvd.nix - ./yubikey.nix - ./wireguard.nix - ]; + # Optionally import modules for non-essential extras + imports = + lib.optionals settings.hardware.yubikey.enable [ ./yubikey.nix ] + ++ lib.optionals settings.dvd [ ./dvd.nix ] + ++ lib.optionals settings.bluray [ ./bluray.nix ] + ++ lib.optionals settings.networking.wireguard [ ./wireguard.nix ]; } diff --git a/extra/yubikey.nix b/extra/yubikey.nix index c087829..7a55373 100644 --- a/extra/yubikey.nix +++ b/extra/yubikey.nix @@ -2,11 +2,12 @@ services.pcscd.enable = true; # enable support for smart cards - environment.systemPackages = with pkgs; [ - # Yubikey stuff - yubioath-flutter # Yubico authentictor app for managing accounts - yubikey-manager # CLI tool for ykman - yubikey-manager-qt # GUI tool for ykman - pcsclite - ]; + environment.systemPackages = with pkgs; [ pcsclite ] + # Yubico authentictor app for managing accounts + ++ (lib.optionals settings.hardware.yubikey.authenticator [ yubioath-flutter ]) + # ykman CLI and Qt-GUI + ++ (lib.optionals settings.hardware.yubikey.ykman [ + yubikey-manager # CLI tool for ykman + yubikey-manager-qt # GUI tool for ykman + ]); } diff --git a/settings.nix b/settings.nix index af53d02..1254687 100644 --- a/settings.nix +++ b/settings.nix @@ -1,7 +1,23 @@ { hardware = { + # support for GPUs amdgpu = true; intelgpu = false; nvidiagpu = false; + + # support for yubikey and additional software + yubikey = { + enable = true; + # additional software + ykman = false; + authenticator = true; # flutter yubico authenticator + }; + }; + + dvd = true; # enable DVD decryption + ripping via Handbrake + bluray = true; # enable Bluray decryption (requires additional setup) + + networking = { + wireguard = true; # enable wireguard protocol }; } -- 2.40.1 From a566322eeedb60d9859b515fe0bf1279b8653206 Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 15 Dec 2023 18:58:36 +0100 Subject: [PATCH 3/7] fixed yubikey.nix missing import --- extra/yubikey.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extra/yubikey.nix b/extra/yubikey.nix index 7a55373..36f0d58 100644 --- a/extra/yubikey.nix +++ b/extra/yubikey.nix @@ -1,5 +1,8 @@ -{ pkgs, config, ... }: { - +{ pkgs, lib, ... }: +let + settings = import ./../settings.nix; +in +{ services.pcscd.enable = true; # enable support for smart cards environment.systemPackages = with pkgs; [ pcsclite ] -- 2.40.1 From aced2f565a56a388142f49e4f943f365a83e4289 Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 15 Dec 2023 18:58:49 +0100 Subject: [PATCH 4/7] games now controlled via settings --- games/default.nix | 12 ++++++++---- settings.nix | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/games/default.nix b/games/default.nix index 8b92484..0045079 100644 --- a/games/default.nix +++ b/games/default.nix @@ -1,6 +1,10 @@ +{ lib, ... }: +let + settings = import ./../settings.nix; +in { - imports = [ - ./steam.nix - ./prismlauncher.nix - ]; + # Optionally import modules for game launchers, games or compatability layers + imports = + lib.optionals settings.games.prismlauncher [ ./prismlauncher.nix ] + ++ lib.optionals settings.games.steam [ ./steam.nix ]; } diff --git a/settings.nix b/settings.nix index 1254687..0b6039c 100644 --- a/settings.nix +++ b/settings.nix @@ -20,4 +20,9 @@ networking = { wireguard = true; # enable wireguard protocol }; + + games = { + prismlauncher = true; + steam = true; + }; } -- 2.40.1 From ea5ee00760ae3c4855dcc0b612b3388b841b3c45 Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 15 Dec 2023 20:10:28 +0100 Subject: [PATCH 5/7] added core modules to settings --- core/default.nix | 14 ++++++++------ core/printing.nix | 35 +++++++++++++++++++++++------------ core/xdg.nix | 17 +++++++---------- settings.nix | 15 ++++++++++++++- 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/core/default.nix b/core/default.nix index ca99987..068951f 100644 --- a/core/default.nix +++ b/core/default.nix @@ -1,8 +1,10 @@ +{ lib, ... }: +let + settings = import ./../settings.nix; +in { - imports = [ - ./java.nix - ./dotnet.nix - ./printing.nix - ./xdg.nix - ]; + imports = lib.optionals settings.printing.enable [ ./printing.nix ] + ++ lib.optionals settings.xdg.enable [ ./xdg.nix ] + ++ lib.optionals settings.java [ ./java.nix ] + ++ lib.optionals settings.dotnet [ ./dotnet.nix ]; } diff --git a/core/printing.nix b/core/printing.nix index 6bda1c3..69ab596 100644 --- a/core/printing.nix +++ b/core/printing.nix @@ -1,13 +1,24 @@ -{ pkgs, config, ... }: { - services.printing.enable = true; - services.avahi.enable = true; - # for a WiFi printer - services.avahi.openFirewall = true; - services.avahi.nssmdns = false; # Use the settings from below - # settings from avahi-daemon.nix where mdns is replaced with mdns4 - system.nssModules = pkgs.lib.optional (!config.services.avahi.nssmdns) pkgs.nssmdns; - system.nssDatabases.hosts = with pkgs.lib; optionals (!config.services.avahi.nssmdns) (mkMerge [ - (mkBefore [ "mdns4_minimal [NOTFOUND=return]" ]) # before resolve - (mkAfter [ "mdns4" ]) # after dns - ]); +{ pkgs, lib, config, ... }: +let + settings = import ./../settings.nix; +in +{ + config = lib.mkMerge [ + { + services.printing.enable = true; + } + # Avahi daemon + (lib.mkIf settings.printing.avahi { + services.avahi.enable = true; + # for a WiFi printer + services.avahi.openFirewall = true; + services.avahi.nssmdns = false; # Use the settings from below + # settings from avahi-daemon.nix where mdns is replaced with mdns4 + system.nssModules = pkgs.lib.optional (!config.services.avahi.nssmdns) pkgs.nssmdns; + system.nssDatabases.hosts = with pkgs.lib; optionals (!config.services.avahi.nssmdns) (mkMerge [ + (mkBefore [ "mdns4_minimal [NOTFOUND=return]" ]) # before resolve + (mkAfter [ "mdns4" ]) # after dns + ]); + }) + ]; } diff --git a/core/xdg.nix b/core/xdg.nix index 89f14b8..527b8cf 100644 --- a/core/xdg.nix +++ b/core/xdg.nix @@ -1,15 +1,12 @@ -{ pkgs, config, ... }: { - +{ pkgs, ... }: +let + settings = import ./../settings.nix; +in +{ xdg.portal = { enable = true; - extraPortals = [ - pkgs.xdg-desktop-portal-gtk - pkgs.xdg-desktop-portal-kde - ]; + extraPortals = settings.xdg.extraPortals; }; - environment.systemPackages = with pkgs; [ - pkgs.xdg-desktop-portal-gtk - pkgs.xdg-desktop-portal-kde - ]; + environment.systemPackages = settings.xdg.extraPortals; } diff --git a/settings.nix b/settings.nix index 0b6039c..f92fb2b 100644 --- a/settings.nix +++ b/settings.nix @@ -1,4 +1,4 @@ -{ +with import {}; { hardware = { # support for GPUs amdgpu = true; @@ -16,6 +16,19 @@ dvd = true; # enable DVD decryption + ripping via Handbrake bluray = true; # enable Bluray decryption (requires additional setup) + printing = { + enable = true; + avahi = true; + }; + xdg = { + enable = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-gtk + xdg-desktop-portal-kde + ]; + }; + java = true; + dotnet = true; networking = { wireguard = true; # enable wireguard protocol -- 2.40.1 From 4d39e01214a3aea3fea375e37e695698f36f072f Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 15 Dec 2023 20:44:33 +0100 Subject: [PATCH 6/7] moved dev to settings --- dev/default.nix | 16 ++++++++++------ dev/docker-rootless.nix | 8 ++++++-- dev/qemu.nix | 14 +++++++++----- settings.nix | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/dev/default.nix b/dev/default.nix index 8949320..f8d9057 100644 --- a/dev/default.nix +++ b/dev/default.nix @@ -1,10 +1,14 @@ +{ pkgs, lib, config, ... }: +let + settings = import ./../settings.nix; +in { imports = [ ./language-server.nix - ./dotnet.nix - ./docker-rootless.nix - ./platformio.nix - ./qemu.nix - ./latex.nix - ]; + ] + ++ lib.optionals settings.virtualisation.docker-rootless.enable [ ./docker-rootless.nix ] + ++ lib.optionals settings.virtualisation.qemu.enable [ ./qemu.nix ] + ++ lib.optionals settings.dev.platformio [ ./platformio.nix ] + ++ lib.optionals settings.dev.latex [ ./latex.nix ] + ++ lib.optionals settings.dev.dotnet [ ./dotnet.nix ]; } diff --git a/dev/docker-rootless.nix b/dev/docker-rootless.nix index 7b60e25..3dc3640 100644 --- a/dev/docker-rootless.nix +++ b/dev/docker-rootless.nix @@ -1,9 +1,13 @@ -{ pkgs, config, ... }: { +{ pkgs, config, ... }: +let + settings = import ./../settings.nix; +in +{ # enable rootless docker for more security virtualisation.docker.rootless = { enable = true; setSocketVariable = true; }; # regulary clean unused docker images - virtualisation.docker.autoPrune.enable = true; + virtualisation.docker.autoPrune.enable = settings.virtualisation.docker-rootless.autoPrune; } diff --git a/dev/qemu.nix b/dev/qemu.nix index 1c5c1f3..48abae9 100644 --- a/dev/qemu.nix +++ b/dev/qemu.nix @@ -1,10 +1,14 @@ -{ pkgs, config, ... }: { +{ pkgs, config, ... }: +let + settings = import ./../settings.nix; +in +{ # KVM virtualisation.libvirtd.enable = true; - # programs.virt-manager.enable = true; # after 23.11 + programs.virt-manager.enable = settings.virtualisation.qemu.virt-manager; # after 23.11 # only before 23.11 - environment.systemPackages = (with pkgs; [ - virt-manager - ]); + # environment.systemPackages = (with pkgs; [ + # virt-manager + # ]); } diff --git a/settings.nix b/settings.nix index f92fb2b..0c22b12 100644 --- a/settings.nix +++ b/settings.nix @@ -14,6 +14,22 @@ with import {}; { }; }; + virtualisation = { + docker-rootless = { + enable = true; + autoPrune = true; + }; + qemu = { + enable = true; + virt-manager = true; + }; + }; + dev = { + platformio = true; + latex = true; + dotnet = false; + }; + dvd = true; # enable DVD decryption + ripping via Handbrake bluray = true; # enable Bluray decryption (requires additional setup) printing = { -- 2.40.1 From d037c58394d7415aad1cc22df33123a2c062e2cc Mon Sep 17 00:00:00 2001 From: servostar Date: Fri, 15 Dec 2023 20:53:37 +0100 Subject: [PATCH 7/7] added lsp to dev --- dev/default.nix | 4 +--- dev/language-server.nix | 10 ---------- dev/lsp.nix | 13 +++++++++++++ settings.nix | 10 ++++++++++ 4 files changed, 24 insertions(+), 13 deletions(-) delete mode 100644 dev/language-server.nix create mode 100644 dev/lsp.nix diff --git a/dev/default.nix b/dev/default.nix index f8d9057..86786fc 100644 --- a/dev/default.nix +++ b/dev/default.nix @@ -3,9 +3,7 @@ let settings = import ./../settings.nix; in { - imports = [ - ./language-server.nix - ] + imports = lib.optionals settings.dev.lsp.enable [ ./lsp.nix ] ++ lib.optionals settings.virtualisation.docker-rootless.enable [ ./docker-rootless.nix ] ++ lib.optionals settings.virtualisation.qemu.enable [ ./qemu.nix ] ++ lib.optionals settings.dev.platformio [ ./platformio.nix ] diff --git a/dev/language-server.nix b/dev/language-server.nix deleted file mode 100644 index 04f39c8..0000000 --- a/dev/language-server.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ pkgs, config, ... }: { - # various language server used by IDEs and by my Neovim config - environment.systemPackages = with pkgs; [ - shellcheck - lua-language-server - pyright - arduino-language-server - clang - ]; -} diff --git a/dev/lsp.nix b/dev/lsp.nix new file mode 100644 index 0000000..27f3e5c --- /dev/null +++ b/dev/lsp.nix @@ -0,0 +1,13 @@ +{ pkgs, lib, ... }: +let + settings = import ./../settings.nix; +in +{ + # various language server used by IDEs and by Neovim lsp-config + environment.systemPackages = with pkgs; + lib.optionals settings.dev.lsp.shellcheck [ shellcheck ] + ++ lib.optionals settings.dev.lsp.luals [ lua-language-server ] + ++ lib.optionals settings.dev.lsp.pyright[ pyright ] + ++ lib.optionals settings.dev.lsp.arduino [ arduino-language-server ] + ++ lib.optionals settings.dev.lsp.clangd [ clang ]; +} diff --git a/settings.nix b/settings.nix index 0c22b12..335eb6b 100644 --- a/settings.nix +++ b/settings.nix @@ -28,6 +28,16 @@ with import {}; { platformio = true; latex = true; dotnet = false; + + lsp = { + enable = true; + # various language server + shellcheck = true; + luals = true; + pyright = true; + arduino = true; + clangd = true; + }; }; dvd = true; # enable DVD decryption + ripping via Handbrake -- 2.40.1