1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46: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

@ -1,8 +1,7 @@
{ config, lib, pkgs, ... }:
with lib;
let
inherit (lib) literalExpression mkOption types;
inherit (config.home) stateVersion;
@ -114,7 +113,7 @@ let
layout = mkOption {
type = with types; nullOr str;
default =
if versionAtLeast config.home.stateVersion "19.09"
if lib.versionAtLeast config.home.stateVersion "19.09"
then null
else "us";
defaultText = literalExpression "null";
@ -148,7 +147,7 @@ let
variant = mkOption {
type = with types; nullOr str;
default =
if versionAtLeast config.home.stateVersion "19.09"
if lib.versionAtLeast config.home.stateVersion "19.09"
then null
else "";
defaultText = literalExpression "null";
@ -167,10 +166,10 @@ let
in
{
meta.maintainers = [ maintainers.rycee ];
meta.maintainers = [ lib.maintainers.rycee ];
imports = [
(mkRemovedOptionModule [ "home" "sessionVariableSetter" ] ''
(lib.mkRemovedOptionModule [ "home" "sessionVariableSetter" ] ''
Session variables are now always set through the shell. This is
done automatically if the shell configuration is managed by Home
Manager. If not, then you must source the
@ -223,7 +222,7 @@ in
home.keyboard = mkOption {
type = types.nullOr keyboardSubModule;
default = if versionAtLeast stateVersion "21.11" then null else { };
default = if lib.versionAtLeast stateVersion "21.11" then null else { };
defaultText = literalExpression ''
"{ }" for state version < 21.11,
"null" for state version 21.11
@ -355,7 +354,7 @@ in
home.emptyActivationPath = mkOption {
internal = true;
type = types.bool;
default = versionAtLeast stateVersion "22.11";
default = lib.versionAtLeast stateVersion "22.11";
defaultText = literalExpression ''
false for state version < 22.11,
true for state version 22.11
@ -370,7 +369,7 @@ in
};
home.activation = mkOption {
type = hm.types.dagOf types.str;
type = lib.hm.types.dagOf types.str;
default = {};
example = literalExpression ''
{
@ -475,7 +474,7 @@ in
'';
};
home.preferXdgDirectories = mkEnableOption "" // {
home.preferXdgDirectories = lib.mkEnableOption "" // {
description = ''
Whether to make programs use XDG directories whenever supported.
'';
@ -502,7 +501,7 @@ in
config.home.enableNixpkgsReleaseCheck
&& hmRelease != nixpkgsRelease;
in
optional releaseMismatch ''
lib.optional releaseMismatch ''
You are using
Home Manager version ${hmRelease} and
@ -520,11 +519,11 @@ in
'';
home.username =
mkIf (versionOlder config.home.stateVersion "20.09")
(mkDefault (builtins.getEnv "USER"));
lib.mkIf (lib.versionOlder config.home.stateVersion "20.09")
(lib.mkDefault (builtins.getEnv "USER"));
home.homeDirectory =
mkIf (versionOlder config.home.stateVersion "20.09")
(mkDefault (builtins.getEnv "HOME"));
lib.mkIf (lib.versionOlder config.home.stateVersion "20.09")
(lib.mkDefault (builtins.getEnv "HOME"));
home.profileDirectory =
if config.submoduleSupport.enable
@ -540,7 +539,7 @@ in
home.sessionVariables =
let
maybeSet = n: v: optionalAttrs (v != null) { ${n} = v; };
maybeSet = n: v: lib.optionalAttrs (v != null) { ${n} = v; };
in
(maybeSet "LANG" cfg.language.base)
//
@ -577,7 +576,7 @@ in
${config.lib.shell.exportAll cfg.sessionVariables}
'' + lib.optionalString (cfg.sessionPath != [ ]) ''
export PATH="$PATH''${PATH:+:}${concatStringsSep ":" cfg.sessionPath}"
export PATH="$PATH''${PATH:+:}${lib.concatStringsSep ":" cfg.sessionPath}"
'' + cfg.sessionVariablesExtra;
};
@ -586,7 +585,7 @@ in
# The entry acting as a boundary between the activation script's "check" and
# the "write" phases. This is where we commit to attempting to actually
# activate the configuration.
home.activation.writeBoundary = hm.dag.entryAnywhere ''
home.activation.writeBoundary = lib.hm.dag.entryAnywhere ''
if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then
_i "Creating new profile generation"
run nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath"
@ -610,7 +609,7 @@ in
# In case the user has moved from a user-install of Home Manager
# to a submodule managed one we attempt to uninstall the
# `home-manager-path` package if it is installed.
home.activation.installPackages = hm.dag.entryAfter ["writeBoundary"] (
home.activation.installPackages = lib.hm.dag.entryAfter ["writeBoundary"] (
if config.submoduleSupport.externalPackageInstall
then
''
@ -676,10 +675,10 @@ in
_iNote "Activating %s" "${res.name}"
${res.data}
'';
sortedCommands = hm.dag.topoSort cfg.activation;
sortedCommands = lib.hm.dag.topoSort cfg.activation;
activationCmds =
if sortedCommands ? result then
concatStringsSep "\n" (map mkCmd sortedCommands.result)
lib.concatStringsSep "\n" (map mkCmd sortedCommands.result)
else
abort ("Dependency cycle in activation script: "
+ builtins.toJSON sortedCommands);
@ -708,7 +707,7 @@ in
else
":$(${pkgs.coreutils}/bin/dirname $(${pkgs.coreutils}/bin/readlink -m $(type -p nix-env)))"
)
+ optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH";
+ lib.optionalString (!cfg.emptyActivationPath) "\${PATH:+:}$PATH";
activationScript = pkgs.writeShellScript "activation-script" ''
set -eu
@ -722,8 +721,8 @@ in
${builtins.readFile ./lib-bash/activation-init.sh}
if [[ ! -v SKIP_SANITY_CHECKS ]]; then
checkUsername ${escapeShellArg config.home.username}
checkHomeDirectory ${escapeShellArg config.home.homeDirectory}
checkUsername ${lib.escapeShellArg config.home.username}
checkHomeDirectory ${lib.escapeShellArg config.home.homeDirectory}
fi
# Create a temporary GC root to prevent collection during activation.
@ -732,7 +731,7 @@ in
${activationCmds}
${optionalString (!config.uninstall) ''
${lib.optionalString (!config.uninstall) ''
# Create the "current generation" GC root.
run --silence nix-store --realise "$newGenPath" --add-root "$currentGenGcPath"