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

support updating multiple flake directories simultaneously #98

Closed
wants to merge 1 commit into from
Closed
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: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
uses: DeterminateSystems/update-flake-lock@vX
with:
inputs: input1 input2 input3
path-to-flake-dir: 'nix/' # in this example our flake doesn't sit at the root of the repository, it sits under 'nix/flake.nix'
flake-dirs: 'nix/' # in this example our flake doesn't sit at the root of the repository, it sits under 'nix/flake.nix'
```

## Example using a different Git user
Expand Down
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ inputs:
required: false
default: "update_flake_lock_action"
path-to-flake-dir:
description: 'The path of the directory containing `flake.nix` file within your repository. Useful when `flake.nix` cannot reside at the root of your repository.'
description: 'Deprecated. Use flake-dirs instead. The path of the directory containing `flake.nix` file within your repository. Useful when `flake.nix` cannot reside at the root of your repository.'
required: false
default: ''
flake-dirs:
description: 'A space-separated list of directories containing `flake.nix` files within your repository. Useful when you have multiple flakes in your repository.'
required: false
default: ''
pr-title:
Expand Down Expand Up @@ -154,6 +158,7 @@ runs:
TARGETS: ${{ inputs.inputs }}
COMMIT_MSG: ${{ inputs.commit-msg }}
PATH_TO_FLAKE_DIR: ${{ inputs.path-to-flake-dir }}
FLAKE_DIRS: ${{ inputs.flake-dirs }}
- name: Save PR Body as file
uses: DamianReeves/[email protected]
with:
Expand Down
33 changes: 22 additions & 11 deletions update-flake-lock.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ -n "$PATH_TO_FLAKE_DIR" ]]; then
cd "$PATH_TO_FLAKE_DIR"
fi
update(){
if [[ -n "${TARGETS:-}" ]]; then
inputs=()
for input in $TARGETS; do
inputs+=("--update-input" "$input")
done
nix "${options[@]}" flake lock "${inputs[@]}" --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
else
nix "${options[@]}" flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
fi
}


options=()
if [[ -n "$NIX_OPTIONS" ]]; then
if [[ -n "${NIX_OPTIONS:-}" ]]; then
for option in $NIX_OPTIONS; do
options+=("${option}")
done
fi

if [[ -n "$TARGETS" ]]; then
inputs=()
for input in $TARGETS; do
inputs+=("--update-input" "$input")
done
nix "${options[@]}" flake lock "${inputs[@]}" --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
if [[ -n "${PATH_TO_FLAKE_DIR:-}" ]]; then
cd "$PATH_TO_FLAKE_DIR"
update
elif [[ -n "${FLAKE_DIRS:-}" ]]; then
for flake_dir in $FLAKE_DIRS; do
cd "$flake_dir"
update
done
else
nix "${options[@]}" flake update --commit-lock-file --commit-lockfile-summary "$COMMIT_MSG"
update
fi