From 04c915bcf1a1eac3519372ff3185beef053fba7c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 7 Mar 2025 06:11:10 -0500 Subject: [PATCH] firefox: Support paths for userChrome & userContent (#3856) A path may be preferred for some uses, and allowing it avoids the user needing to `builtins.readFile`, thus creating duplicates and making it more difficult to determine the actual store path. --- modules/programs/firefox/mkFirefoxModule.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/programs/firefox/mkFirefoxModule.nix b/modules/programs/firefox/mkFirefoxModule.nix index 1e6c87b11..733c8ec94 100644 --- a/modules/programs/firefox/mkFirefoxModule.nix +++ b/modules/programs/firefox/mkFirefoxModule.nix @@ -401,7 +401,7 @@ in { }; userChrome = mkOption { - type = types.lines; + type = types.oneOf [ types.lines types.path ]; default = ""; description = "Custom ${appName} user chrome CSS."; example = '' @@ -420,7 +420,7 @@ in { }; userContent = mkOption { - type = types.lines; + type = types.oneOf [ types.lines types.path ]; default = ""; description = "Custom ${appName} user content CSS."; example = '' @@ -868,10 +868,18 @@ in { "${profilesPath}/${profile.path}/.keep".text = ""; "${profilesPath}/${profile.path}/chrome/userChrome.css" = - mkIf (profile.userChrome != "") { text = profile.userChrome; }; + mkIf (profile.userChrome != "") (let + key = + if builtins.isString profile.userChrome then "text" else "source"; + in { "${key}" = profile.userChrome; }); "${profilesPath}/${profile.path}/chrome/userContent.css" = - mkIf (profile.userContent != "") { text = profile.userContent; }; + mkIf (profile.userContent != "") (let + key = if builtins.isString profile.userContent then + "text" + else + "source"; + in { "${key}" = profile.userContent; }); "${profilesPath}/${profile.path}/user.js" = mkIf (profile.preConfig != "" || profile.settings != { } || profile.extraConfig != ""