2020-02-19 08:37:46 -08:00
|
|
|
let
|
2020-03-22 09:14:20 -07:00
|
|
|
# This is either a path to a local nix-bitcoin source or an attribute set to
|
|
|
|
# be used as the fetchurl argument.
|
|
|
|
nix-bitcoin-release = import ./nix-bitcoin-release.nix;
|
|
|
|
|
|
|
|
nix-bitcoin-path =
|
|
|
|
if builtins.isAttrs nix-bitcoin-release then nix-bitcoin-unpacked
|
|
|
|
else nix-bitcoin-release;
|
|
|
|
|
2020-02-19 08:37:46 -08:00
|
|
|
nixpkgs-path = (import "${toString nix-bitcoin-path}/pkgs/nixpkgs-pinned.nix").nixpkgs;
|
2021-03-16 04:45:18 -07:00
|
|
|
pkgs = import nixpkgs-path {};
|
|
|
|
nix-bitcoin = pkgs.callPackage nix-bitcoin-path {};
|
2020-02-26 08:11:23 -08:00
|
|
|
|
2020-03-22 09:14:20 -07:00
|
|
|
nix-bitcoin-unpacked = (import <nixpkgs> {}).runCommand "nix-bitcoin-src" {} ''
|
|
|
|
mkdir $out; tar xf ${builtins.fetchurl nix-bitcoin-release} -C $out
|
|
|
|
'';
|
2020-02-19 08:37:46 -08:00
|
|
|
in
|
2021-03-16 04:45:18 -07:00
|
|
|
with pkgs;
|
2020-02-19 08:37:46 -08:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "nix-bitcoin-environment";
|
|
|
|
|
2021-03-16 04:45:18 -07:00
|
|
|
path = lib.makeBinPath [ nix-bitcoin.extra-container ];
|
2020-02-19 08:37:46 -08:00
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
export NIX_PATH="nixpkgs=${nixpkgs-path}:nix-bitcoin=${toString nix-bitcoin-path}:."
|
2020-10-19 02:33:25 -07:00
|
|
|
export PATH="${path}''${PATH:+:}$PATH"
|
|
|
|
|
2021-03-16 04:45:17 -07:00
|
|
|
export NIX_BITCOIN_EXAMPLES_DIR="${toString ./.}"
|
|
|
|
|
2021-03-16 04:45:18 -07:00
|
|
|
fetch-release() {
|
|
|
|
${toString nix-bitcoin-path}/helper/fetch-release
|
|
|
|
}
|
2020-02-26 08:11:23 -08:00
|
|
|
|
2021-03-10 05:08:39 -08:00
|
|
|
krops-deploy() {
|
|
|
|
# Ensure strict permissions on secrets/ directory before rsyncing it to
|
|
|
|
# the target machine
|
|
|
|
chmod 700 ${toString ./secrets}
|
|
|
|
$(nix-build --no-out-link ${toString ./krops/deploy.nix})
|
|
|
|
}
|
|
|
|
|
2021-03-16 04:45:18 -07:00
|
|
|
# Print logo if
|
|
|
|
# 1. stdout is a TTY, i.e. we're not piping the output
|
|
|
|
# 2. the shell is interactive
|
|
|
|
if [[ -t 1 && $- == *i* ]]; then
|
|
|
|
${figlet}/bin/figlet "nix-bitcoin"
|
|
|
|
fi
|
|
|
|
|
2020-10-19 02:33:25 -07:00
|
|
|
(mkdir -p secrets; cd secrets; env -i ${nix-bitcoin.generate-secrets})
|
2020-03-29 09:21:12 -07:00
|
|
|
|
|
|
|
# Don't run this hook when another nix-shell is run inside this shell
|
|
|
|
unset shellHook
|
2020-02-19 08:37:46 -08:00
|
|
|
'';
|
|
|
|
}
|