Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

home-manager: enable nix run for activationPackage #1828

Closed
wants to merge 1 commit into from
Closed

home-manager: enable nix run for activationPackage #1828

wants to merge 1 commit into from

Conversation

ant-arctica
Copy link
Contributor

@ant-arctica ant-arctica commented Feb 24, 2021

Description

Adds a symlink from $out/activate to $out/bin/home-manager-generation in the home-manager-generation activationPackage.
This makes it possible for people who put their home-manager configuration in a flake (not as a part of a NixOS configuration)
to update their home with:
nix run flake#homeMangerConfigurations.<name>.activationPackage
Instead of with nix build <stuff> && ./result/activate which is more cumbersome, and pollutes your gcroots/auto with stray symlinks to your current folder.

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all.

[ ] Test cases updated/added. See example.

  • I don't think there are tests for activationPackage
  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

    • Added myself and the module files to .github/CODEOWNERS.

Symlink $out/activate to $out/bin/home-manager-generation in
activationPackage, so you can use nix run to build a generation
inside of a flake and then directly activate it.
Copy link
Member

@berbiche berbiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution 👍

This will be quite useful to many users.

@@ -552,6 +552,9 @@ in

cp ${activationScript} $out/activate

mkdir $out/bin
ln -s $out/activate $out/bin/home-manager-generation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ln -s $out/activate $out/bin/home-manager-generation
ln -s $out/activate $out/bin/activate

To have a similar API to NixOS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I tested it, nix run only tries to run $out/bin/<package-name> (that's why nix run nixpkgs#neovim doesn't work). So if the symlink is moved to a different location you can't run it automatically anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I forgot about this peculiarity of nix run. It's good to know meta.mainProgram exists now.
I usually always do nix shell nixpkgs#something -c some-program

@ant-arctica
Copy link
Contributor Author

Closed in favor of #1856

@ant-arctica ant-arctica closed this Mar 8, 2021
@ant-arctica ant-arctica deleted the nix-run-activationPackage branch April 15, 2021 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants