Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flakes support #127

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.');
Expand Down
14 changes: 12 additions & 2 deletions dist/main/push-paths.sh
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.');
}
Expand Down