mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-03 23:51:03 +01:00
nix: add support for nix profile
PR #2833 Co-authored-by: David Arnold <dar@xoe.solutions> Co-authored-by: Florian Franzen <Florian.Franzen@gmail.com>
This commit is contained in:
parent
171702dd88
commit
2f58d0a3de
6 changed files with 101 additions and 52 deletions
|
|
@ -259,8 +259,18 @@ in
|
|||
cleanOldGen
|
||||
|
||||
if [[ ! -v oldGenPath || "$oldGenPath" != "$newGenPath" ]] ; then
|
||||
_i "Creating profile generation %s" "$newGenNum"
|
||||
$DRY_RUN_CMD nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath"
|
||||
_i "Creating profile generation %s" $newGenNum
|
||||
if [[ -e "$genProfilePath"/manifest.json ]] ; then
|
||||
# Remove all packages from "$genProfilePath"
|
||||
# `nix profile remove '.*' --profile "$genProfilePath"` was not working, so here is a workaround:
|
||||
nix profile list --profile "$genProfilePath" \
|
||||
| cut -d ' ' -f 4 \
|
||||
| xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG --profile "$genProfilePath"
|
||||
$DRY_RUN_CMD nix profile install $VERBOSE_ARG --profile "$genProfilePath" "$newGenPath"
|
||||
else
|
||||
$DRY_RUN_CMD nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath"
|
||||
fi
|
||||
|
||||
$DRY_RUN_CMD ln -Tsf $VERBOSE_ARG "$newGenPath" "$newGenGcPath"
|
||||
else
|
||||
_i "No change so reusing latest profile generation %s" "$oldGenNum"
|
||||
|
|
|
|||
|
|
@ -578,17 +578,36 @@ in
|
|||
if config.submoduleSupport.externalPackageInstall
|
||||
then
|
||||
''
|
||||
if nix-env -q | grep '^home-manager-path$'; then
|
||||
$DRY_RUN_CMD nix-env -e home-manager-path
|
||||
if [[ -e "$nixProfilePath"/manifest.json ]] ; then
|
||||
nix profile list \
|
||||
| { grep 'home-manager-path$' || test $? = 1; } \
|
||||
| awk -F ' ' '{ print $4 }' \
|
||||
| cut -d ' ' -f 4 \
|
||||
| xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG
|
||||
else
|
||||
if nix-env -q | grep '^home-manager-path$'; then
|
||||
$DRY_RUN_CMD nix-env -e home-manager-path
|
||||
fi
|
||||
fi
|
||||
''
|
||||
else
|
||||
''
|
||||
if ! $DRY_RUN_CMD nix-env -i ${cfg.path} ; then
|
||||
if [[ -e "$nixProfilePath"/manifest.json ]] ; then
|
||||
INSTALL_CMD="nix profile install"
|
||||
LIST_CMD="nix profile list"
|
||||
REMOVE_CMD_SYNTAX='nix profile remove {number | store path}'
|
||||
else
|
||||
INSTALL_CMD="nix-env -i"
|
||||
LIST_CMD="nix-env -q"
|
||||
REMOVE_CMD_SYNTAX='nix-env -e {package name}'
|
||||
fi
|
||||
|
||||
if ! $DRY_RUN_CMD $INSTALL_CMD ${cfg.path} ; then
|
||||
echo
|
||||
_iError $'Oops, nix-env failed to install your new Home Manager profile!\n\nPerhaps there is a conflict with a package that was installed using\n"nix-env -i"? Try running\n\n nix-env -q\n\nand if there is a conflicting package you can remove it with\n\n nix-env -e {package name}\n\nThen try activating your Home Manager configuration again.'
|
||||
_iError $'Oops, Nix failed to install your new Home Manager profile!\n\nPerhaps there is a conflict with a package that was installed using\n"%s"? Try running\n\n %s\n\nand if there is a conflicting package you can remove it with\n\n %s\n\nThen try activating your Home Manager configuration again.' "$INSTALL_CMD" "$LIST_CMD" "$REMOVE_CMD_SYNTAX"
|
||||
exit 1
|
||||
fi
|
||||
unset INSTALL_CMD LIST_CMD REMOVE_CMD_SYNTAX
|
||||
''
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ function setupVars() {
|
|||
local profilesPath="$nixStateDir/profiles/per-user/$USER"
|
||||
local gcPath="$nixStateDir/gcroots/per-user/$USER"
|
||||
|
||||
declare -gr nixProfilePath="$profilesPath/profile"
|
||||
declare -gr genProfilePath="$profilesPath/home-manager"
|
||||
declare -gr newGenPath="@GENERATION_DIR@";
|
||||
declare -gr newGenGcPath="$gcPath/current-home"
|
||||
|
|
|
|||
|
|
@ -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: 2022-01-02 11:55+0100\n"
|
||||
"POT-Creation-Date: 2022-03-26 15:08+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -29,35 +29,35 @@ msgstr ""
|
|||
msgid "Creating profile generation %s"
|
||||
msgstr ""
|
||||
|
||||
#: modules/files.nix:266
|
||||
#: modules/files.nix:276
|
||||
msgid "No change so reusing latest profile generation %s"
|
||||
msgstr ""
|
||||
|
||||
#: modules/home-environment.nix:589
|
||||
#: modules/home-environment.nix:607
|
||||
msgid ""
|
||||
"Oops, nix-env failed to install your new Home Manager profile!\n"
|
||||
"Oops, Nix failed to install your new Home Manager profile!\n"
|
||||
"\n"
|
||||
"Perhaps there is a conflict with a package that was installed using\n"
|
||||
"\"nix-env -i\"? Try running\n"
|
||||
"\"%s\"? Try running\n"
|
||||
"\n"
|
||||
" nix-env -q\n"
|
||||
" %s\n"
|
||||
"\n"
|
||||
"and if there is a conflicting package you can remove it with\n"
|
||||
"\n"
|
||||
" nix-env -e {package name}\n"
|
||||
" %s\n"
|
||||
"\n"
|
||||
"Then try activating your Home Manager configuration again."
|
||||
msgstr ""
|
||||
|
||||
#: modules/home-environment.nix:620
|
||||
#: modules/home-environment.nix:639
|
||||
msgid "Activating %s"
|
||||
msgstr ""
|
||||
|
||||
#: modules/lib-bash/activation-init.sh:30
|
||||
#: modules/lib-bash/activation-init.sh:31
|
||||
msgid "Sanity checking oldGenNum and oldGenPath"
|
||||
msgstr ""
|
||||
|
||||
#: modules/lib-bash/activation-init.sh:33
|
||||
#: modules/lib-bash/activation-init.sh:34
|
||||
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"
|
||||
|
|
@ -73,26 +73,26 @@ msgid ""
|
|||
"and trying home-manager switch again. Good luck!"
|
||||
msgstr ""
|
||||
|
||||
#: modules/lib-bash/activation-init.sh:50
|
||||
#: modules/lib-bash/activation-init.sh:51
|
||||
msgid "Starting Home Manager activation"
|
||||
msgstr ""
|
||||
|
||||
#: modules/lib-bash/activation-init.sh:54
|
||||
#: modules/lib-bash/activation-init.sh:55
|
||||
msgid "Sanity checking Nix"
|
||||
msgstr ""
|
||||
|
||||
#: modules/lib-bash/activation-init.sh:60
|
||||
#: modules/lib-bash/activation-init.sh:61
|
||||
msgid "This is a dry run"
|
||||
msgstr ""
|
||||
|
||||
#: modules/lib-bash/activation-init.sh:63
|
||||
#: modules/lib-bash/activation-init.sh:64
|
||||
msgid "This is a live run"
|
||||
msgstr ""
|
||||
|
||||
#: modules/lib-bash/activation-init.sh:68
|
||||
#: modules/lib-bash/activation-init.sh:69
|
||||
msgid "Using Nix version: %s"
|
||||
msgstr ""
|
||||
|
||||
#: modules/lib-bash/activation-init.sh:71
|
||||
#: modules/lib-bash/activation-init.sh:72
|
||||
msgid "Activation variables:"
|
||||
msgstr ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue