diff --git a/action.yml b/action.yml index c6db4a06..5f9828d9 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,8 @@ inputs: description: 'Extra command-line arguments to pass to cachix. If empty, defaults to -j8' installCommand: description: 'Override the default cachix installation method' + useFlakes: + description: 'Use nix flakes (requires jq): input|runtime' branding: color: 'blue' icon: 'database' diff --git a/dist/main/index.js b/dist/main/index.js index f0695ca0..ea96f48f 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -4301,6 +4301,7 @@ const pushFilter = core.getInput('pushFilter'); const cachixArgs = core.getInput('cachixArgs'); const installCommand = core.getInput('installCommand') || "nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install"; +const useFlakes = core.getInput('useFlakes'); function setup() { return __awaiter(this, void 0, void 0, function* () { try { @@ -4347,7 +4348,7 @@ function upload() { core.info('Pushing is disabled as skipPush is set to true'); } else if (signingKey !== "" || authToken !== "") { - yield exec.exec(`${__dirname}/push-paths.sh`, ['cachix', cachixArgs, name, pathsToPush, pushFilter]); + yield exec.exec(`${__dirname}/push-paths.sh`, ['cachix', cachixArgs, name, pathsToPush, pushFilter, useFlakes]); } else { core.info('Pushing is disabled as signingKey nor authToken are set (or are empty?) in your YAML file.'); diff --git a/dist/main/push-paths.sh b/dist/main/push-paths.sh index 35ab55ff..d32e30f6 100755 --- a/dist/main/push-paths.sh +++ b/dist/main/push-paths.sh @@ -1,10 +1,20 @@ #!/usr/bin/env bash set -euo pipefail -cachix=$1 cachixArgs=${2:--j8} cache=$3 pathsToPush=$4 pushFilter=$5 +cachix=$1 cachixArgs=${2:--j8} cache=$3 pathsToPush=$4 pushFilter=$5 useFlakes=$6 if [[ $pathsToPush == "" ]]; then - pathsToPush=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh)) + case useFlakes in + input) + pathsToPush=$(nix flake archive --json | jq -r '.path,(.inputs|to_entries[].value.path)') + ;; + runtime) + pathsToPush=$(nix build --json | jq -r '.[].outputs | to_entries[].value') + ;; + *) + pathsToPush=$(comm -13 <(sort /tmp/store-path-pre-build) <("$(dirname "$0")"/list-nix-store.sh)) + ;; + esac if [[ $pushFilter != "" ]]; then pathsToPush=$(echo "$pathsToPush" | grep -vEe "$pushFilter") diff --git a/src/main.ts b/src/main.ts index 5e8cedba..05c9a159 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,7 @@ const cachixArgs = core.getInput('cachixArgs'); const installCommand = core.getInput('installCommand') || "nix-env --quiet -j8 -iA cachix -f https://cachix.org/api/v1/install"; +const useFlakes = core.getInput('useFlakes'); async function setup() { try { @@ -64,7 +65,7 @@ async function upload() { if (skipPush === 'true') { core.info('Pushing is disabled as skipPush is set to true'); } else if (signingKey !== "" || authToken !== "") { - await exec.exec(`${__dirname}/push-paths.sh`, ['cachix', cachixArgs, name, pathsToPush, pushFilter]); + await exec.exec(`${__dirname}/push-paths.sh`, ['cachix', cachixArgs, name, pathsToPush, pushFilter, useFlakes]); } else { core.info('Pushing is disabled as signingKey nor authToken are set (or are empty?) in your YAML file.'); }