feat: Enable Nix shell

Also add a script to automate this process by creating a JSON file based
on the current state of the relevant channel
<https://github.com/linz/geostore/pull/2130/files>.
This commit is contained in:
Victor Engmark 2022-10-16 19:40:16 +13:00
parent 1544a89249
commit 321991c470
4 changed files with 72 additions and 1 deletions

2
.gitignore vendored
View File

@ -2,5 +2,5 @@ ACTIVATION
.authcode
*aax
*jpg
*json
*-chapters.json
Audiobook/*

41
bump-nixpkgs.bash Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
shopt -s failglob inherit_errexit
if [[ $# -ne 1 ]]; then
cat >&2 <<EOF
bump-nixpkgs.bash: Update nixpkgs.json with latest info from given release
Usage:
./bump-nixpkgs.bash RELEASE
Example:
./bump-nixpkgs.bash 22.05
Bumps nixpkgs within the 22.05 release.
EOF
exit 2
fi
release="$1"
cleanup() {
rm --force --recursive "$working_dir"
}
trap cleanup EXIT
working_dir="$(mktemp --directory)"
intermediate_file="${working_dir}/1.json"
full_file="${working_dir}/2.json"
target_file=./nixpkgs.json
curl "https://api.github.com/repos/NixOS/nixpkgs/git/refs/heads/release-${release}" |
jq '{name: (.ref | split("/")[-1] + "-" + (now|strflocaltime("%Y-%m-%dT%H-%M-%SZ"))), url: ("https://github.com/NixOS/nixpkgs/archive/" + .object.sha + ".tar.gz")}' >"$intermediate_file"
jq '. + {sha256: $hash}' --arg hash "$(nix-prefetch-url --unpack "$(jq --raw-output .url "$intermediate_file")")" "$intermediate_file" >"$full_file"
if diff <(jq 'del(.name)' "$full_file") <(jq 'del(.name)' "$target_file"); then
echo "No change; aborting." >&2
else
mv "$full_file" "$target_file"
fi

5
nixpkgs.json Normal file
View File

@ -0,0 +1,5 @@
{
"name": "release-22.05-2022-10-16T19-25-26Z",
"url": "https://github.com/NixOS/nixpkgs/archive/945a85cb7ee31f5f8c49432d77b610b777662d4f.tar.gz",
"sha256": "0bvxw6lzi7n8vxr3dqcjmbypr8c7wzhz0flgmjlbswix8wmbyh0j"
}

25
shell.nix Normal file
View File

@ -0,0 +1,25 @@
let
pkgs =
import (
fetchTarball (
builtins.fromJSON (
builtins.readFile ./nixpkgs.json
)
)
) {
};
in
pkgs.mkShell {
packages = [
pkgs.alejandra
pkgs.bashInteractive
pkgs.cacert
pkgs.gitFull
pkgs.gitlint
pkgs.gnumake
pkgs.nix
pkgs.nixos-rebuild
pkgs.nodePackages.prettier
pkgs.pre-commit
];
}