Use nix-direnv instead of lorri

This commit is contained in:
Charlotte Van Petegem 2020-07-07 15:37:15 +02:00
parent 789ffd218b
commit 32ba100ee4
2 changed files with 16 additions and 7 deletions

View file

@ -4,10 +4,8 @@
* Create a new `*.nix` file in the shells directory that describes the environment (this is the hard part).
* Execute `lorri init` in the base directory of your project. This will create a `.envrc` file and `shell.nix` file.
* Execute `use_nix > .envrc` to initialize the `.envrc` file.
* Edit the `shell.nix` file so that it contains `import /path/to/this/repo/shells/your-new-file.nix`.
* Execute `ln -s /path/to/correct/file.nix shell.nix`.
* For shells that have a shellHook that exports environment containing computed directories (e.g. the git root or the current working directory), add `eval "$shellHook"` to your `.envrc`.
* Execute `direnv allow` to load the `.envrc` file which in turn uses `lorri` to load your `shell.nix` file.
* Execute `direnv allow` to load the `.envrc` file which in turn loads your environment.

View file

@ -3,19 +3,30 @@
{
custom.zfs.homeLinks = [
{ path = ".local/share/direnv"; type = "cache"; }
{ path = ".cache/lorri"; type = "cache"; }
{ path = ".cache/direnv"; type = "cache"; }
];
nix.extraOptions = ''
keep-outputs = true
keep-derivations = true
'';
home-manager.users.charlotte = { ... }: {
programs.direnv = {
enable = true;
enableNixDirenvIntegration = true;
enableZshIntegration = true;
config = {
global = {
strict_env = true;
};
};
stdlib = ''
: ''${XDG_CACHE_HOME:=$HOME/.cache}
hash=$(echo -n $PWD | shasum | cut -d' ' -f 1)
direnv_layout_dir=$XDG_CACHE_HOME/direnv/layouts/"''$(echo -n $PWD | sed 's#/#-#g')/$hash"
mkdir -p "$direnv_layout_dir"
'';
};
services.lorri.enable = true;
};
}