From d214605b3239f81a7585fc4979f134530d0ad050 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Tue, 16 Mar 2021 12:45:21 +0100 Subject: [PATCH] spark-wallet: add flakes compatibility Pure flakes can't use NIX_PATH. --- pkgs/spark-wallet/composition.nix | 2 +- pkgs/spark-wallet/generate.sh | 7 +++++++ pkgs/spark-wallet/node-env.nix | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) delete mode 100644 pkgs/spark-wallet/node-env.nix diff --git a/pkgs/spark-wallet/composition.nix b/pkgs/spark-wallet/composition.nix index dd99c0a..3bc2c21 100644 --- a/pkgs/spark-wallet/composition.nix +++ b/pkgs/spark-wallet/composition.nix @@ -5,7 +5,7 @@ }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-10_x"}: let - nodeEnv = import ./node-env.nix { + nodeEnv = import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix" { inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile; inherit nodejs; libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null; diff --git a/pkgs/spark-wallet/generate.sh b/pkgs/spark-wallet/generate.sh index 84434d9..b1bb841 100755 --- a/pkgs/spark-wallet/generate.sh +++ b/pkgs/spark-wallet/generate.sh @@ -22,6 +22,13 @@ jq '.dependencies["qrcode-terminal"] = .optionalDependencies["qrcode-terminal"]' cp pkg.json $TMPDIR/pkg.json node2nix --nodejs-10 -i $TMPDIR/pkg.json -c 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. +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 diff --git a/pkgs/spark-wallet/node-env.nix b/pkgs/spark-wallet/node-env.nix deleted file mode 100644 index f17b2d6..0000000 --- a/pkgs/spark-wallet/node-env.nix +++ /dev/null @@ -1 +0,0 @@ -import