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

install: allow customizing the shellHook #6195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions home-manager/install.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ home-manager, runCommand }:
{ home-manager, runCommand
, shellHook ? "exec ${home-manager}/bin/home-manager init --switch --no-flake"
}:

let

Expand All @@ -12,7 +14,7 @@ in runCommand "home-manager-install" {
propagatedBuildInputs = [ home-manager ];
preferLocalBuild = true;
shellHookOnly = true;
shellHook = "exec ${home-manager}/bin/home-manager init --switch --no-flake";
inherit shellHook;
} ''
${hmBashLibInit}
_iError 'This derivation is not buildable, please run it using nix-shell.'
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/standalone/alice-home-dotprofile.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ config, pkgs, ... }:

{
home.username = "alice";
home.homeDirectory = "/home/alice";
home.stateVersion = "24.11";
programs.home-manager.enable = true;

# Write .profile
home.file = {
".profile".text = ''
echo sourcing dotprofile
'';
};
}
6 changes: 6 additions & 0 deletions tests/integration/standalone/override-install.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ hmInstall ? (import <home-manager> { }).install }:
hmInstall.override {
shellHook = ''
exec home-manager init --switch --no-flake -b backup
'';
}
10 changes: 10 additions & 0 deletions tests/integration/standalone/standard-basics.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@
machine.succeed("test ! -e /home/alice/.local/state/home-manager")
machine.succeed("test ! -e /home/alice/.local/state/nix/profiles/home-manager")

with subtest("Home Manager Installation with preexisting dotfile"):
succeed_as_alice("touch /home/alice/.profile")

succeed_as_alice("cp ${
./alice-home-dotprofile.nix
} /home/alice/.config/home-manager/home.nix")

succeed_as_alice("nix-shell ${./override-install.nix}")
succeed_as_alice("test -e /home/alice/.profile.backup")

logout_alice()
'';
}
Loading