diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix
index e76e135e..67678323 100644
--- a/modules/misc/fontconfig.nix
+++ b/modules/misc/fontconfig.nix
@@ -28,14 +28,32 @@ in
};
};
- config = mkIf cfg.enableProfileFonts {
- xdg.configFile."fontconfig/conf.d/10-nix-profile-fonts.conf".text = ''
-
-
-
- ~/.nix-profile/lib/X11/fonts
- ~/.nix-profile/share/fonts
-
- '';
- };
+ config = mkMerge [
+ (mkIf cfg.enableProfileFonts {
+ xdg.configFile."fontconfig/conf.d/10-nix-profile-fonts.conf".text = ''
+
+
+
+ ~/.nix-profile/lib/X11/fonts
+ ~/.nix-profile/share/fonts
+
+ '';
+ })
+
+ # If we are inside a NixOS system configuration then packages are
+ # installed through the NixOS `users.users..packages`
+ # option. Unfortunately fontconfig does not know about the
+ # per-user installation directory so we have to add that directory
+ # in a extra configuration file.
+ (mkIf config.nixosSubmodule {
+ xdg.configFile."fontconfig/conf.d/10-nix-per-user-fonts.conf".text = ''
+
+
+
+ /etc/per-user-pkgs/${config.home.username}/lib/X11/fonts
+ /etc/per-user-pkgs/${config.home.username}/share/fonts
+
+ '';
+ })
+ ];
}