From d14392eaf6c6402eacbdf71ef7854d5a535f3601 Mon Sep 17 00:00:00 2001 From: MithicSpirit Date: Sun, 17 Nov 2024 19:49:32 -0500 Subject: [PATCH] nixos/obs-studio: nullable package Allows setting `programs.obs-studio.package = null`, which is useful in case the user wants the appropriate kernel modules from `programs.obs-studio.enableVirtualCamera`, but does not wish to install obs system-wide with nixos (e.g., because they want to install it just for their user with home-manager or maybe via flatpak). --- nixos/modules/programs/obs-studio.nix | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/nixos/modules/programs/obs-studio.nix b/nixos/modules/programs/obs-studio.nix index ee9ec520d1fb..b2a56ea61a6e 100644 --- a/nixos/modules/programs/obs-studio.nix +++ b/nixos/modules/programs/obs-studio.nix @@ -12,10 +12,13 @@ in options.programs.obs-studio = { enable = lib.mkEnableOption "Free and open source software for video recording and live streaming"; - package = lib.mkPackageOption pkgs "obs-studio" { example = "obs-studio"; }; + package = lib.mkPackageOption pkgs "obs-studio" { + nullable = true; + example = "obs-studio"; + }; finalPackage = lib.mkOption { - type = lib.types.package; + type = lib.types.nullOr lib.types.package; visible = false; readOnly = true; description = "Resulting customized OBS Studio package."; @@ -39,11 +42,16 @@ in }; config = lib.mkIf cfg.enable { - programs.obs-studio.finalPackage = pkgs.wrapOBS.override { obs-studio = cfg.package; } { - plugins = cfg.plugins; + assertions = lib.singleton { + assertion = cfg.package == null -> cfg.plugins == [ ]; + message = "Plugins cannot be set if package is null"; }; - environment.systemPackages = [ cfg.finalPackage ]; + programs.obs-studio.finalPackage = lib.mapNullable ( + obs-studio: pkgs.wrapOBS.override { inherit obs-studio; } { plugins = cfg.plugins; } + ) cfg.package; + + environment.systemPackages = lib.optional (cfg.finalPackage != null) cfg.finalPackage; boot = lib.mkIf cfg.enableVirtualCamera { kernelModules = [ "v4l2loopback" ];