From 6b04b535c16f347dd7fb5cd9f9c31fe7e24ea6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vili=20Sinerv=C3=A4?= Date: Thu, 6 Jun 2024 22:16:29 +0300 Subject: [PATCH] Add conditionals and assertions --- desktop.nix | 7 +++++++ hardware-specific/amd-laptop.nix | 2 +- hardware-specific/keychron-q11.nix | 2 +- hardware-specific/trackball.nix | 7 +++++++ services/game-streaming.nix | 7 +++++++ services/redshift.nix | 6 ++++++ services/vaultwarden.nix | 2 +- 7 files changed, 30 insertions(+), 3 deletions(-) diff --git a/desktop.nix b/desktop.nix index ef8cac5..6633470 100644 --- a/desktop.nix +++ b/desktop.nix @@ -451,6 +451,13 @@ let ''}"; in { + assertions = [ + { + assertion = config.users.users ? "vili"; + message = "User 'vili' needed for desktop!"; + } + ]; + environment.systemPackages = with pkgs; [ i3status rofi diff --git a/hardware-specific/amd-laptop.nix b/hardware-specific/amd-laptop.nix index 9ebcbb1..b25bc9d 100644 --- a/hardware-specific/amd-laptop.nix +++ b/hardware-specific/amd-laptop.nix @@ -8,7 +8,7 @@ boot.initrd.kernelModules = [ "amdgpu" ]; services = { - xserver = { + xserver = pkgs.lib.mkIf config.services.xserver.enable { videoDrivers = [ "amdgpu" "modesetting" diff --git a/hardware-specific/keychron-q11.nix b/hardware-specific/keychron-q11.nix index d1571c5..d8bb8d7 100644 --- a/hardware-specific/keychron-q11.nix +++ b/hardware-specific/keychron-q11.nix @@ -1,7 +1,7 @@ # Config for Keychron Q11 keyboard { config, pkgs, ... }: { - environment.systemPackages = with pkgs; [ via ]; + environment.systemPackages = with pkgs; if config.services.xserver.enable then [ via ] else [ ]; # Keychron Q11 services.udev.extraRules = '' diff --git a/hardware-specific/trackball.nix b/hardware-specific/trackball.nix index 115305d..7b7b63a 100644 --- a/hardware-specific/trackball.nix +++ b/hardware-specific/trackball.nix @@ -1,6 +1,13 @@ # Config for my Logitech trackball { config, pkgs, ... }: { + assertions = [ + { + assertion = config.services.xserver.enable; + message = "Trackball does not work without a desktop!"; + } + ]; + disabledModules = [ "services/hardware/libinput.nix" ]; nixpkgs.overlays = [ diff --git a/services/game-streaming.nix b/services/game-streaming.nix index 385a399..4a9bdc1 100644 --- a/services/game-streaming.nix +++ b/services/game-streaming.nix @@ -1,6 +1,13 @@ # Game streaming software (and possibly services in future) { config, pkgs, ... }: { + assertions = [ + { + assertion = config.services.xserver.enable; + message = "Game streaming does not work without a desktop!"; + } + ]; + environment.systemPackages = with pkgs; [ moonlight-qt parsec-bin diff --git a/services/redshift.nix b/services/redshift.nix index d013455..12a9aa8 100644 --- a/services/redshift.nix +++ b/services/redshift.nix @@ -1,6 +1,12 @@ # Redshift bluelight reducer { config, pkgs, ... }: { + assertions = [ + { + assertion = config.services.xserver.enable; + message = "Redshift does not work without a desktop!"; + } + ]; services = { redshift = { executable = "/bin/redshift-gtk"; diff --git a/services/vaultwarden.nix b/services/vaultwarden.nix index a9f6b46..96a4e2c 100644 --- a/services/vaultwarden.nix +++ b/services/vaultwarden.nix @@ -1,4 +1,4 @@ -# Nextcloud instance +# Vaultwarden instance { config, pkgs, ... }: { networking.firewall.allowedTCPPorts = [