mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-26 14:04:52 +00:00
Merge pull request #230991 from winterqt/add-npm-root
npmHooks.npmConfigHook: add npmRoot option
This commit is contained in:
commit
273b32abe2
@ -7,6 +7,10 @@ npmConfigHook() {
|
|||||||
export NIX_NODEJS_BUILDNPMPACKAGE=1
|
export NIX_NODEJS_BUILDNPMPACKAGE=1
|
||||||
export prefetchNpmDeps="@prefetchNpmDeps@"
|
export prefetchNpmDeps="@prefetchNpmDeps@"
|
||||||
|
|
||||||
|
if [ -n "${npmRoot-}" ]; then
|
||||||
|
pushd "$npmRoot"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Configuring npm"
|
echo "Configuring npm"
|
||||||
|
|
||||||
export HOME="$TMPDIR"
|
export HOME="$TMPDIR"
|
||||||
@ -105,6 +109,10 @@ npmConfigHook() {
|
|||||||
rm "$CACHE_MAP_PATH"
|
rm "$CACHE_MAP_PATH"
|
||||||
unset CACHE_MAP_PATH
|
unset CACHE_MAP_PATH
|
||||||
|
|
||||||
|
if [ -n "${npmRoot-}" ]; then
|
||||||
|
popd
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Finished npmConfigHook"
|
echo "Finished npmConfigHook"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,31 +1,23 @@
|
|||||||
{ pkgs
|
{ lib
|
||||||
, lib
|
|
||||||
, stdenv
|
, stdenv
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
, python3Packages
|
, python3Packages
|
||||||
, ffmpeg
|
, ffmpeg
|
||||||
, makeWrapper
|
, makeWrapper
|
||||||
, nixosTests
|
, nixosTests
|
||||||
|
, nodejs
|
||||||
|
, npmHooks
|
||||||
|
, fetchNpmDeps
|
||||||
|
|
||||||
# For the update script
|
# For the update script
|
||||||
, coreutils
|
, coreutils
|
||||||
, curl
|
, curl
|
||||||
, nix-prefetch-git
|
, nix-prefetch-git
|
||||||
|
, prefetch-npm-deps
|
||||||
, jq
|
, jq
|
||||||
, nodePackages
|
, writeShellScript
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
nodejs = pkgs.nodejs_14;
|
|
||||||
nodeEnv = import ../../../development/node-packages/node-env.nix {
|
|
||||||
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
|
|
||||||
inherit pkgs nodejs;
|
|
||||||
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
|
|
||||||
};
|
|
||||||
botamusiqueNodePackages = import ./node-packages.nix {
|
|
||||||
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
|
|
||||||
inherit nodeEnv;
|
|
||||||
};
|
|
||||||
|
|
||||||
srcJson = lib.importJSON ./src.json;
|
srcJson = lib.importJSON ./src.json;
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "azlux";
|
owner = "azlux";
|
||||||
@ -33,19 +25,23 @@ let
|
|||||||
inherit (srcJson) rev sha256;
|
inherit (srcJson) rev sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
nodeDependencies = (botamusiqueNodePackages.shell.override (old: {
|
|
||||||
src = src + "/web";
|
|
||||||
})).nodeDependencies;
|
|
||||||
|
|
||||||
# Python needed to instantiate the html templates
|
# Python needed to instantiate the html templates
|
||||||
buildPython = python3Packages.python.withPackages (ps: [ ps.jinja2 ]);
|
buildPython = python3Packages.python.withPackages (ps: [ ps.jinja2 ]);
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "botamusique";
|
pname = "botamusique";
|
||||||
version = srcJson.version;
|
version = srcJson.version;
|
||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
|
|
||||||
|
npmDeps = fetchNpmDeps {
|
||||||
|
src = "${src}/web";
|
||||||
|
hash = srcJson.npmDepsHash;
|
||||||
|
};
|
||||||
|
|
||||||
|
npmRoot = "web";
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
# botamusique by default resolves relative state paths by first checking
|
# botamusique by default resolves relative state paths by first checking
|
||||||
# whether it exists in the working directory, then falls back to using the
|
# whether it exists in the working directory, then falls back to using the
|
||||||
@ -67,9 +63,12 @@ stdenv.mkDerivation rec {
|
|||||||
--replace "configuration.default.ini" "$out/share/botamusique/configuration.default.ini"
|
--replace "configuration.default.ini" "$out/share/botamusique/configuration.default.ini"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
NODE_OPTIONS = "--openssl-legacy-provider";
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
makeWrapper
|
makeWrapper
|
||||||
nodejs
|
nodejs
|
||||||
|
npmHooks.npmConfigHook
|
||||||
python3Packages.wrapPython
|
python3Packages.wrapPython
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -91,9 +90,6 @@ stdenv.mkDerivation rec {
|
|||||||
# Generates artifacts in ./static
|
# Generates artifacts in ./static
|
||||||
(
|
(
|
||||||
cd web
|
cd web
|
||||||
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
|
|
||||||
export PATH="${nodeDependencies}/bin:$PATH"
|
|
||||||
|
|
||||||
npm run build
|
npm run build
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -118,36 +114,26 @@ stdenv.mkDerivation rec {
|
|||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.updateScript = pkgs.writeShellScript "botamusique-updater" ''
|
passthru.updateScript = writeShellScript "botamusique-updater" ''
|
||||||
export PATH=${lib.makeBinPath [ coreutils curl nix-prefetch-git jq nodePackages.node2nix ]}
|
export PATH=${lib.makeBinPath [ coreutils curl nix-prefetch-git jq prefetch-npm-deps ]}
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
OWNER=azlux
|
OWNER=azlux
|
||||||
REPO=botamusique
|
REPO=botamusique
|
||||||
VERSION=$(curl https://api.github.com/repos/$OWNER/$REPO/releases/latest | jq -r '.tag_name')
|
VERSION="$(curl https://api.github.com/repos/$OWNER/$REPO/releases/latest | jq -r '.tag_name')"
|
||||||
|
|
||||||
nix-prefetch-git --rev "$VERSION" --url https://github.com/$OWNER/$REPO | \
|
nix-prefetch-git --rev "$VERSION" --url https://github.com/$OWNER/$REPO | \
|
||||||
jq > ${toString ./src.json } \
|
jq > "${toString ./src.json}" \
|
||||||
--arg version "$VERSION" \
|
--arg version "$VERSION" \
|
||||||
'.version |= $version'
|
'.version |= $version'
|
||||||
path=$(jq '.path' -r < ${toString ./src.json})
|
path="$(jq '.path' -r < "${toString ./src.json}")"
|
||||||
|
|
||||||
tmp=$(mktemp -d)
|
tmp="$(mktemp -d)"
|
||||||
trap 'rm -rf "$tmp"' exit
|
trap 'rm -rf "$tmp"' exit
|
||||||
|
|
||||||
# botamusique doesn't have a version in its package.json
|
npmHash="$(prefetch-npm-deps $path/web/package-lock.json)"
|
||||||
# But that's needed for node2nix
|
jq '. + { npmDepsHash: "'"$npmHash"'" }' < "${toString ./src.json}" > "$tmp/src.json"
|
||||||
jq < "$path"/web/package.json > "$tmp/package.json" \
|
mv "$tmp/src.json" "${toString ./src.json}"
|
||||||
--arg version "$VERSION" \
|
|
||||||
'.version |= $version'
|
|
||||||
|
|
||||||
node2nix \
|
|
||||||
--input "$tmp"/package.json \
|
|
||||||
--lock "$path"/web/package-lock.json \
|
|
||||||
--no-copy-node-env \
|
|
||||||
--development \
|
|
||||||
--composition /dev/null \
|
|
||||||
--output ${toString ./node-packages.nix}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.tests = {
|
passthru.tests = {
|
||||||
|
5237
pkgs/tools/audio/botamusique/node-packages.nix
generated
5237
pkgs/tools/audio/botamusique/node-packages.nix
generated
File diff suppressed because it is too large
Load Diff
@ -8,5 +8,6 @@
|
|||||||
"fetchSubmodules": false,
|
"fetchSubmodules": false,
|
||||||
"deepClone": false,
|
"deepClone": false,
|
||||||
"leaveDotGit": false,
|
"leaveDotGit": false,
|
||||||
"version": "7.2.2"
|
"version": "7.2.2",
|
||||||
|
"npmDepsHash": "sha256-IzEO7TFqIZUkhNGf0pnHbK/WFexF27RPD9lkYvmFmDw="
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user