From 7284e905a3d7b427c94985603cb5988bfafd0340 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Fri, 7 Apr 2023 12:56:00 -0400 Subject: [PATCH] firefox: Support paths for userChrome & userContent 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.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/programs/firefox.nix b/modules/programs/firefox.nix index 8ce84fcb..d79e06a6 100644 --- a/modules/programs/firefox.nix +++ b/modules/programs/firefox.nix @@ -343,7 +343,7 @@ in { }; userChrome = mkOption { - type = types.lines; + type = types.oneOf [ types.lines types.path ]; default = ""; description = "Custom Firefox user chrome CSS."; example = '' @@ -362,7 +362,7 @@ in { }; userContent = mkOption { - type = types.lines; + type = types.oneOf [ types.lines types.path ]; default = ""; description = "Custom Firefox user content CSS."; example = '' @@ -749,10 +749,16 @@ 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.settings != { } || profile.extraConfig != "" || profile.bookmarks != [ ]) {