From 7784352dc8f1ff5aea5439659af22b76bddf1a0b Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Sun, 8 Sep 2024 02:36:45 +0300 Subject: [PATCH] modules: share opengl only when graphics is enabled --- modules/nixos/programs/browsers/default.nix | 8 ++++-- .../nixos/programs/communication/skype.nix | 26 ++++++++++++------- .../nixos/programs/communication/telegram.nix | 26 ++++++++++++------- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/modules/nixos/programs/browsers/default.nix b/modules/nixos/programs/browsers/default.nix index 7815093..a754c22 100644 --- a/modules/nixos/programs/browsers/default.nix +++ b/modules/nixos/programs/browsers/default.nix @@ -91,9 +91,13 @@ in isReadOnly = false; hostPath = "/home/jan/downloads/browser"; }; - "/run/opengl-driver/lib" = { }; - "/run/opengl-driver-32/lib" = { }; } + (lib.mkIf config.hardware.graphics.enable { + "/run/opengl-driver/lib" = { }; + }) + (lib.mkIf config.hardware.graphics.enable32Bit { + "/run/opengl-driver-32/lib" = { }; + }) (lib.mkIf cfg.librewolf.enable { "/home/kira/.librewolf" = { isReadOnly = false; diff --git a/modules/nixos/programs/communication/skype.nix b/modules/nixos/programs/communication/skype.nix index b2e5be8..80d1122 100644 --- a/modules/nixos/programs/communication/skype.nix +++ b/modules/nixos/programs/communication/skype.nix @@ -62,15 +62,21 @@ in privateNetwork = true; inherit hostAddress localAddress; - bindMounts = { - "/tmp/.X11-unix" = { }; - "/etc/ssh/keys" = { - isReadOnly = false; - hostPath = "/persistent/per-machine/skype/etc/ssh/keys"; - }; - "/run/opengl-driver/lib" = { }; - "/run/opengl-driver-32/lib" = { }; - }; + bindMounts = lib.mkMerge [ + { + "/tmp/.X11-unix" = { }; + "/etc/ssh/keys" = { + isReadOnly = false; + hostPath = "/persistent/per-machine/skype/etc/ssh/keys"; + }; + } + (lib.mkIf config.hardware.graphics.enable { + "/run/opengl-driver/lib" = { }; + }) + (lib.mkIf config.hardware.graphics.enable32Bit { + "/run/opengl-driver-32/lib" = { }; + }) + ]; config = { pkgs, ... }: { system.stateVersion = "23.11"; @@ -105,7 +111,7 @@ in home = "/home/kira"; password = "hello"; extraGroups = [ "pulse-access" ]; - packages = [cfg.package]; + packages = [ cfg.package ]; }; environment.sessionVariables = { diff --git a/modules/nixos/programs/communication/telegram.nix b/modules/nixos/programs/communication/telegram.nix index 7857e24..94f4bf4 100644 --- a/modules/nixos/programs/communication/telegram.nix +++ b/modules/nixos/programs/communication/telegram.nix @@ -62,15 +62,21 @@ in privateNetwork = true; inherit hostAddress localAddress; - bindMounts = { - "/tmp/.X11-unix" = { }; - "/etc/ssh/keys" = { - isReadOnly = false; - hostPath = "/persistent/per-machine/telegram/etc/ssh/keys"; - }; - "/run/opengl-driver/lib" = { }; - "/run/opengl-driver-32/lib" = { }; - }; + bindMounts = lib.mkMerge [ + { + "/tmp/.X11-unix" = { }; + "/etc/ssh/keys" = { + isReadOnly = false; + hostPath = "/persistent/per-machine/telegram/etc/ssh/keys"; + }; + } + (lib.mkIf config.hardware.graphics.enable { + "/run/opengl-driver/lib" = { }; + }) + (lib.mkIf config.hardware.graphics.enable32Bit { + "/run/opengl-driver-32/lib" = { }; + }) + ]; config = { pkgs, ... }: { system.stateVersion = "23.11"; @@ -104,7 +110,7 @@ in home = "/home/kira"; password = "hello"; extraGroups = [ "pulse-access" ]; - packages = [cfg.package]; + packages = [ cfg.package ]; }; environment.sessionVariables = {