2
2
set -euo pipefail
3
3
4
4
# This script does the following:
5
- # - Update all flake inputs, including nixpkgs
5
+ # - When called without arguments, update all flake inputs, including nixpkgs.
6
+ # - When called with a version argument, set input `nixpkgs` in `flake.nix` to the
7
+ # specified version and only update this input.
6
8
# - Print version updates of pinned pkgs like so:
7
9
# Pkg updates in nixpkgs unstable:
8
10
# bitcoin: 0.20.0 -> 0.21.1
@@ -39,23 +41,11 @@ if [[ $forceRun ]] && ! git diff --quiet ../flake.{nix,lock}; then
39
41
exit 1
40
42
fi
41
43
42
- # Support Nix >=2.19
43
- {
44
- versionGreaterThanOrEqual () {
45
- [[ $1 != $( echo -e " $1 \n$2 " | sort -V | head -n1) || $1 == " $2 " ]]
46
- }
47
- nixVersion=$( nix --version | cut -d\ -f 3)
48
- if versionGreaterThanOrEqual " $nixVersion " 2.19; then
49
- # https://nixos.org/manual/nix/stable/release-notes/rl-2.19#:~:text=nix%20flake%20update
50
- nixUpdateArg=--flake
51
- else
52
- nixUpdateArg=
53
- fi
54
- }
55
-
56
- echo " Updating flake 'nixos-search'"
57
- nix flake update $nixUpdateArg ../test/nixos-search
58
- echo
44
+ if [[ ! $nixosVersion ]]; then
45
+ echo " Updating flake 'nixos-search'"
46
+ nix flake update --flake ../test/nixos-search
47
+ echo
48
+ fi
59
49
60
50
versions=$( nix eval --json -f update-flake.nix versions)
61
51
@@ -65,8 +55,10 @@ versions=$(nix eval --json -f update-flake.nix versions)
65
55
echo " Updating main flake"
66
56
if [[ $nixosVersion ]]; then
67
57
sed -Ei " s|(nixpkgs.url = .*nixos-)[^\" ]+|\1$nixosVersion |" ../flake.nix
58
+ nix flake update nixpkgs --flake ..
59
+ else
60
+ nix flake update --flake ..
68
61
fi
69
- nix flake update $nixUpdateArg ..
70
62
71
63
echo
72
64
nix eval --raw -f update-flake.nix --argstr prevVersions " $versions " showUpdates; echo
0 commit comments