your_spotify: use yarn{Config,Build}Hook instead of mkYarnPackage
This commit is contained in:
@@ -1,49 +1,36 @@
|
||||
{
|
||||
apiEndpoint ? "http://localhost:3000",
|
||||
fetchYarnDeps,
|
||||
your_spotify,
|
||||
mkYarnPackage,
|
||||
fixup-yarn-lock,
|
||||
stdenv,
|
||||
src,
|
||||
version,
|
||||
yarn,
|
||||
meta,
|
||||
offlineCache,
|
||||
apiEndpoint ? "http://localhost:3000",
|
||||
yarnConfigHook,
|
||||
yarnBuildHook,
|
||||
nodejs
|
||||
}:
|
||||
mkYarnPackage rec {
|
||||
inherit version src;
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "your_spotify_client";
|
||||
name = "your_spotify_client-${version}";
|
||||
packageJSON = ./package.json;
|
||||
offlineCache = fetchYarnDeps {
|
||||
yarnLock = src + "/yarn.lock";
|
||||
hash = "sha256-5SgknaRVzgO2Dzc8MhAaM8UERWMv+PrItzevoWHbWnA=";
|
||||
};
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
inherit version src offlineCache;
|
||||
|
||||
export HOME=$(mktemp -d)
|
||||
yarn config --offline set yarn-offline-mirror $offlineCache
|
||||
fixup-yarn-lock yarn.lock
|
||||
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
||||
patchShebangs node_modules/
|
||||
nativeBuildInputs = [
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
nodejs
|
||||
];
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
API_ENDPOINT="${apiEndpoint}";
|
||||
preBuild = ''
|
||||
pushd ./apps/client/
|
||||
yarn --offline run build
|
||||
export API_ENDPOINT="${apiEndpoint}"
|
||||
'';
|
||||
postBuild = ''
|
||||
substituteInPlace scripts/run/variables.sh --replace-quiet '/app/apps/client/' "./"
|
||||
|
||||
chmod +x ./scripts/run/variables.sh
|
||||
patchShebangs --build ./scripts/run/variables.sh
|
||||
|
||||
./scripts/run/variables.sh
|
||||
|
||||
popd
|
||||
runHook postBuild
|
||||
'';
|
||||
nativeBuildInputs = [yarn fixup-yarn-lock];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
@@ -51,8 +38,6 @@ mkYarnPackage rec {
|
||||
cp -r ./apps/client/build/* $out
|
||||
runHook postInstall
|
||||
'';
|
||||
doDist = false;
|
||||
meta = {
|
||||
inherit (your_spotify.meta) homepage changelog description license maintainers;
|
||||
};
|
||||
}
|
||||
|
||||
inherit meta;
|
||||
})
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"name": "@your_spotify/root",
|
||||
"version": "1.10.1",
|
||||
"repository": "git@github.com:Yooooomi/your_spotify.git",
|
||||
"author": "Timothee <timothee.boussus@gmail.com>",
|
||||
"private": true,
|
||||
"workspaces": [
|
||||
"apps/*"
|
||||
]
|
||||
}
|
||||
@@ -1,85 +1,76 @@
|
||||
{
|
||||
callPackage,
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
fetchYarnDeps,
|
||||
lib,
|
||||
makeWrapper,
|
||||
mkYarnPackage,
|
||||
yarnConfigHook,
|
||||
yarnBuildHook,
|
||||
nodejs,
|
||||
fixup-yarn-lock,
|
||||
yarn,
|
||||
}: let
|
||||
makeWrapper,
|
||||
callPackage,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "your_spotify_server";
|
||||
version = "1.10.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Yooooomi";
|
||||
repo = "your_spotify";
|
||||
rev = "refs/tags/${version}";
|
||||
rev = "refs/tags/${finalAttrs.version}";
|
||||
hash = "sha256-e82j2blGxQLWAlBNuAnFvlD9vwMk4/mRI0Vf7vuaPA0=";
|
||||
};
|
||||
client = callPackage ./client.nix {inherit src version;};
|
||||
in
|
||||
mkYarnPackage rec {
|
||||
inherit version src;
|
||||
pname = "your_spotify_server";
|
||||
name = "your_spotify_server-${version}";
|
||||
packageJSON = ./package.json;
|
||||
offlineCache = fetchYarnDeps {
|
||||
yarnLock = src + "/yarn.lock";
|
||||
hash = "sha256-5SgknaRVzgO2Dzc8MhAaM8UERWMv+PrItzevoWHbWnA=";
|
||||
|
||||
offlineCache = fetchYarnDeps {
|
||||
yarnLock = finalAttrs.src + "/yarn.lock";
|
||||
hash = "sha256-5SgknaRVzgO2Dzc8MhAaM8UERWMv+PrItzevoWHbWnA=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
yarnConfigHook
|
||||
yarnBuildHook
|
||||
nodejs
|
||||
];
|
||||
|
||||
preBuild = ''
|
||||
pushd ./apps/server/
|
||||
'';
|
||||
postBuild = ''
|
||||
popd
|
||||
rm -r node_modules
|
||||
export NODE_ENV="production"
|
||||
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
||||
patchShebangs node_modules/
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/share/your_spotify
|
||||
cp -r node_modules $out/share/your_spotify/node_modules
|
||||
cp -r ./apps/server/{lib,package.json} $out
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${lib.escapeShellArg (lib.getExe nodejs)} "$out/bin/your_spotify_migrate" \
|
||||
--add-flags "$out/lib/migrations.js" --set NODE_PATH "$out/share/your_spotify/node_modules"
|
||||
makeWrapper ${lib.escapeShellArg (lib.getExe nodejs)} "$out/bin/your_spotify_server" \
|
||||
--add-flags "$out/lib/index.js" --set NODE_PATH "$out/share/your_spotify/node_modules"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
client = callPackage ./client.nix {
|
||||
inherit (finalAttrs) src version offlineCache meta;
|
||||
};
|
||||
};
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
export HOME=$(mktemp -d)
|
||||
yarn config --offline set yarn-offline-mirror $offlineCache
|
||||
fixup-yarn-lock yarn.lock
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
||||
patchShebangs node_modules/
|
||||
|
||||
pushd ./apps/server/
|
||||
yarn --offline run build
|
||||
popd
|
||||
|
||||
rm -r node_modules
|
||||
export NODE_ENV="production"
|
||||
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
||||
patchShebangs node_modules/
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
nativeBuildInputs = [makeWrapper yarn fixup-yarn-lock];
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/share/your_spotify
|
||||
cp -r node_modules $out/share/your_spotify/node_modules
|
||||
cp -r ./apps/server/{lib,package.json} $out
|
||||
mkdir -p $out/bin
|
||||
makeWrapper ${lib.escapeShellArg (lib.getExe nodejs)} "$out/bin/your_spotify_migrate" \
|
||||
--add-flags "$out/lib/migrations.js" --set NODE_PATH "$out/share/your_spotify/node_modules"
|
||||
makeWrapper ${lib.escapeShellArg (lib.getExe nodejs)} "$out/bin/your_spotify_server" \
|
||||
--add-flags "$out/lib/index.js" --set NODE_PATH "$out/share/your_spotify/node_modules"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
doDist = false;
|
||||
passthru = {
|
||||
inherit client;
|
||||
};
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/Yooooomi/your_spotify";
|
||||
changelog = "https://github.com/Yooooomi/your_spotify/releases/tag/${version}";
|
||||
description = "Self-hosted application that tracks what you listen and offers you a dashboard to explore statistics about it";
|
||||
license = licenses.gpl3Only;
|
||||
maintainers = with maintainers; [patrickdag];
|
||||
mainProgram = "your_spotify_server";
|
||||
};
|
||||
}
|
||||
meta = {
|
||||
homepage = "https://github.com/Yooooomi/your_spotify";
|
||||
changelog = "https://github.com/Yooooomi/your_spotify/releases/tag/${finalAttrs.version}";
|
||||
description = "Self-hosted application that tracks what you listen and offers you a dashboard to explore statistics about it";
|
||||
license = lib.licenses.gpl3Only;
|
||||
maintainers = with lib.maintainers; [ patrickdag ];
|
||||
mainProgram = "your_spotify_server";
|
||||
};
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user