treewide: move NixOS-inherited defaults to their option definitions

This commit is contained in:
Benedikt Rips
2026-05-16 23:50:25 +02:00
committed by Matthieu Coudron
parent a2c0bcaff4
commit dd71501fb7
3 changed files with 20 additions and 32 deletions

View File

@@ -16,9 +16,10 @@
# https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/development/libraries/glibc/nix-locale-archive.patch # https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/development/libraries/glibc/nix-locale-archive.patch
{ {
lib,
pkgs,
config, config,
lib,
nixosConfig,
pkgs,
... ...
}: }:
@@ -55,9 +56,8 @@ in
This option only applies to the Linux platform. This option only applies to the Linux platform.
When Home Manager is configured with NixOS, the default value If Home Manager is installed as a NixOS submodule, this
will be set to {var}`i18n.glibcLocales` from the option defaults to NixOS' {var}`i18n.glibcLocales`.
system configuration.
''; '';
example = lib.literalExpression '' example = lib.literalExpression ''
pkgs.glibcLocales.override { pkgs.glibcLocales.override {
@@ -65,9 +65,8 @@ in
locales = [ "en_US.UTF-8/UTF-8" ]; locales = [ "en_US.UTF-8/UTF-8" ];
} }
''; '';
# NB. See nixos/default.nix for NixOS default. default = nixosConfig.i18n.glibcLocales or pkgs.glibcLocales;
default = pkgs.glibcLocales; defaultText = lib.literalExpression "nixosConfig.i18n.glibcLocales or pkgs.glibcLocales";
defaultText = lib.literalExpression "pkgs.glibcLocales";
}; };
}; };

View File

@@ -5,6 +5,7 @@
{ {
config, config,
lib, lib,
nixosConfig,
pkgs, pkgs,
... ...
}: }:
@@ -70,7 +71,6 @@ in
fonts.fontconfig = { fonts.fontconfig = {
enable = lib.mkOption { enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = false;
description = '' description = ''
Whether to enable fontconfig configuration. This will, for example, Whether to enable fontconfig configuration. This will, for example,
allow fontconfig to discover fonts and configurations installed through allow fontconfig to discover fonts and configurations installed through
@@ -80,6 +80,17 @@ in
{var}`home-manager.useUserPackages` is enabled, this option defaults to the {var}`home-manager.useUserPackages` is enabled, this option defaults to the
value of NixOS' {var}`fonts.fontconfig.enable`. value of NixOS' {var}`fonts.fontconfig.enable`.
''; '';
# On NixOS, the per-user directory inside /etc/profiles is not known by
# fontconfig by default.
default =
nixosConfig != null
&& nixosConfig.home-manager.useUserPackages
&& nixosConfig.fonts.fontconfig.enable;
defaultText = lib.literalExpression ''
nixosConfig != null
&& nixosConfig.home-manager.useUserPackages
&& nixosConfig.fonts.fontconfig.enable;
'';
}; };
defaultFonts = { defaultFonts = {

View File

@@ -68,29 +68,7 @@ in
}; };
config = lib.mkMerge [ config = lib.mkMerge [
{ { home-manager.extraSpecialArgs.nixosConfig = config; }
home-manager = {
extraSpecialArgs.nixosConfig = config;
sharedModules = [
{
key = "home-manager#nixos-shared-module";
config = {
# The per-user directory inside /etc/profiles is not known by
# fontconfig by default.
#
# When changing the following line, remember to reflect these
# changes in the description of 'fonts.fontconfig.enable'!
fonts.fontconfig.enable = lib.mkDefault (cfg.useUserPackages && config.fonts.fontconfig.enable);
# Inherit glibcLocales setting from NixOS.
i18n.glibcLocales = lib.mkDefault config.i18n.glibcLocales;
};
}
];
};
}
(mkIf (!cfg.startAsUserService && cfg.users != { }) { (mkIf (!cfg.startAsUserService && cfg.users != { }) {
systemd.services = lib.mapAttrs' ( systemd.services = lib.mapAttrs' (