From cae54dc45c0d61c99c1dc8b04bc42f36c76f9771 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 13 Mar 2023 23:16:03 +0100 Subject: [PATCH] home-manager: change default configuration home This changes the default configuration location for Home Manager configurations from $XDG_CONFIG_HOME/nixpkgs to $XDG_CONFIG_HOME/home-manager The old location is still supported but using it will trigger a warning message. Fixes #3640 --- docs/faq.adoc | 5 ++- docs/man-configuration.xml | 6 +-- docs/man-home-manager.xml | 6 ++- docs/nix-flakes.adoc | 10 ++--- docs/release-notes/rl-2305.adoc | 11 +++++ docs/usage.adoc | 13 ++++-- home-manager/home-manager | 72 ++++++++++++++++++++++---------- home-manager/install.nix | 2 +- home-manager/po/home-manager.pot | 59 +++++++++++++++----------- modules/po/hm-modules.pot | 20 ++++----- 10 files changed, 132 insertions(+), 72 deletions(-) diff --git a/docs/faq.adoc b/docs/faq.adoc index 64886880..e8b86649 100644 --- a/docs/faq.adoc +++ b/docs/faq.adoc @@ -72,7 +72,10 @@ For example, if you have two machines, called "kronos" and "rhea" on which you w - `rhea-jane.nix`, and - `common.nix` -in your repository. On the kronos and rhea machines you can then make `~jane/.config/nixpkgs/home.nix` be a symbolic link to the corresponding file in your configuration repository. +in your repository. +On the kronos and rhea machines you can then make +`~jane/.config/home-manager/home.nix` +be a symbolic link to the corresponding file in your configuration repository. The `kronos-jane.nix` and `rhea-jane.nix` files follow the format diff --git a/docs/man-configuration.xml b/docs/man-configuration.xml index 42962a75..ce35feb7 100644 --- a/docs/man-configuration.xml +++ b/docs/man-configuration.xml @@ -13,12 +13,12 @@ Description - - The file ~/.config/nixpkgs/home.nix contains the + + The file ~/.config/home-manager/home.nix contains the declarative specification of your Home Manager configuration. The command home-manager takes this file and realises the user environment configuration specified therein. - + Options diff --git a/docs/man-home-manager.xml b/docs/man-home-manager.xml index 1a2fe68e..49c8ac61 100644 --- a/docs/man-home-manager.xml +++ b/docs/man-home-manager.xml @@ -200,7 +200,9 @@ Description This command updates the user environment so that it corresponds to the - configuration specified in ~/.config/nixpkgs/home.nix or ~/.config/nixpkgs/flake.nix. + configuration specified in + $XDG_CONFIG_HOME/home-manager/home.nix or + $XDG_CONFIG_HOME/home-manager/flake.nix. All operations using this tool expects a sub-command that indicates the @@ -434,7 +436,7 @@ Indicates the path to the Home Manager configuration file. If not given, - $XDG_CONFIG_HOME/nixpkgs/home.nix is used. + $XDG_CONFIG_HOME/home-manager/home.nix is used. diff --git a/docs/nix-flakes.adoc b/docs/nix-flakes.adoc index 2520e8ef..73556d93 100644 --- a/docs/nix-flakes.adoc +++ b/docs/nix-flakes.adoc @@ -118,9 +118,9 @@ and `nixpkgs` url to `github:NixOS/nixpkgs/nixos-22.11`. * The Home Manager library is exported by the flake under `lib.hm`. -* You can use the above `flake.nix` as a template in `~/.config/nixpkgs` by +* You can use the above `flake.nix` as a template in `~/.config/home-manager` by [source,console] -$ nix flake new ~/.config/nixpkgs -t github:nix-community/home-manager +$ nix flake new ~/.config/home-manager -t github:nix-community/home-manager ==== 2. Install Home Manager and apply the configuration by @@ -129,9 +129,9 @@ $ nix flake new ~/.config/nixpkgs -t github:nix-community/home-manager $ nix run #homeConfigurations.jdoe.activationPackage + Substitute `` with the flake URI of the configuration flake. -If `flake.nix` resides in `~/.config/nixpkgs`, -`` may be `~/.config/nixpkgs` -as a Git tree or `path:~/.config/nixpkgs` if not. +If `flake.nix` resides in `~/.config/home-manager`, +`` may be `~/.config/home-manager` +as a Git tree or `path:~/.config/home-manager` if not. 3. Since the release `21.05`, building a flake-based configuration is as simple as diff --git a/docs/release-notes/rl-2305.adoc b/docs/release-notes/rl-2305.adoc index 720aa300..b2156e9c 100644 --- a/docs/release-notes/rl-2305.adoc +++ b/docs/release-notes/rl-2305.adoc @@ -19,6 +19,17 @@ in your configuration then you must change it to [source,nix] programs.firefox.profiles.myprofile.extensions = [ foo bar ]; +* The default configuration location has been changed from +`~/.config/nixpkgs/home.nix` to `~/.config/home-manager/home.nix`. ++ +Similarly, if you are using a Nix flake based setup +then the default flake file location has changed from +`~/.config/nixpkgs/flake.nix` to `~/.config/home-manager/flake.nix`. ++ +The old location will continue to work but using it will trigger a warning message. +We changed the default configuration location to avoid confusion about +which files belong to Home Manager and which belong to Nixpkgs. + [[sec-release-23.05-state-version-changes]] === State Version Changes diff --git a/docs/usage.adoc b/docs/usage.adoc index adac7b72..08cf0903 100644 --- a/docs/usage.adoc +++ b/docs/usage.adoc @@ -1,7 +1,14 @@ [[ch-usage]] == Using Home Manager -Your use of Home Manager is centered around the configuration file, which is typically found at `~/.config/nixpkgs/home.nix`. +Your use of Home Manager is centered around the configuration file, +which is typically found at `~/.config/home-manager/home.nix` in the standard installation +or `~/.config/home-manager/flake.nix` in a Nix flake based installation. + +[NOTE] +The default configuration used to be placed in `~/.config/nixpkgs`ΒΈ +so you may see references to that elsewhere. +The old directory still works but Home Manager will print a warning message when used. This configuration file can be _built_ and _activated_. @@ -18,7 +25,7 @@ then building it, for example using `home-manager build`, will result in an erro ---- $ home-manager build error: A definition for option `programs.emacs.enable' is not of type `boolean'. Definition values: -- In `/home/jdoe/.config/nixpkgs/home.nix': "yes" +- In `/home/jdoe/.config/home-manager/home.nix': "yes" (use '--show-trace' to show detailed location information) ---- @@ -32,7 +39,7 @@ Once a configuration is successfully built, it can be activated. The activation [[sec-usage-configuration]] === Configuration Example -A fresh install of Home Manager will generate a minimal `~/.config/nixpkgs/home.nix` file containing something like +A fresh install of Home Manager will generate a minimal `~/.config/home-manager/home.nix` file containing something like [source,nix] ---- diff --git a/home-manager/home-manager b/home-manager/home-manager index d758653d..eaa1287d 100644 --- a/home-manager/home-manager +++ b/home-manager/home-manager @@ -56,29 +56,42 @@ function setWorkDir() { # an error message and exit with an error code. function setConfigFile() { if [[ -v HOME_MANAGER_CONFIG ]] ; then - if [[ ! -e "$HOME_MANAGER_CONFIG" ]] ; then - _i "No configuration file found at %s" \ + if [[ -e "$HOME_MANAGER_CONFIG" ]] ; then + HOME_MANAGER_CONFIG="$(realpath "$HOME_MANAGER_CONFIG")" + else + _i 'No configuration file found at %s' \ "$HOME_MANAGER_CONFIG" >&2 exit 1 fi + elif [[ ! -v HOME_MANAGER_CONFIG ]]; then + local configHome="${XDG_CONFIG_HOME:-$HOME/.config}" + local hmConfigHome="$configHome/home-manager" + local nixpkgsConfigHome="$configHome/nixpkgs" + local defaultConfFile="$hmConfigHome/home.nix" + local configFlake - HOME_MANAGER_CONFIG="$(realpath "$HOME_MANAGER_CONFIG")" - return - fi - - local defaultConfFile="${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix" - local confFile - for confFile in "$defaultConfFile" \ - "$HOME/.nixpkgs/home.nix" ; do - if [[ -e "$confFile" ]] ; then - HOME_MANAGER_CONFIG="$(realpath "$confFile")" - return + if [[ -e "$defaultConfFile" ]]; then + configFile="$defaultConfFile" + elif [[ -e "$nixpkgsConfigHome/home.nix" ]]; then + configFile="$nixpkgsConfigHome/home.nix" + # translators: The first '%s' specifier will be replaced by either + # 'home.nix' or 'flake.nix'. + _iWarn $'Keeping your Home Manager %s in %s is deprecated,\nplease move it to %s' \ + 'home.nix' "$nixpkgsConfigHome" "$hmConfigHome" >&2 + elif [[ -e "$HOME/.nixpkgs/home.nix" ]]; then + configFile="$HOME/.nixpkgs/home.nix" + _iWarn $'Keeping your Home Manager %s in %s is deprecated,\nplease move it to %s' \ + 'home.nix' "$HOME/.nixpkgs" "$hmConfigHome" >&2 fi - done - _i "No configuration file found. Please create one at %s" \ - "$defaultConfFile" >&2 - exit 1 + if [[ $configFile ]]; then + HOME_MANAGER_CONFIG="$(realpath "$configFile")" + else + _i 'No configuration file found. Please create one at %s' \ + "$defaultConfFile" >&2 + exit 1 + fi + fi } function setHomeManagerNixPath() { @@ -111,9 +124,24 @@ function setHomeManagerPathVariables() { } function setFlakeAttribute() { - local configFlake="${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/flake.nix" - if [[ -z $FLAKE_ARG && ! -v HOME_MANAGER_CONFIG && -e "$configFlake" ]]; then - FLAKE_ARG="$(dirname "$(readlink -f "$configFlake")")" + if [[ -z $FLAKE_ARG && ! -v HOME_MANAGER_CONFIG ]]; then + local configHome="${XDG_CONFIG_HOME:-$HOME/.config}" + local hmConfigHome="$configHome/home-manager" + local nixpkgsConfigHome="$configHome/nixpkgs" + + local configFlake + + if [[ -e "$hmConfigHome/flake.nix" ]]; then + configFlake="$hmConfigHome/flake.nix" + elif [[ -e "$nixpkgsConfigHome/flake.nix" ]]; then + configFlake="$nixpkgsConfigHome/flake.nix" + _iWarn $'Keeping your Home Manager %s in %s is deprecated,\nplease move it to %s' \ + 'flake.nix' "$nixpkgsConfigHome" "$hmConfigHome" >&2 + fi + + if [[ -v configFlake ]]; then + FLAKE_ARG="$(dirname "$(readlink -f "$configFlake")")" + fi fi if [[ -n "$FLAKE_ARG" ]]; then @@ -121,7 +149,7 @@ function setFlakeAttribute() { case $FLAKE_ARG in *#*) local name="${FLAKE_ARG#*#}" - ;; + ;; *) local name="$USER" # Check both long and short hostnames; long first to preserve @@ -134,7 +162,7 @@ function setFlakeAttribute() { fi fi done - ;; + ;; esac export FLAKE_CONFIG_URI="$flake#homeConfigurations.\"$name\"" fi diff --git a/home-manager/install.nix b/home-manager/install.nix index f4bcbb3f..7cbd9160 100644 --- a/home-manager/install.nix +++ b/home-manager/install.nix @@ -15,7 +15,7 @@ in runCommand "home-manager-install" { shellHook = '' ${hmBashLibInit} - confFile="''${XDG_CONFIG_HOME:-$HOME/.config}/nixpkgs/home.nix" + confFile="''${XDG_CONFIG_HOME:-$HOME/.config}/home-manager/home.nix" if [[ ! -e $confFile ]]; then echo diff --git a/home-manager/po/home-manager.pot b/home-manager/po/home-manager.pot index a6a77c7f..a947668b 100644 --- a/home-manager/po/home-manager.pot +++ b/home-manager/po/home-manager.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Home Manager\n" "Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n" -"POT-Creation-Date: 2023-03-07 23:36+0100\n" +"POT-Creation-Date: 2023-03-14 23:10+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,23 +18,32 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" -#: home-manager/home-manager:60 +#: home-manager/home-manager:62 msgid "No configuration file found at %s" msgstr "" -#: home-manager/home-manager:79 +#. translators: The first '%s' specifier will be replaced by either +#. 'home.nix' or 'flake.nix'. +#: home-manager/home-manager:79 home-manager/home-manager:83 +#: home-manager/home-manager:138 +msgid "" +"Keeping your Home Manager %s in %s is deprecated,\n" +"please move it to %s" +msgstr "" + +#: home-manager/home-manager:90 msgid "No configuration file found. Please create one at %s" msgstr "" -#: home-manager/home-manager:146 +#: home-manager/home-manager:174 msgid "Can't inspect options of a flake configuration" msgstr "" -#: home-manager/home-manager:185 +#: home-manager/home-manager:213 msgid "Can't instantiate a flake configuration" msgstr "" -#: home-manager/home-manager:258 +#: home-manager/home-manager:286 msgid "" "There is %d unread and relevant news item.\n" "Read it by running the command \"%s news\"." @@ -44,80 +53,80 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: home-manager/home-manager:272 +#: home-manager/home-manager:300 msgid "Unknown \"news.display\" setting \"%s\"." msgstr "" -#: home-manager/home-manager:279 +#: home-manager/home-manager:307 #, sh-format msgid "Please set the $EDITOR environment variable" msgstr "" -#: home-manager/home-manager:294 +#: home-manager/home-manager:322 msgid "Cannot run build in read-only directory" msgstr "" -#: home-manager/home-manager:378 +#: home-manager/home-manager:406 msgid "No generation with ID %s" msgstr "" -#: home-manager/home-manager:380 +#: home-manager/home-manager:408 msgid "Cannot remove the current generation %s" msgstr "" -#: home-manager/home-manager:382 +#: home-manager/home-manager:410 msgid "Removing generation %s" msgstr "" -#: home-manager/home-manager:401 +#: home-manager/home-manager:429 msgid "No generations to expire" msgstr "" -#: home-manager/home-manager:412 +#: home-manager/home-manager:440 msgid "No home-manager packages seem to be installed." msgstr "" -#: home-manager/home-manager:469 +#: home-manager/home-manager:497 msgid "Unknown argument %s" msgstr "" -#: home-manager/home-manager:485 +#: home-manager/home-manager:513 msgid "This will remove Home Manager from your system." msgstr "" -#: home-manager/home-manager:488 +#: home-manager/home-manager:516 msgid "This is a dry run, nothing will actually be uninstalled." msgstr "" -#: home-manager/home-manager:492 +#: home-manager/home-manager:520 msgid "Really uninstall Home Manager?" msgstr "" -#: home-manager/home-manager:498 +#: home-manager/home-manager:526 msgid "Switching to empty Home Manager configuration..." msgstr "" -#: home-manager/home-manager:525 +#: home-manager/home-manager:553 msgid "Yay!" msgstr "" -#: home-manager/home-manager:530 +#: home-manager/home-manager:558 msgid "Home Manager is uninstalled but your home.nix is left untouched." msgstr "" -#: home-manager/home-manager:695 +#: home-manager/home-manager:723 msgid "%s: unknown option '%s'" msgstr "" -#: home-manager/home-manager:696 +#: home-manager/home-manager:724 msgid "Run '%s --help' for usage help" msgstr "" -#: home-manager/home-manager:730 +#: home-manager/home-manager:758 msgid "expire-generations expects one argument, got %d." msgstr "" -#: home-manager/home-manager:752 +#: home-manager/home-manager:780 msgid "Unknown command: %s" msgstr "" diff --git a/modules/po/hm-modules.pot b/modules/po/hm-modules.pot index 8bbcc221..5c9a7078 100644 --- a/modules/po/hm-modules.pot +++ b/modules/po/hm-modules.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Home Manager Modules\n" "Report-Msgid-Bugs-To: https://github.com/nix-community/home-manager/issues\n" -"POT-Creation-Date: 2023-03-07 23:36+0100\n" +"POT-Creation-Date: 2023-03-14 23:10+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -53,15 +53,15 @@ msgstr "" msgid "Activating %s" msgstr "" -#: modules/lib-bash/activation-init.sh:18 +#: modules/lib-bash/activation-init.sh:16 msgid "Migrating profiles from %s to %s" msgstr "" -#: modules/lib-bash/activation-init.sh:77 +#: modules/lib-bash/activation-init.sh:75 msgid "Sanity checking oldGenNum and oldGenPath" msgstr "" -#: modules/lib-bash/activation-init.sh:80 +#: modules/lib-bash/activation-init.sh:78 msgid "" "The previous generation number and path are in conflict! These\n" "must be either both empty or both set but are now set to\n" @@ -77,26 +77,26 @@ msgid "" "and trying home-manager switch again. Good luck!" msgstr "" -#: modules/lib-bash/activation-init.sh:97 +#: modules/lib-bash/activation-init.sh:95 msgid "Starting Home Manager activation" msgstr "" -#: modules/lib-bash/activation-init.sh:101 +#: modules/lib-bash/activation-init.sh:99 msgid "Sanity checking Nix" msgstr "" -#: modules/lib-bash/activation-init.sh:107 +#: modules/lib-bash/activation-init.sh:105 msgid "This is a dry run" msgstr "" -#: modules/lib-bash/activation-init.sh:111 +#: modules/lib-bash/activation-init.sh:109 msgid "This is a live run" msgstr "" -#: modules/lib-bash/activation-init.sh:118 +#: modules/lib-bash/activation-init.sh:116 msgid "Using Nix version: %s" msgstr "" -#: modules/lib-bash/activation-init.sh:121 +#: modules/lib-bash/activation-init.sh:119 msgid "Activation variables:" msgstr ""