From 321991c470db46d4c4fa3a668639acbe37a1324e Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Sun, 16 Oct 2022 19:40:16 +1300 Subject: [PATCH] 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 . --- .gitignore | 2 +- bump-nixpkgs.bash | 41 +++++++++++++++++++++++++++++++++++++++++ nixpkgs.json | 5 +++++ shell.nix | 25 +++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100755 bump-nixpkgs.bash create mode 100644 nixpkgs.json create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index ec72114..c0cce73 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ ACTIVATION .authcode *aax *jpg -*json +*-chapters.json Audiobook/* diff --git a/bump-nixpkgs.bash b/bump-nixpkgs.bash new file mode 100755 index 0000000..ac6762c --- /dev/null +++ b/bump-nixpkgs.bash @@ -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 <"$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 diff --git a/nixpkgs.json b/nixpkgs.json new file mode 100644 index 0000000..51bf6e1 --- /dev/null +++ b/nixpkgs.json @@ -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" +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..003eefc --- /dev/null +++ b/shell.nix @@ -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 + ]; + }