Created
March 1, 2022 09:39
-
-
Save Mic92/891cdff1912670f71f8df7a4e9b811c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/.envrc b/.envrc | |
index 8aaa78e..1d47631 100644 | |
--- a/.envrc | |
+++ b/.envrc | |
@@ -7,6 +7,17 @@ watch_dir nix | |
watch_file default.nix BUILD.nix | |
# Build and load the devshell | |
-out=$(nix-build -A shell --no-out-link) | |
+layout_dir=$(direnv_layout_dir) | |
+[[ -d "$layout_dir" ]] || mkdir -p "$layout_dir" | |
+if [[ ! -f "$layout_dir/last-build" | |
+ || "$layout_dir/last-build" -ot BUILD.nix | |
+ || "$layout_dir/last-build" -ot default.nix | |
+ || "$layout_dir/last-build" -ot nix/sources.json | |
+ || "$layout_dir/last-build" -ot nix/sources.nix | |
+ || "$layout_dir/last-build" -ot nix/default.nix | |
+ ]]; then | |
+ nix-build --builders '' -A shell --out-link "$layout_dir/shell" | |
+ touch "$layout_dir/last-build" | |
+fi | |
# shellcheck disable=SC1091 | |
-source "$out/env.bash" | |
+source "$layout_dir/shell/env.bash" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment