nix-bitcoin/helper
Erik Arvstedt af115d746b
internal scripts: use pinned, cached pkgs
Instead of setting up the script PATH via nix-shell, use
`nix shell` with inputs from the nix-bitcoin flake.
Advantages:
- Uses the nixpkgs version from the nix-bitcoin flake instead of
  `<nixpkgs>` from the user env (NIX_PATH), so the script runtime
  env is reproducible.
- The pkg derivations for the runtime env are cached, which greatly
  increases script startup speed.

This commit was generated by running the following script inside the
repo root dir:

def transform(path, src)
  if src =~ /#! *nix-shell +-i +bash +-p +(.*)/
    pkgs = $1
    if src =~ /^.*?(set -e.*?pipefail)\n/
      set_statement = $1
      src.sub!($&, '')
    end
    src.sub!(/\A.*?#! *nix-shell.*?\n/m, '')

    parents = ([ '..' ] * (path.split('/').count - 1)).join('/')

    [
      '#!/usr/bin/env bash',
      *set_statement,
      %(. "${BASH_SOURCE[0]%/*}/#{parents}/helper/run-in-nix-env" "#{pkgs}" "$@"),
      nil,
      src
    ].join("\n")
  end
end

Dir['**/*.sh'].each do |f|
  src = File.read(f)
  if new_src = transform(f, src)
    puts "Changed file #{f}"
    File.write(f, new_src)
  end
end
2022-08-28 23:49:12 +02:00
..
fetch-release shellcheck: fix lint of scripts in /helper 2022-08-28 18:25:37 +02:00
key-jonasnick.bin Update jonasnick's gpg key 2020-07-08 12:03:57 +00:00
makeShell.nix deployment shell: add command `build-config` 2022-07-17 22:17:48 +02:00
push-release.sh shellcheck: fix lint of scripts in /helper 2022-08-28 18:25:37 +02:00
run-in-nix-env internal scripts: use pinned, cached pkgs 2022-08-28 23:49:12 +02:00
update-fixed-output-derivation.sh shellcheck: fix lint of scripts in /helper 2022-08-28 18:25:37 +02:00
update-flake.nix update-flake.nix: fix stable pkgs selection 2022-06-27 22:19:06 +02:00
update-flake.sh test: add test `nixosSearch` 2021-12-12 16:21:02 +01:00