Skip to content

Commit

Permalink
flake.nix: add home-manager as devShell
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Oct 5, 2023
1 parent 1238aa2 commit b6b1bed
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
};
};

outputs = { self, nixpkgs, ... }@inputs:
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
let
inherit (import ./lib/attrsets.nix { inherit (nixpkgs) lib; }) recursiveMergeAttrs;
inherit (import ./lib/flake.nix inputs) mkGHActionsYAMLs mkRunCmd mkNixOSConfig mkHomeConfig;
Expand Down Expand Up @@ -190,5 +190,51 @@
"update-flakes-darwin"
"validate-flakes"
])

(flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
homeManager = (mkHomeConfig {
inherit system;
hostname = "devShell";
homePath = "/tmp";
username = "home";
extraModules = [{
# Disable systemd services/sockets/timers/etc.
systemd.user = {
automounts = pkgs.lib.mkForce { };
mounts = pkgs.lib.mkForce { };
paths = pkgs.lib.mkForce { };
services = pkgs.lib.mkForce { };
sessionVariables = pkgs.lib.mkForce { };
slices = pkgs.lib.mkForce { };
sockets = pkgs.lib.mkForce { };
targets = pkgs.lib.mkForce { };
timers = pkgs.lib.mkForce { };
};
}];
}).homeConfigurations.devShell;
in
{
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
'';
};
}))
]); # END recursiveMergeAttrs
}

0 comments on commit b6b1bed

Please sign in to comment.