From f91f71b59e70d27eff81ab61af7db23282b1a302 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Wed, 28 Aug 2024 19:29:03 +0200 Subject: [PATCH] direnv: provide example config, update Readme The recommended direnv config is now shipped as an example file, allowing to just copy it for using. Readme is updated accordingly. The recommended NixOS config for direnv now uses the recommended nix-community use_flake hook as well. --- .envrc.example | 2 ++ README.md | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 .envrc.example diff --git a/.envrc.example b/.envrc.example new file mode 100644 index 000000000..58527a766 --- /dev/null +++ b/.envrc.example @@ -0,0 +1,2 @@ +use flake . --impure --allow-dirty --no-write-lock-file +build_channels_dir diff --git a/README.md b/README.md index 8f7ddf499..098874150 100644 --- a/README.md +++ b/README.md @@ -39,11 +39,15 @@ Automatically enter the dev shell with direnv Use `direnv` to automatically enter the dev shell when you change to the fc-nixos directory. +A recommended direnv config is shipped in `.envrc.example` to use it in your repo checkout just +`cp .envrc{.example,} && direnv allow`. + +We recommend the usage of the [nix-community/nix-direnv](https://github.com/nix-community/nix-direnv) hook +instead of the one shipped by direnv itself. To set it up with `home-manager`, see: https://github.com/nix-community/nix-direnv?tab=readme-ov-file#via-home-manager -Without home-manager --------------------- +### Without home-manager On a NixOS machine, enabling `programs.direnv.enable` should be enough. @@ -54,18 +58,14 @@ Add `/etc/local/nixos/dev_vm.nix`, for example: nix.extraOptions = '' keep-outputs = true ''; - programs.direnv.enable = true; + programs.direnv = { + enable = true; + nix-direnv.enable = true; + }; } Rebuild the system, close the shell/tmux session and log in again. -In `fc-nixos`, add an `.envrc` file like: - - use flake . --impure --allow-dirty - build_channels_dir - -Then, run `direnv allow` to build and enter the dev shell. - Run `direnv allow` again if the dev shell disappears or doesn't reload automatically.