Skip to content

Commit

Permalink
flake.nix: get USER from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Oct 5, 2023
1 parent 6c1456e commit 6e3a5c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@
homeManager = (mkHomeConfig {
inherit system;
hostname = "devShell";
homePath = "/tmp";
username = "home";
homeDirectory = "/tmp/home";
# Needs to run with `--impure` flag
username = builtins.getEnv "USER";
extraModules = [{
home.stateVersion = "23.11";
# Disable some modules
Expand Down Expand Up @@ -232,20 +233,13 @@
{
devShells.default = pkgs.mkShell {
shellHook = ''
# Home Manager checks if the USER environment variable matches
# username
OLD_USER="$USER"
export USER=${homeManager.config.home.username}
export HOME=${homeManager.config.home.homeDirectory}
mkdir -p "$HOME"
trap "rm -rf $HOME" EXIT
${homeManager.activationPackage}/activate
export USER="$OLD_USER"
unset OLD_USER
zsh -l && exit 0
'';
};
Expand Down
2 changes: 1 addition & 1 deletion lib/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ in
{ hostname
, username ? "thiagoko"
, homePath ? "/home"
, homeDirectory ? "${homePath}/${username}"
, configPosfix ? "Projects/nix-configs"
, configuration ? ../home-manager
, deviceType ? "desktop"
Expand All @@ -95,7 +96,6 @@ in
}:
let
pkgs = nixpkgs.legacyPackages.${system};
homeDirectory = "${homePath}/${username}";
in
{
homeConfigurations.${hostname} = homeManagerConfiguration {
Expand Down

0 comments on commit 6e3a5c5

Please sign in to comment.