1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

treewide: remove with lib (#6512)

* nixos: remove with lib
* nix-darwin: remove with lib
* home-manager: remove with lib
* modules/accounts: remove with lib
* modules/config: remove with lib
* modules/i18n: remove with lib
* modules/misc: remove with lib
* modules: remove with lib
* modules/targets: remove with lib
* tests/modules/firefox: remove with lib
* tests/modules/services: remove with lib
This commit is contained in:
Austin Horstman 2025-03-07 14:16:46 -06:00 committed by GitHub
parent 83f4629364
commit 95711f9266
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
62 changed files with 618 additions and 666 deletions

View file

@ -3,9 +3,8 @@
{ options, config, lib, pkgs, ... }:
with lib;
let
inherit (lib) flip mkOption mkEnableOption mkIf types;
cfg = config.home-manager;
@ -74,7 +73,7 @@ in {
extraSpecialArgs = mkOption {
type = types.attrs;
default = { };
example = literalExpression "{ inherit emacs-overlay; }";
example = lib.literalExpression "{ inherit emacs-overlay; }";
description = ''
Extra `specialArgs` passed to Home Manager. This
option can be used to pass additional arguments to all modules.
@ -84,7 +83,8 @@ in {
sharedModules = mkOption {
type = with types; listOf raw;
default = [ ];
example = literalExpression "[ { home.packages = [ nixpkgs-fmt ]; } ]";
example =
lib.literalExpression "[ { home.packages = [ nixpkgs-fmt ]; } ]";
description = ''
Extra modules added to all users.
'';
@ -103,19 +103,18 @@ in {
};
};
config = (mkMerge [
config = (lib.mkMerge [
# Fix potential recursion when configuring home-manager users based on values in users.users #594
(mkIf (cfg.useUserPackages && cfg.users != { }) {
users.users =
(mapAttrs (username: usercfg: { packages = [ usercfg.home.path ]; })
cfg.users);
users.users = (lib.mapAttrs
(_username: usercfg: { packages = [ usercfg.home.path ]; }) cfg.users);
environment.pathsToLink = [ "/etc/profile.d" ];
})
(mkIf (cfg.users != { }) {
warnings = flatten (flip mapAttrsToList cfg.users (user: config:
warnings = lib.flatten (flip lib.mapAttrsToList cfg.users (user: config:
flip map config.warnings (warning: "${user} profile: ${warning}")));
assertions = flatten (flip mapAttrsToList cfg.users (user: config:
assertions = lib.flatten (flip lib.mapAttrsToList cfg.users (user: config:
flip map config.assertions (assertion: {
inherit (assertion) assertion;
message = "${user} profile: ${assertion.message}";

View file

@ -1,19 +1,17 @@
{ config, lib, pkgs, utils, ... }:
with lib;
let
cfg = config.home-manager;
serviceEnvironment = optionalAttrs (cfg.backupFileExtension != null) {
serviceEnvironment = lib.optionalAttrs (cfg.backupFileExtension != null) {
HOME_MANAGER_BACKUP_EXT = cfg.backupFileExtension;
} // optionalAttrs cfg.verbose { VERBOSE = "1"; };
} // lib.optionalAttrs cfg.verbose { VERBOSE = "1"; };
in {
imports = [ ./common.nix ];
config = mkMerge [
config = lib.mkMerge [
{
home-manager = {
extraSpecialArgs.nixosConfig = config;
@ -33,10 +31,11 @@ in {
}];
};
}
(mkIf (cfg.users != { }) {
systemd.services = mapAttrs' (_: usercfg:
(lib.mkIf (cfg.users != { }) {
systemd.services = lib.mapAttrs' (_: usercfg:
let username = usercfg.home.username;
in nameValuePair ("home-manager-${utils.escapeSystemdPath username}") {
in lib.nameValuePair
"home-manager-${utils.escapeSystemdPath username}" {
description = "Home Manager environment for ${username}";
wantedBy = [ "multi-user.target" ];
wants = [ "nix-daemon.socket" ];
@ -61,7 +60,7 @@ in {
sed = "${pkgs.gnused}/bin/sed";
exportedSystemdVariables = concatStringsSep "|" [
exportedSystemdVariables = lib.concatStringsSep "|" [
"DBUS_SESSION_BUS_ADDRESS"
"DISPLAY"
"WAYLAND_DISPLAY"