-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckVersion.nix
36 lines (29 loc) · 1.1 KB
/
checkVersion.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ stdenv, writeScriptBin }:
writeScriptBin "checkVersion" ''
#!${stdenv.shell}
# Small script to check package version in given nix channel
getChannel() {
n=1
while read -r line; do
# Check if the line contains the substring "nixos-"
if [[ $line = *"nixos-"* ]]; then
# Cut everything after "</a>"
curStr="''${line%%</a>*}"
# Cut everything before the last ">"
curStr="''${curStr##*>}"
printf " %s: %s\n" "$n" "$curStr"
# Build array to reference the correct string after selection
releaseArr[$n]="$curStr"
((n++))
fi
done < <(curl -s https://nixos.org/channels/)
read -r -e -p "Enter 1-$n for the channel to search: " -i "" channelNumber
channelName=''${releaseArr[$channelNumber]}
}
getPackage() {
read -r -e -p "Enter the package name that you want to search, e.g. chromium: " -i "" packageName
}
getChannel
getPackage
nix eval -f channel:$channelName $packageName.name
''