aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/by-name/di/direnv/module.nix4
-rwxr-xr-xmodules/by-name/di/direnv/pre-cache.sh26
2 files changed, 19 insertions, 11 deletions
diff --git a/modules/by-name/di/direnv/module.nix b/modules/by-name/di/direnv/module.nix
index 31c70dad..55a694cf 100644
--- a/modules/by-name/di/direnv/module.nix
+++ b/modules/by-name/di/direnv/module.nix
@@ -17,14 +17,14 @@
cfg = config.soispha.programs.direnv;
devshells = sources.loadFlake "devshells";
+ nixpkgs = sources.loadFlake "nixpkgs";
pre-cache = pkgs.runCommand "pre-cache.sh" {} ''
cat "${./pre-cache.sh}" > $out
substituteInPlace $out \
--replace-fail "%DEVSHELLS_REPO%" "${devshells}" \
- --replace-fail "%DEVSHELLS_REPO_REF%" "${devshells.sourceInfo.rev}"
-
+ --replace-fail "%DEVSHELLS_REPO_REF%" "${devshells.sourceInfo.rev}.${builtins.readFile "${nixpkgs}/.git-revision"}"
'';
in {
options.soispha.programs.direnv = {
diff --git a/modules/by-name/di/direnv/pre-cache.sh b/modules/by-name/di/direnv/pre-cache.sh
index 883689f1..d2174f98 100755
--- a/modules/by-name/di/direnv/pre-cache.sh
+++ b/modules/by-name/di/direnv/pre-cache.sh
@@ -39,7 +39,7 @@ _pre_cache_load_shell() {
_nix print-dev-env --profile "$tmp_profile" "$REPO#$lang" >"$lang_cache"
_nix_add_gcroot "$tmp_profile" "$profile"
- rm "$tmp_profile" "$tmp_profile"*
+ # rm "$tmp_profile" "$tmp_profile"* || true
fi
_pre_cache_log "Loaded dev-shell for $lang."
@@ -50,24 +50,32 @@ _pre_cache_build_shells() {
installables=""
for lang in "$@"; do
- new_part="$REPO#devShells.$system.$lang"
+ lang_cache="$final_cache/$lang"
- if [ -z "$installables" ]; then
- installables="$new_part"
- else
- installables="$installables $new_part"
+ if ! [ -f "$lang_cache" ]; then
+ new_part="$REPO#devShells.$system.$lang"
+
+ if [ -z "$installables" ]; then
+ installables="$new_part"
+ else
+ installables="$installables $new_part"
+ fi
fi
done
- # We want shell-spliting
- # shellcheck disable=SC2086
- _nix build --no-link $installables
+ if [ -n "$installables" ]; then
+ _pre_cache_log "Building '$installables'..."
+ # We want shell-spliting
+ # shellcheck disable=SC2086
+ _nix build --no-link $installables
+ fi
}
pre_cache_load() {
_pre_cache_preflight
+ # Build all not-yet build shells concurrently. That speeds up the initial load.
_pre_cache_build_shells "$@"
for lan in "$@"; do