Skip to content

Commit 7ede02c

Browse files
authored
progs: firefox: *.userChrome may be path or drv (#6761)
This allows `programs.firefox.profiles.*.userChrome` to be set to a: derivation, path/path-like string to directory or file, or multiline text to be used as content verbatim. This allows setting, for example(s): ```nix programs.firefox.profiles."jacob.default".userChrome = pkgs.wavefox; programs.firefox.profiles."jacob.default".userChrome = "${pkgs.wavefox}/userChrome.css"; ```
1 parent d8263c0 commit 7ede02c

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

modules/programs/firefox/mkFirefoxModule.nix

+28-15
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,19 @@ in
397397
};
398398

399399
userChrome = mkOption {
400-
type = types.oneOf [
401-
types.lines
402-
types.path
403-
];
404-
default = "";
405-
description = "Custom ${appName} user chrome CSS.";
400+
type = types.nullOr (
401+
types.oneOf [
402+
types.lines
403+
types.path
404+
]
405+
);
406+
default = null;
407+
description = ''
408+
Custom ${appName} user chrome CSS.
409+
410+
This can be a path to a file or directory in the Nix store,
411+
or a derivation, or a verbatim multi-line string.
412+
'';
406413
example = ''
407414
/* Hide tab bar in FF Quantum */
408415
@-moz-document url(chrome://browser/content/browser.xul), url(chrome://browser/content/browser.xhtml) {
@@ -861,21 +868,27 @@ in
861868
]
862869
++ lib.flip mapAttrsToList cfg.profiles (
863870
_: profile:
871+
let
872+
chromePath = if lib.pathIsDirectory profile.userChrome then "chrome" else "chrome/userChrome.css";
873+
sourcePath = if lib.types.path.check profile.userChrome then profile.userChrome else null;
874+
in
864875
# Merge the regular profile settings with extension settings
865876
mkMerge (
866877
[
878+
(mkIf (profile.userChrome != null) {
879+
"${profilesPath}/${profile.path}/${chromePath}" =
880+
if sourcePath == null then
881+
{
882+
text = profile.userChrome;
883+
}
884+
else
885+
{
886+
source = sourcePath;
887+
};
888+
})
867889
{
868890
"${profilesPath}/${profile.path}/.keep".text = "";
869891

870-
"${profilesPath}/${profile.path}/chrome/userChrome.css" = mkIf (profile.userChrome != "") (
871-
let
872-
key = if builtins.isString profile.userChrome then "text" else "source";
873-
in
874-
{
875-
"${key}" = profile.userChrome;
876-
}
877-
);
878-
879892
"${profilesPath}/${profile.path}/chrome/userContent.css" = mkIf (profile.userContent != "") (
880893
let
881894
key = if builtins.isString profile.userContent then "text" else "source";

0 commit comments

Comments
 (0)