diff --git a/dist/main/index.js b/dist/main/index.js index fc9d5291..652f280b 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -7957,11 +7957,26 @@ async function execToVariable(command, args, options) { async function registerPostBuildHook(cachixBin, daemonDir) { const postBuildHookScriptPath = `${daemonDir}/post-build-hook.sh`; await fs.writeFile(postBuildHookScriptPath, ` - #!/bin/sh + #!/usr/bin/env bash set -eu set -f # disable globbing + PUSH_FILTER="${pushFilter}" + + filterPaths() { + local regex=$1 + local paths=$2 + + for path in $paths; do + echo $path | grep -vEe $regex + done | xargs + } + + if [ -n "$PUSH_FILTER" ]; then + OUT_PATHS=$(filterPaths $PUSH_FILTER "$OUT_PATHS") + fi + exec ${cachixBin} daemon push \ --socket ${daemonDir}/daemon.sock \ $OUT_PATHS diff --git a/dist/main/push-paths.sh b/dist/main/push-paths.sh index 35ab55ff..5a565fba 100755 --- a/dist/main/push-paths.sh +++ b/dist/main/push-paths.sh @@ -3,11 +3,20 @@ set -euo pipefail cachix=$1 cachixArgs=${2:--j8} cache=$3 pathsToPush=$4 pushFilter=$5 -if [[ $pathsToPush == "" ]]; then +filterPaths() { + local regex=$1 + local paths=$2 + + for path in $paths; do + echo $path | grep -vEe $regex + done | xargs +} + +if [[ -z $pathsToPush ]]; then pathsToPush=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh)) - if [[ $pushFilter != "" ]]; then - pathsToPush=$(echo "$pathsToPush" | grep -vEe "$pushFilter") + if [[ -n $pushFilter ]]; then + pathsToPush=$(filterPaths $pushFilter "$pathsToPush") fi fi diff --git a/src/main.ts b/src/main.ts index 564db3c7..82598840 100644 --- a/src/main.ts +++ b/src/main.ts @@ -276,11 +276,26 @@ async function execToVariable(command: string, args?: string[], options?: exec.E async function registerPostBuildHook(cachixBin: string, daemonDir: string) { const postBuildHookScriptPath = `${daemonDir}/post-build-hook.sh`; await fs.writeFile(postBuildHookScriptPath, ` - #!/bin/sh + #!/usr/bin/env bash set -eu set -f # disable globbing + PUSH_FILTER="${pushFilter}" + + filterPaths() { + local regex=$1 + local paths=$2 + + for path in $paths; do + echo $path | grep -vEe $regex + done | xargs + } + + if [ -n "$PUSH_FILTER" ]; then + OUT_PATHS=$(filterPaths $PUSH_FILTER "$OUT_PATHS") + fi + exec ${cachixBin} daemon push \ --socket ${daemonDir}/daemon.sock \ $OUT_PATHS