From 2069f62abca9f42d9f72825adf38115054246ef9 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 14 Dec 2021 19:51:16 +0100 Subject: [PATCH 01/10] krops: -> 1.26.2 Includes https://github.com/krebs/krops/commit/9fc8cbf8e826d4c8a118f37202ab3f335341082a Add krops/fetch-release.sh --- pkgs/krops/default.nix | 4 ++-- pkgs/krops/fetch-release.sh | 17 +++++++++++++++++ pkgs/krops/get-sha256.sh | 14 -------------- 3 files changed, 19 insertions(+), 16 deletions(-) create mode 100755 pkgs/krops/fetch-release.sh delete mode 100755 pkgs/krops/get-sha256.sh diff --git a/pkgs/krops/default.nix b/pkgs/krops/default.nix index a80ceba..a198095 100644 --- a/pkgs/krops/default.nix +++ b/pkgs/krops/default.nix @@ -3,8 +3,8 @@ let src = pkgs.fetchgit { url = "https://cgit.krebsco.de/krops"; - rev = "804c79a14dc8f81a602d31d5a1eed5f82b3f2457"; - sha256 = "1k20l7zqprsrm9s38xslr7190vssf4sjdprd9gh146hxlvln2qrf"; + rev = "1.26.2"; + sha256 = "0mzn213dh3pklvdzfpwi4nin4lncdap447zvl11j81r809jll76j"; }; in { lib = import "${src}/lib"; diff --git a/pkgs/krops/fetch-release.sh b/pkgs/krops/fetch-release.sh new file mode 100755 index 0000000..cf414c6 --- /dev/null +++ b/pkgs/krops/fetch-release.sh @@ -0,0 +1,17 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i bash -p git +set -euo pipefail + +archive_hash () { + repo=$1 + rev=$2 + nix-prefetch-url --unpack "https://github.com/${repo}/archive/${rev}.tar.gz" 2> /dev/null +} + +echo "Fetching latest version" +version=$( + git ls-remote --tags https://github.com/krebs/krops | cut -f 2 \ + | sed -E 's|refs/tags/||g; s|((v)?(.*))|\1 \3|g' | sort -k 2 -V | tail -1 | cut -f 1 -d' ' +) +echo "rev: ${version}" +echo "sha256: $(archive_hash krebs/krops $version)" diff --git a/pkgs/krops/get-sha256.sh b/pkgs/krops/get-sha256.sh deleted file mode 100755 index d7cd792..0000000 --- a/pkgs/krops/get-sha256.sh +++ /dev/null @@ -1,14 +0,0 @@ -#! /usr/bin/env nix-shell -#! nix-shell -i bash -p git -set -euo pipefail - -archive_hash () { - repo=$1 - rev=$2 - nix-prefetch-url --unpack "https://github.com/${repo}/archive/${rev}.tar.gz" 2> /dev/null -} - -echo "Fetching latest krops commit" -latest=$(git ls-remote https://github.com/krebs/krops master | cut -f 1) -echo "rev: ${latest}" -echo "sha256: $(archive_hash krebs/krops $latest)" From f13ffe014667376faeb0a0af6c7ab711d793bb90 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 14 Dec 2021 19:51:17 +0100 Subject: [PATCH 02/10] run-tests: make `nixosSearch` compatible with `--copy-src` --- test/lib/copy-src.sh | 2 +- test/lib/create-git-repo.sh | 13 +++++++++++++ test/run-tests.sh | 9 +++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 test/lib/create-git-repo.sh diff --git a/test/lib/copy-src.sh b/test/lib/copy-src.sh index 93be40c..39e6995 100644 --- a/test/lib/copy-src.sh +++ b/test/lib/copy-src.sh @@ -15,4 +15,4 @@ trap "atExit" EXIT rsync -a --delete --exclude='.git*' "$scriptDir/../" $tmp/src echo "Copied src" -_nixBitcoinInCopySrc=1 $tmp/src/test/run-tests.sh "${args[@]}" +_nixBitcoinInCopiedSrc=1 $tmp/src/test/run-tests.sh "${args[@]}" diff --git a/test/lib/create-git-repo.sh b/test/lib/create-git-repo.sh new file mode 100644 index 0000000..4f635c5 --- /dev/null +++ b/test/lib/create-git-repo.sh @@ -0,0 +1,13 @@ +# Create and maintain a minimal git repo at the root of the copied src +( + cd "$scriptDir/.." + amend=--amend + if [[ ! -e .git ]]; then + git init + amend= + fi + git add . + if ! git diff --quiet --cached; then + git commit -a $amend -m - + fi +) >/dev/null diff --git a/test/run-tests.sh b/test/run-tests.sh index 06ac514..f30c5a2 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -95,7 +95,7 @@ while :; do ;; --copy-src|-c) shift - if [[ ! $_nixBitcoinInCopySrc ]]; then + if [[ ! $_nixBitcoinInCopiedSrc ]]; then . "$scriptDir/lib/copy-src.sh" exit fi @@ -271,12 +271,17 @@ flake() { nixosSearch() { if ! checkFlakeSupport "nixosSearch"; then return; fi + if [[ $_nixBitcoinInCopiedSrc ]]; then + # flake-info requires that its target flake is under version control + . "$scriptDir/lib/create-git-repo.sh" + fi + if [[ $outLinkPrefix ]]; then # Add gcroots for flake-info nix build $scriptDir/nixos-search#flake-info -o "$outLinkPrefix-flake-info" fi echo "Running flake-info (nixos-search)" - nix run $scriptDir/nixos-search#flake-info -- flake ../. + nix run $scriptDir/nixos-search#flake-info -- flake "$scriptDir/.." } # A basic subset of tests to keep the total runtime within From d296b2d1fbeef02ebac41ccd8d24171650d4fd8d Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 14 Dec 2021 19:51:18 +0100 Subject: [PATCH 03/10] charge-lnd: remove unneeded use of `literalExample` --- modules/charge-lnd.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/charge-lnd.nix b/modules/charge-lnd.nix index 6f564dc..769b1ce 100644 --- a/modules/charge-lnd.nix +++ b/modules/charge-lnd.nix @@ -37,7 +37,7 @@ let policies = mkOption { type = types.lines; default = ""; - example = literalExample '' + example = '' [discourage-routing-out-of-balance] chan.max_ratio = 0.1 chan.min_capacity = 250000 From fbfb61210a699b22ea2cfff7cd64ea8786cee794 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 14 Dec 2021 19:51:19 +0100 Subject: [PATCH 04/10] rtl: use node package lockfile --- pkgs/rtl/composition.nix | 2 +- pkgs/rtl/default.nix | 10 +- pkgs/rtl/generate.sh | 47 ++-- pkgs/rtl/node-packages.nix | 517 +++++++++++++++++++------------------ pkgs/rtl/pkg.json | 3 - 5 files changed, 303 insertions(+), 276 deletions(-) delete mode 100644 pkgs/rtl/pkg.json diff --git a/pkgs/rtl/composition.nix b/pkgs/rtl/composition.nix index f49b28e..01c4b77 100644 --- a/pkgs/rtl/composition.nix +++ b/pkgs/rtl/composition.nix @@ -2,7 +2,7 @@ {pkgs ? import { inherit system; - }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-10_x"}: + }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}: let nodeEnv = import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix" { diff --git a/pkgs/rtl/default.nix b/pkgs/rtl/default.nix index ea6f456..b7931b7 100644 --- a/pkgs/rtl/default.nix +++ b/pkgs/rtl/default.nix @@ -1,5 +1,5 @@ -{ stdenv, pkgs, lib }: -lib.head (builtins.attrValues (import ./composition.nix { - inherit pkgs; - inherit (stdenv.hostPlatform) system; -})) +{ pkgs }: +let + nodePackages = import ./composition.nix { inherit pkgs; inherit (pkgs) nodejs; }; +in +nodePackages.package diff --git a/pkgs/rtl/generate.sh b/pkgs/rtl/generate.sh index 1a32cc1..8a1c256 100755 --- a/pkgs/rtl/generate.sh +++ b/pkgs/rtl/generate.sh @@ -1,31 +1,44 @@ #!/usr/bin/env nix-shell -#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq moreutils +#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq gnused set -euo pipefail TMPDIR="$(mktemp -d -p /tmp)" trap "rm -rf $TMPDIR" EXIT -# Get/verify source tarball version="0.11.2" +repo=https://github.com/Ride-The-Lightning/RTL + +# Fetch and verify source tarball +file=v${version}.tar.gz +url=$repo/archive/refs/tags/$file export GNUPGHOME=$TMPDIR gpg --keyserver hkps://keyserver.ubuntu.com --recv-key 3E9BD4436C288039CA827A9200C9E2BC2E45666F -wget -P $TMPDIR https://github.com/Ride-The-Lightning/RTL/archive/refs/tags/v${version}.tar.gz -wget -P $TMPDIR https://github.com/Ride-The-Lightning/RTL/releases/download/v${version}/v${version}.tar.gz.asc -gpg --verify $TMPDIR/v${version}.tar.gz.asc $TMPDIR/v${version}.tar.gz -shasum=$(sha256sum $TMPDIR/v${version}.tar.gz | cut -d\ -f1) +wget -P $TMPDIR $url +wget -P $TMPDIR $repo/releases/download/v${version}/$file.asc +gpg --verify $TMPDIR/$file.asc $TMPDIR/$file +hash=$(nix hash file $TMPDIR/$file) -# Run node2nix -mkdir $TMPDIR/package && tar xvf $TMPDIR/v${version}.tar.gz -C $TMPDIR/package --strip-components 1 -cp pkg.json $TMPDIR/pkg.json -node2nix --nodejs-10 -i $TMPDIR/pkg.json -c composition.nix --no-copy-node-env +# Extract source +src=$TMPDIR/src +mkdir $src +tar xvf $TMPDIR/$file -C $src --strip-components 1 >/dev/null -# Set node env import. -# The reason for not providing a custom node-env.nix file is the following: -# To be flakes-compatible, we have to locate the nixpgs source via `pkgs.path` instead of ``. -# This requires the `pkgs` variable which is available only in composition.nix, not in node-env.nix. +# Generate nix pkg +node2nix \ + --input $src/package.json \ + --lock $src/package-lock.json \ + --composition composition.nix \ + --no-copy-node-env + +# Use node-env.nix from nixpkgs nodeEnvImport='import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix"' sed -i "s|import ./node-env.nix|$nodeEnvImport|" composition.nix -# Use verified source in node-packages.nix -url="https://github.com/Ride-The-Lightning/RTL/archive/refs/tags/v$version.tar.gz" -sed -i '/packageName = "rtl";/!b;n;n;c\ src = fetchurl {\n url = "'$url'";\n sha256 = "'$shasum'";\n };' node-packages.nix +# Use the verified package src +read -d '' fetchurl < Date: Tue, 14 Dec 2021 19:51:20 +0100 Subject: [PATCH 05/10] cl-rest: use node package lockfile --- pkgs/cl-rest/composition.nix | 2 +- pkgs/cl-rest/default.nix | 10 +- pkgs/cl-rest/generate.sh | 47 ++-- pkgs/cl-rest/node-packages.nix | 429 ++++++++++++++++++++------------- 4 files changed, 291 insertions(+), 197 deletions(-) diff --git a/pkgs/cl-rest/composition.nix b/pkgs/cl-rest/composition.nix index f49b28e..01c4b77 100644 --- a/pkgs/cl-rest/composition.nix +++ b/pkgs/cl-rest/composition.nix @@ -2,7 +2,7 @@ {pkgs ? import { inherit system; - }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-10_x"}: + }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}: let nodeEnv = import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix" { diff --git a/pkgs/cl-rest/default.nix b/pkgs/cl-rest/default.nix index ea6f456..b7931b7 100644 --- a/pkgs/cl-rest/default.nix +++ b/pkgs/cl-rest/default.nix @@ -1,5 +1,5 @@ -{ stdenv, pkgs, lib }: -lib.head (builtins.attrValues (import ./composition.nix { - inherit pkgs; - inherit (stdenv.hostPlatform) system; -})) +{ pkgs }: +let + nodePackages = import ./composition.nix { inherit pkgs; inherit (pkgs) nodejs; }; +in +nodePackages.package diff --git a/pkgs/cl-rest/generate.sh b/pkgs/cl-rest/generate.sh index 002cd2e..d458a70 100755 --- a/pkgs/cl-rest/generate.sh +++ b/pkgs/cl-rest/generate.sh @@ -1,31 +1,44 @@ #!/usr/bin/env nix-shell -#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq moreutils +#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq gnused set -euo pipefail TMPDIR="$(mktemp -d -p /tmp)" trap "rm -rf $TMPDIR" EXIT -# Get/verify source tarball version="0.6.0" +repo=https://github.com/Ride-The-Lightning/c-lightning-REST + +# Fetch and verify source tarball +file=v${version}.tar.gz +url=$repo/archive/refs/tags/$file export GNUPGHOME=$TMPDIR gpg --keyserver hkps://keyserver.ubuntu.com --recv-key 3E9BD4436C288039CA827A9200C9E2BC2E45666F -wget -P $TMPDIR https://github.com/Ride-The-Lightning/c-lightning-REST/archive/refs/tags/v${version}.tar.gz -wget -P $TMPDIR https://github.com/Ride-The-Lightning/c-lightning-REST/releases/download/v${version}/v${version}.tar.gz.asc -gpg --verify $TMPDIR/v${version}.tar.gz.asc $TMPDIR/v${version}.tar.gz -shasum=$(sha256sum $TMPDIR/v${version}.tar.gz | cut -d\ -f1) +wget -P $TMPDIR $url +wget -P $TMPDIR $repo/releases/download/v${version}/$file.asc +gpg --verify $TMPDIR/$file.asc $TMPDIR/$file +hash=$(nix hash file $TMPDIR/$file) -# Run node2nix -mkdir $TMPDIR/package && tar xvf $TMPDIR/v${version}.tar.gz -C $TMPDIR/package --strip-components 1 -cp pkg.json $TMPDIR/pkg.json -node2nix --nodejs-10 -i $TMPDIR/pkg.json -c composition.nix --no-copy-node-env +# Extract source +src=$TMPDIR/src +mkdir $src +tar xvf $TMPDIR/$file -C $src --strip-components 1 >/dev/null -# Set node env import. -# The reason for not providing a custom node-env.nix file is the following: -# To be flakes-compatible, we have to locate the nixpgs source via `pkgs.path` instead of ``. -# This requires the `pkgs` variable which is available only in composition.nix, not in node-env.nix. +# Generate nix pkg +node2nix \ + --input $src/package.json \ + --lock $src/package-lock.json \ + --composition composition.nix \ + --no-copy-node-env + +# Use node-env.nix from nixpkgs nodeEnvImport='import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix"' sed -i "s|import ./node-env.nix|$nodeEnvImport|" composition.nix -# Use verified source in node-packages.nix -url="https://github.com/Ride-The-Lightning/c-lightning-REST/archive/refs/tags/v$version.tar.gz" -sed -i '/packageName = "c-lightning-rest";/!b;n;n;c\ src = fetchurl {\n url = "'$url'";\n sha256 = "'$shasum'";\n };' node-packages.nix +# Use the verified package src +read -d '' fetchurl < Date: Tue, 14 Dec 2021 19:51:21 +0100 Subject: [PATCH 06/10] spark-wallet: use node package lockfile --- pkgs/spark-wallet/default.nix | 13 +- pkgs/spark-wallet/generate.sh | 51 +- pkgs/spark-wallet/node-packages.nix | 1042 ++++++++++++++++----------- pkgs/spark-wallet/pkg.json | 3 - 4 files changed, 650 insertions(+), 459 deletions(-) delete mode 100644 pkgs/spark-wallet/pkg.json diff --git a/pkgs/spark-wallet/default.nix b/pkgs/spark-wallet/default.nix index ea6f456..4ed1bec 100644 --- a/pkgs/spark-wallet/default.nix +++ b/pkgs/spark-wallet/default.nix @@ -1,5 +1,8 @@ -{ stdenv, pkgs, lib }: -lib.head (builtins.attrValues (import ./composition.nix { - inherit pkgs; - inherit (stdenv.hostPlatform) system; -})) +{ pkgs }: +let + nodePackages = import ./composition.nix { inherit pkgs; }; +in +nodePackages.package.override { + # Required because spark-wallet uses `npm-shrinkwrap.json` as the lock file + reconstructLock = true; +} diff --git a/pkgs/spark-wallet/generate.sh b/pkgs/spark-wallet/generate.sh index 9a3f9c4..d869c2c 100755 --- a/pkgs/spark-wallet/generate.sh +++ b/pkgs/spark-wallet/generate.sh @@ -1,34 +1,49 @@ #!/usr/bin/env nix-shell -#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq moreutils +#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq moreutils gnused set -euo pipefail TMPDIR="$(mktemp -d -p /tmp)" trap "rm -rf $TMPDIR" EXIT -# Get/verify spark-wallet-npm.tgz version="0.3.1" +repo=https://github.com/shesek/spark-wallet + +# Fetch and verify source tarball +file=spark-wallet-${version}-npm.tgz +url=$repo/releases/download/v$version/$file export GNUPGHOME=$TMPDIR gpg --keyserver hkps://keyserver.ubuntu.com --recv-key FCF19B67866562F08A43AAD681F6104CD0F150FC -wget -P $TMPDIR https://github.com/shesek/spark-wallet/releases/download/v${version}/SHA256SUMS.asc -wget -P $TMPDIR https://github.com/shesek/spark-wallet/releases/download/v${version}/spark-wallet-${version}-npm.tgz -(cd $TMPDIR; gpg --verify $TMPDIR/SHA256SUMS.asc; sha256sum -c --ignore-missing $TMPDIR/SHA256SUMS.asc) -shasum=$(sha256sum $TMPDIR/spark-wallet-${version}-npm.tgz | cut -d\ -f1) +wget -P $TMPDIR $url +wget -P $TMPDIR $repo/releases/download/v$version/SHA256SUMS.asc +gpg --verify $TMPDIR/SHA256SUMS.asc +(cd $TMPDIR; sha256sum --check --ignore-missing SHA256SUMS.asc) +hash=$(nix hash file $TMPDIR/$file) + +# Extract source +src=$TMPDIR/src +mkdir $src +tar xvf $TMPDIR/$file -C $src --strip-components 1 >/dev/null # Make qrcode-terminal a strict dependency so that node2nix includes it in the package derivation. -tar xvf $TMPDIR/spark-wallet-*-npm.tgz -C $TMPDIR -jq '.dependencies["qrcode-terminal"] = .optionalDependencies["qrcode-terminal"]' $TMPDIR/package/package.json | sponge $TMPDIR/package/package.json +jq '.dependencies["qrcode-terminal"] = .optionalDependencies["qrcode-terminal"]' $src/package.json | sponge $src/package.json -# Run node2nix -cp pkg.json $TMPDIR/pkg.json -node2nix --nodejs-10 -i $TMPDIR/pkg.json -c composition.nix --no-copy-node-env +# Generate nix pkg +node2nix \ + --nodejs-10 \ + --input $src/package.json \ + --lock $src/npm-shrinkwrap.json \ + --composition composition.nix \ + --no-copy-node-env -# Set node env import. -# The reason for not providing a custom node-env.nix file is the following: -# To be flakes-compatible, we have to locate the nixpgs source via `pkgs.path` instead of ``. -# This requires the `pkgs` variable which is available only in composition.nix, not in node-env.nix. +# Use node-env.nix from nixpkgs nodeEnvImport='import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix"' sed -i "s|import ./node-env.nix|$nodeEnvImport|" composition.nix -# Use verified source in node-packages.nix -url="https://github.com/shesek/spark-wallet/releases/download/v$version/spark-wallet-$version-npm.tgz" -sed -i '/packageName = "spark-wallet";/!b;n;n;c\ src = fetchurl {\n url = "'$url'";\n sha256 = "'$shasum'";\n };' node-packages.nix +# Use the verified package src +read -d '' fetchurl < Date: Tue, 14 Dec 2021 19:51:22 +0100 Subject: [PATCH 07/10] rtl, cl-rest: add /bin to pkg output --- modules/rtl.nix | 5 +++-- pkgs/cl-rest/default.nix | 16 +++++++++++++--- pkgs/rtl/default.nix | 16 +++++++++++++--- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/modules/rtl.nix b/modules/rtl.nix index 095fe4a..5bbba94 100644 --- a/modules/rtl.nix +++ b/modules/rtl.nix @@ -105,6 +105,7 @@ let cfg = config.services.rtl; nbLib = config.nix-bitcoin.lib; + nbPkgs = config.nix-bitcoin.pkgs; secretsDir = config.nix-bitcoin.secretsDir; node = { isLnd, index }: '' @@ -223,7 +224,7 @@ in { install -D -o ${cfg.user} -g ${cfg.group} ${lnd.networkDir}/admin.macaroon \ '${cfg.dataDir}/macaroons/admin.macaroon' ''); - ExecStart = "${pkgs.nodejs}/bin/node ${config.nix-bitcoin.pkgs.rtl}/lib/node_modules/rtl/rtl"; + ExecStart = "${nbPkgs.rtl}/bin/rtl"; # Show "rtl" instead of "node" in the journal SyslogIdentifier = "rtl"; User = cfg.user; @@ -247,7 +248,7 @@ in { StateDirectory = "cl-rest"; # cl-rest reads the config file from the working directory WorkingDirectory = cl-rest.dataDir; - ExecStart = "${pkgs.nodejs}/bin/node ${config.nix-bitcoin.pkgs.cl-rest}/lib/node_modules/c-lightning-rest/cl-rest"; + ExecStart = "${nbPkgs.cl-rest}/bin/cl-rest"; # Show "cl-rest" instead of "node" in the journal SyslogIdentifier = "cl-rest"; User = cfg.user; diff --git a/pkgs/cl-rest/default.nix b/pkgs/cl-rest/default.nix index b7931b7..90cda20 100644 --- a/pkgs/cl-rest/default.nix +++ b/pkgs/cl-rest/default.nix @@ -1,5 +1,15 @@ -{ pkgs }: +{ pkgs, makeWrapper }: let - nodePackages = import ./composition.nix { inherit pkgs; inherit (pkgs) nodejs; }; + inherit (pkgs) nodejs; + nodePackages = import ./composition.nix { inherit pkgs nodejs; }; in -nodePackages.package +nodePackages.package.overrideAttrs (old: { + nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ + makeWrapper + ]; + + postInstall = '' + makeWrapper ${nodejs}/bin/node $out/bin/cl-rest \ + --add-flags $out/lib/node_modules/c-lightning-rest/cl-rest + ''; +}) diff --git a/pkgs/rtl/default.nix b/pkgs/rtl/default.nix index b7931b7..bc3605b 100644 --- a/pkgs/rtl/default.nix +++ b/pkgs/rtl/default.nix @@ -1,5 +1,15 @@ -{ pkgs }: +{ pkgs, makeWrapper }: let - nodePackages = import ./composition.nix { inherit pkgs; inherit (pkgs) nodejs; }; + inherit (pkgs) nodejs; + nodePackages = import ./composition.nix { inherit pkgs nodejs; }; in -nodePackages.package +nodePackages.package.overrideAttrs (old: { + nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ + makeWrapper + ]; + + postInstall = '' + makeWrapper ${nodejs}/bin/node $out/bin/rtl \ + --add-flags $out/lib/node_modules/rtl/rtl + ''; +}) From 5ab85cb2a5df7d91b52a1ffa1dc408077bfa24ce Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 14 Dec 2021 19:51:23 +0100 Subject: [PATCH 08/10] pkgs: add `meta` attr Also add more detailed `enable` option descriptions. --- modules/btcpayserver.nix | 2 +- modules/clightning.nix | 2 +- modules/electrs.nix | 2 +- modules/joinmarket.nix | 4 ++-- modules/lightning-loop.nix | 2 +- modules/lightning-pool.nix | 2 +- modules/liquid.nix | 2 +- modules/lnd.nix | 2 +- modules/rtl.nix | 2 +- pkgs/cl-rest/default.nix | 10 +++++++++- pkgs/clboss/default.nix | 2 +- pkgs/clightning-plugins/default.nix | 17 ++++++++++++++--- pkgs/joinmarket/default.nix | 8 ++++++++ pkgs/liquid-swap/default.nix | 9 ++++++++- pkgs/rtl/default.nix | 10 +++++++++- pkgs/secp256k1/default.nix | 4 ++-- pkgs/spark-wallet/default.nix | 10 +++++++++- 17 files changed, 70 insertions(+), 20 deletions(-) diff --git a/modules/btcpayserver.nix b/modules/btcpayserver.nix index 47b152e..2b55e5b 100644 --- a/modules/btcpayserver.nix +++ b/modules/btcpayserver.nix @@ -4,7 +4,7 @@ with lib; let options.services = { btcpayserver = { - enable = mkEnableOption "btcpayserver"; + enable = mkEnableOption "btcpayserver, a self-hosted Bitcoin payment processor"; address = mkOption { type = types.str; default = "127.0.0.1"; diff --git a/modules/clightning.nix b/modules/clightning.nix index 965ae81..e1c6569 100644 --- a/modules/clightning.nix +++ b/modules/clightning.nix @@ -3,7 +3,7 @@ with lib; let options.services.clightning = { - enable = mkEnableOption "clightning"; + enable = mkEnableOption "clightning, a Lightning Network implementation in C"; address = mkOption { type = types.str; default = "127.0.0.1"; diff --git a/modules/electrs.nix b/modules/electrs.nix index 3091da1..32e29b0 100644 --- a/modules/electrs.nix +++ b/modules/electrs.nix @@ -3,7 +3,7 @@ with lib; let options.services.electrs = { - enable = mkEnableOption "electrs"; + enable = mkEnableOption "electrs, an Electrum server implemented in Rust"; address = mkOption { type = types.str; default = "127.0.0.1"; diff --git a/modules/joinmarket.nix b/modules/joinmarket.nix index 053a376..3b18c6e 100644 --- a/modules/joinmarket.nix +++ b/modules/joinmarket.nix @@ -3,7 +3,7 @@ with lib; let options.services.joinmarket = { - enable = mkEnableOption "JoinMarket"; + enable = mkEnableOption "JoinMarket, a Bitcoin CoinJoin implementation"; payjoinAddress = mkOption { type = types.str; default = "127.0.0.1"; @@ -58,7 +58,7 @@ let inherit (nbLib) cliExec; yieldgenerator = { - enable = mkEnableOption "yield generator bot"; + enable = mkEnableOption "JoinMarket yield generator bot"; ordertype = mkOption { type = types.enum [ "reloffer" "absoffer" ]; default = "reloffer"; diff --git a/modules/lightning-loop.nix b/modules/lightning-loop.nix index 8d9039b..614d39f 100644 --- a/modules/lightning-loop.nix +++ b/modules/lightning-loop.nix @@ -3,7 +3,7 @@ with lib; let options.services.lightning-loop = { - enable = mkEnableOption "lightning-loop"; + enable = mkEnableOption "Lightning Loop, a non-custodial off/on chain bridge"; rpcAddress = mkOption { type = types.str; default = "localhost"; diff --git a/modules/lightning-pool.nix b/modules/lightning-pool.nix index 092a83f..d60ea3c 100644 --- a/modules/lightning-pool.nix +++ b/modules/lightning-pool.nix @@ -3,7 +3,7 @@ with lib; let options.services.lightning-pool = { - enable = mkEnableOption "lightning-pool"; + enable = mkEnableOption "Lightning Pool, a marketplace for inbound lightning liquidity "; rpcAddress = mkOption { type = types.str; default = "localhost"; diff --git a/modules/liquid.nix b/modules/liquid.nix index 352bf84..075b918 100644 --- a/modules/liquid.nix +++ b/modules/liquid.nix @@ -4,7 +4,7 @@ with lib; let options = { services.liquidd = { - enable = mkEnableOption "Liquid sidechain"; + enable = mkEnableOption "Liquid Bitcoin sidechain daemon"; address = mkOption { type = types.str; default = "127.0.0.1"; diff --git a/modules/lnd.nix b/modules/lnd.nix index 409f1a7..6a69483 100644 --- a/modules/lnd.nix +++ b/modules/lnd.nix @@ -3,7 +3,7 @@ with lib; let options.services.lnd = { - enable = mkEnableOption "Lightning Network Daemon"; + enable = mkEnableOption "Lightning Network daemon, a Lightning Network implementation in Go"; address = mkOption { type = types.str; default = "localhost"; diff --git a/modules/rtl.nix b/modules/rtl.nix index 5bbba94..f40a3f7 100644 --- a/modules/rtl.nix +++ b/modules/rtl.nix @@ -3,7 +3,7 @@ with lib; let options.services.rtl = { - enable = mkEnableOption "rtl"; + enable = mkEnableOption "Ride The Lightning, a web interface for lnd and clightning "; address = mkOption { type = types.str; default = "127.0.0.1"; diff --git a/pkgs/cl-rest/default.nix b/pkgs/cl-rest/default.nix index 90cda20..ca44d4c 100644 --- a/pkgs/cl-rest/default.nix +++ b/pkgs/cl-rest/default.nix @@ -1,4 +1,4 @@ -{ pkgs, makeWrapper }: +{ pkgs, lib, makeWrapper }: let inherit (pkgs) nodejs; nodePackages = import ./composition.nix { inherit pkgs nodejs; }; @@ -12,4 +12,12 @@ nodePackages.package.overrideAttrs (old: { makeWrapper ${nodejs}/bin/node $out/bin/cl-rest \ --add-flags $out/lib/node_modules/c-lightning-rest/cl-rest ''; + + meta = with lib; { + description = "REST API for C-Lightning"; + homepage = "https://github.com/Ride-The-Lightning/c-lightning-REST"; + license = licenses.mit; + maintainers = with maintainers; [ nixbitcoin earvstedt ]; + platforms = platforms.unix; + }; }) diff --git a/pkgs/clboss/default.nix b/pkgs/clboss/default.nix index 7c89db9..ba6de16 100644 --- a/pkgs/clboss/default.nix +++ b/pkgs/clboss/default.nix @@ -19,8 +19,8 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Automated C-Lightning Node Manager"; homepage = "https://github.com/ZmnSCPxj/clboss"; - maintainers = with maintainers; [ nixbitcoin ]; license = licenses.mit; + maintainers = with maintainers; [ nixbitcoin ]; platforms = platforms.linux; }; } diff --git a/pkgs/clightning-plugins/default.nix b/pkgs/clightning-plugins/default.nix index 42531e9..45498aa 100644 --- a/pkgs/clightning-plugins/default.nix +++ b/pkgs/clightning-plugins/default.nix @@ -13,19 +13,22 @@ let version = builtins.substring 0 7 src.rev; plugins = with nbPython3Packages; { - helpme = {}; - monitor = {}; + helpme = { description = "Walks you through setting up a c-lightning node, offering advice for common problems"; }; + monitor = { description = "Helps you analyze the health of your peers and channels"; }; prometheus = { + description = "Lightning node exporter for the prometheus timeseries server"; extraPkgs = [ prometheus_client ]; patchRequirements = "--replace prometheus-client==0.6.0 prometheus-client==0.11.0" + " --replace pyln-client~=0.9.3 pyln-client~=0.10.1"; }; - rebalance = {}; + rebalance = { description = "Keeps your channels balanced"; }; summary = { + description = "Prints a summary of the node status"; extraPkgs = [ packaging requests ]; }; zmq = { + description = "Publishes notifications via ZeroMQ to configured endpoints"; scriptName = "cl-zmq"; extraPkgs = [ twisted txzmq ]; }; @@ -58,6 +61,14 @@ let ''; passthru.path = "${drv}/${script}"; + + meta = with lib; { + inherit (plugin) description; + homepage = "https://github.com/lightningd/plugins"; + license = licenses.bsd3; + maintainers = with maintainers; [ nixbitcoin earvstedt ]; + platforms = platforms.unix; + }; }; in drv; diff --git a/pkgs/joinmarket/default.nix b/pkgs/joinmarket/default.nix index 931854d..6c620f2 100644 --- a/pkgs/joinmarket/default.nix +++ b/pkgs/joinmarket/default.nix @@ -54,4 +54,12 @@ stdenv.mkDerivation { # These files must be placed in the same dir as ob-watcher cp -r scripts/obwatch/{orderbook.html,sybil_attack_calculations.py,vendor} $obw ''; + + meta = with lib; { + description = "Bitcoin CoinJoin implementation"; + homepage = "https://github.com/JoinMarket-Org/joinmarket-clientserver"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ nixbitcoin ]; + platforms = platforms.unix; + }; } diff --git a/pkgs/liquid-swap/default.nix b/pkgs/liquid-swap/default.nix index 5eedc28..103e892 100644 --- a/pkgs/liquid-swap/default.nix +++ b/pkgs/liquid-swap/default.nix @@ -14,5 +14,12 @@ buildPythonPackage rec { installFlags = [ ".[CLI]" ]; # The tests unfortunately seem to require the PyQt for the GUI doCheck = false; -} + meta = with lib; { + description = "Swap issued assets on the Liquid network using confidential transactions"; + homepage = "https://github.com/Blockstream/liquid-swap"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ nixbitcoin ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/rtl/default.nix b/pkgs/rtl/default.nix index bc3605b..dfa909c 100644 --- a/pkgs/rtl/default.nix +++ b/pkgs/rtl/default.nix @@ -1,4 +1,4 @@ -{ pkgs, makeWrapper }: +{ pkgs, lib, makeWrapper }: let inherit (pkgs) nodejs; nodePackages = import ./composition.nix { inherit pkgs nodejs; }; @@ -12,4 +12,12 @@ nodePackages.package.overrideAttrs (old: { makeWrapper ${nodejs}/bin/node $out/bin/rtl \ --add-flags $out/lib/node_modules/rtl/rtl ''; + + meta = with lib; { + description = "A web interface for LND, c-lightning and Eclair"; + homepage = "https://github.com/Ride-The-Lightning/RTL"; + license = licenses.mit; + maintainers = with maintainers; [ nixbitcoin earvstedt ]; + platforms = platforms.unix; + }; }) diff --git a/pkgs/secp256k1/default.nix b/pkgs/secp256k1/default.nix index 2f9f28f..6dbffbc 100644 --- a/pkgs/secp256k1/default.nix +++ b/pkgs/secp256k1/default.nix @@ -19,8 +19,8 @@ stdenv.mkDerivation { meta = with lib; { description = "Optimized C library for EC operations on curve secp256k1"; homepage = "https://github.com/bitcoin-core/secp256k1"; - license = with licenses; [ mit ]; + license = licenses.mit; maintainers = with maintainers; [ nixbitcoin ]; - platforms = with platforms; unix; + platforms = platforms.unix; }; } diff --git a/pkgs/spark-wallet/default.nix b/pkgs/spark-wallet/default.nix index 4ed1bec..f4cf736 100644 --- a/pkgs/spark-wallet/default.nix +++ b/pkgs/spark-wallet/default.nix @@ -1,8 +1,16 @@ -{ pkgs }: +{ pkgs, lib }: let nodePackages = import ./composition.nix { inherit pkgs; }; in nodePackages.package.override { # Required because spark-wallet uses `npm-shrinkwrap.json` as the lock file reconstructLock = true; + + meta = with lib; { + description = "A minimalistic wallet GUI for c-lightning"; + homepage = "https://github.com/shesek/spark-wallet"; + license = licenses.mit; + maintainers = with maintainers; [ nixbitcoin earvstedt ]; + platforms = platforms.unix; + }; } From bc7d3a2ed7ffd7d2be25710c703eb1eda342f919 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 15 Dec 2021 15:27:57 +0100 Subject: [PATCH 09/10] fetch-release: check that only one key is imported Co-authored-by: nixbitcoin --- helper/fetch-release | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/helper/fetch-release b/helper/fetch-release index dce8a16..7875766 100755 --- a/helper/fetch-release +++ b/helper/fetch-release @@ -1,9 +1,11 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p bash coreutils curl jq gnupg +#!nix-shell -i bash -p bash coreutils curl jq gnupg gnugrep set -euo pipefail scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) +trap 'echo "Error at ${BASH_SOURCE[0]}, line $LINENO"' ERR + repo=fort-nix/nix-bitcoin if [[ ! -v version ]]; then version=$(curl -s --show-error "https://api.github.com/repos/$repo/releases/latest" | jq -r '.tag_name' | tail -c +2) @@ -17,6 +19,8 @@ mkdir -p -m 700 "$GPG_HOME" # Import key gpg --homedir $GPG_HOME --import "$scriptDir/key-jonasnick.bin" &> /dev/null +# Check that exactly one key was imported +(($(gpg --list-keys --with-colons | grep -c pub) == 1)) # Verify key fingerprint gpg --homedir $GPG_HOME --list-keys "36C7 1A37 C9D9 88BD E825 08D9 B1A7 0E4F 8DCD 0366" > /dev/null From a31d07d8bf611a18247bfb85e3a47acbd60dc90a Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Wed, 15 Dec 2021 14:54:54 +0100 Subject: [PATCH 10/10] ci: update container image for modules tests nixos/nix:latest has switched to Nix 2.5, but we should track 2.3.x, the default on NixOS stable. --- .cirrus.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cirrus.yml b/.cirrus.yml index 2dff4ac..297a74f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -10,7 +10,8 @@ task: matrix: - name: modules_test container: - image: nixos/nix + # Use Nix release 2.3.x, the default on NixOS stable + image: nixos/nix:2.3.12 # Besides virtualization, this also enables privileged containers which are required for # sandboxed builds kvm: true