bento: flake-update can only update a single input

This commit is contained in:
Solene Rapenne 2022-09-15 18:26:17 +02:00
parent bf98c6f469
commit 23ff8f94df
2 changed files with 20 additions and 3 deletions

View File

@ -169,6 +169,13 @@ Example of output:
x1 fcz1s2yp fcz1s2yp 💚 up to date 💚 (build 2m 37s)
```
## Update all flakes
With `bento flake-update` you can easily update your flakes recursively to the latest version.
A parameter can be added to only update a given source with, i.e to update all nixpkgs in the flakes `bento flake-update nixpkgs`.
# CAVEATS
- if you propagate a new version while a host is updating, it may be incorrectly seen as "up to date" because the log file deposited will be newer than the `last_time_changed` file

16
bento
View File

@ -3,7 +3,7 @@
# FUNCTION LIBRARIES
usage() {
cat <<EOF
usage: bento init | deploy | build [test|switch] | status [delay] | flake-update
usage: bento init | deploy | build [test|switch] | status [delay] | flake-update [input]
bento init
: create the layout for bento in the current directory
@ -17,8 +17,9 @@ bento build [test|switch]
bento status [delay]
: display information for remote hosts
bento flake-update
bento flake-update [input]
: recursively update flakes lock files
: with [input] parameter it only update the input passed as parameter
env NAME=someconfig bento deploy|build
: only build / deploy the system "someconfig"
@ -660,6 +661,7 @@ then
fi
# update flakes recursively
# $2 is an input name
if [ "$1" = "flake-update" ]
then
cd hosts || exit 5
@ -668,7 +670,15 @@ then
do
if [ -f "$directory/flake.nix" ]
then
nix flake update path:"$directory"
echo "$directory"
if [ -z "$2" ]
then
nix flake update path:"$directory"
else
cd "$directory" >/dev/null || exit 5
nix flake lock --update-input "$2"
cd - >/dev/null || exit 5
fi
fi
done