@@ -358,7 +358,12 @@ in {
358
358
userChrome = mkOption {
359
359
type = types . oneOf [ types . lines types . path ] ;
360
360
default = "" ;
361
- description = "Custom ${ appName } user chrome CSS." ;
361
+ description = ''
362
+ Custom ${ appName } user chrome CSS.
363
+
364
+ This can be a path to a file or directory in the nix store,
365
+ or a derivation, or a verbatim multi-line string.
366
+ '' ;
362
367
example = ''
363
368
/* Hide tab bar in FF Quantum */
364
369
@-moz-document url(chrome://browser/content/browser.xul), url(chrome://browser/content/browser.xhtml) {
@@ -754,66 +759,78 @@ in {
754
759
"${ cfg . configPath } /profiles.ini" =
755
760
mkIf ( cfg . profiles != { } ) { text = profilesIni ; } ;
756
761
} ] ++ lib . flip mapAttrsToList cfg . profiles ( _ : profile :
757
- # Merge the regular profile settings with extension settings
758
- mkMerge ( [ {
759
- "${ profilesPath } /${ profile. path } /.keep" . text = "" ;
760
-
761
- "${ profilesPath } /${ profile . path } /chrome/userChrome.css" =
762
- mkIf ( profile . userChrome != "" ) ( let
763
- key =
764
- if builtins . isString profile . userChrome then "text" else "source" ;
765
- in { "${ key } " = profile . userChrome ; } ) ;
766
-
767
- "${ profilesPath } /${ profile . path } /chrome/userContent.css" =
768
- mkIf ( profile . userContent != "" ) ( let
769
- key = if builtins . isString profile . userContent then
770
- "text"
771
- else
772
- "source" ;
773
- in { "${ key } " = profile . userContent ; } ) ;
774
-
775
- "${ profilesPath } /${ profile . path } /user.js" = mkIf ( profile . preConfig
776
- != "" || profile . settings != { } || profile . extraConfig != ""
777
- || profile . bookmarks . configFile != null ) {
778
- text =
779
- mkUserJs profile . preConfig profile . settings profile . extraConfig
780
- profile . bookmarks . configFile profile . extensions . settings ;
781
- } ;
762
+ let
763
+ chromePath = if lib . pathIsDirectory profile . userChrome then
764
+ "chrome"
765
+ else
766
+ "chrome/userChrome.css" ;
767
+ sourcePath = if lib . types . path . check profile . userChrome then
768
+ profile . userChrome
769
+ else
770
+ null ;
771
+ # Merge the regular profile settings with extension settings
772
+ in mkMerge [
773
+ {
774
+ "${ profilesPath } /${ profile. path } /.keep" . text = "" ;
775
+
776
+ "${ profilesPath } /${ profile . path } /${ chromePath } " =
777
+ if sourcePath == null then {
778
+ text = profile . userChrome ;
779
+ } else {
780
+ source = sourcePath ;
781
+ } ;
782
782
783
- "${ profilesPath } /${ profile . path } /containers.json" =
784
- mkIf ( profile . containers != { } ) {
785
- text = mkContainersJson profile . containers ;
786
- force = profile . containersForce ;
787
- } ;
783
+ "${ profilesPath } /${ profile . path } /chrome/userContent.css" =
784
+ mkIf ( profile . userContent != "" ) ( let
785
+ key = if builtins . isString profile . userContent then
786
+ "text"
787
+ else
788
+ "source" ;
789
+ in { "${ key } " = profile . userContent ; } ) ;
790
+
791
+ "${ profilesPath } /${ profile . path } /user.js" = mkIf ( profile . preConfig
792
+ != "" || profile . settings != { } || profile . extraConfig != ""
793
+ || profile . bookmarks . configFile != null ) {
794
+ text =
795
+ mkUserJs profile . preConfig profile . settings profile . extraConfig
796
+ profile . bookmarks . configFile profile . extensions . settings ;
797
+ } ;
788
798
789
- "${ profilesPath } /${ profile . path } /search.json.mozlz4" =
790
- mkIf ( profile . search . enable ) {
791
- enable = profile . search . enable ;
792
- force = profile . search . force ;
793
- source = profile . search . file ;
794
- } ;
799
+ "${ profilesPath } /${ profile . path } /containers.json" =
800
+ mkIf ( profile . containers != { } ) {
801
+ text = mkContainersJson profile . containers ;
802
+ force = profile . containersForce ;
803
+ } ;
795
804
796
- "${ profilesPath } /${ profile . path } /extensions" =
797
- mkIf ( profile . extensions . packages != [ ] ) {
798
- source = let
799
- extensionsEnvPkg = pkgs . buildEnv {
800
- name = "hm-firefox-extensions" ;
801
- paths = profile . extensions . packages ;
802
- } ;
803
- in "${ extensionsEnvPkg } /share/mozilla/${ extensionPath } " ;
804
- recursive = true ;
805
- force = true ;
806
- } ;
807
- } ] ++
805
+ "${ profilesPath } /${ profile . path } /search.json.mozlz4" =
806
+ mkIf ( profile . search . enable ) {
807
+ enable = profile . search . enable ;
808
+ force = profile . search . force ;
809
+ source = profile . search . file ;
810
+ } ;
811
+
812
+ "${ profilesPath } /${ profile . path } /extensions" =
813
+ mkIf ( profile . extensions . packages != [ ] ) {
814
+ source = let
815
+ extensionsEnvPkg = pkgs . buildEnv {
816
+ name = "hm-firefox-extensions" ;
817
+ paths = profile . extensions . packages ;
818
+ } ;
819
+ in "${ extensionsEnvPkg } /share/mozilla/${ extensionPath } " ;
820
+ recursive = true ;
821
+ force = true ;
822
+ } ;
823
+ }
808
824
# Add extension settings as separate attributes
809
- optional ( profile . extensions . settings != { } ) ( mkMerge ( mapAttrsToList
825
+ ( mkIf ( profile . extensions . settings != { } ) ( mkMerge ( mapAttrsToList
810
826
( name : settingConfig : {
811
827
"${ profilesPath } /${ profile . path } /browser-extension-data/${ name } /storage.js" =
812
828
{
813
829
force = settingConfig . force || profile . extensions . force ;
814
830
text = lib . generators . toJSON { } settingConfig . settings ;
815
831
} ;
816
- } ) profile . extensions . settings ) ) ) ) ) ;
832
+ } ) profile . extensions . settings ) ) )
833
+ ] ) ) ;
817
834
} // setAttrByPath modulePath {
818
835
finalPackage = wrapPackage cfg . package ;
819
836
0 commit comments