From a3a96a74af5be83e500dce154a3556486c039ac3 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Thu, 5 Oct 2023 22:47:25 +0100 Subject: [PATCH] flake.nix: add devShell That is basically my Home-Manager configuration. --- flake.nix | 48 +++++++++++++++++++++++++++++++++- home-manager/editor/neovim.nix | 2 +- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index fe4fa51f..1053f9ac 100644 --- a/flake.nix +++ b/flake.nix @@ -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; @@ -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 } diff --git a/home-manager/editor/neovim.nix b/home-manager/editor/neovim.nix index a6320e67..22acd215 100644 --- a/home-manager/editor/neovim.nix +++ b/home-manager/editor/neovim.nix @@ -164,7 +164,7 @@ in ignore = {}, devicons = { enable = ${if cfg.enableIcons then "true" else "false"}, - highlight_dirname = false + highlight_dirname = false, }, mappings = { [''] = actions.edit,