Skip to content

Commit

Permalink
[Backport release-24.11] gancio: remove mkYarnPackage usage (#359800)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-vdp authored Nov 29, 2024
2 parents 1f61405 + 6b1dcfe commit c789002
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 254 deletions.
145 changes: 0 additions & 145 deletions pkgs/by-name/ga/gancio/package.json

This file was deleted.

100 changes: 41 additions & 59 deletions pkgs/by-name/ga/gancio/package.nix
Original file line number Diff line number Diff line change
@@ -1,89 +1,71 @@
{
mkYarnPackage,
lib,
stdenv,
fetchFromGitLab,
fetchYarnDeps,
python3,

yarnConfigHook,
yarnBuildHook,
yarnInstallHook,
nodejs,
pkg-config,
nodePackages,
node-gyp,

vips,
lib,
sqlite,

nixosTests,
}:
mkYarnPackage rec {
inherit (nodePackages) nodejs;

stdenv.mkDerivation (finalAttrs: {
pname = "gancio";
version = "1.19.4";

src = fetchFromGitLab {
domain = "framagit.org";
owner = "les";
repo = "gancio";
rev = "v${version}";
rev = "v${finalAttrs.version}";
hash = "sha256-x8s7eBVmHCY3kAjHjACotCncvZq6OBiLPJGF6hvfawE=";
};

offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
yarnLock = finalAttrs.src + "/yarn.lock";
hash = "sha256-LXeAyxZSZOm6GxRuJb5rlHTlQpYa1fdKSENVjwLY4tU=";
};

packageJSON = ./package.json;
nativeBuildInputs = [
yarnConfigHook
yarnBuildHook
yarnInstallHook
nodejs
(nodejs.python.withPackages (ps: [ ps.setuptools ]))
pkg-config
];

# for pkg-config dependencies:
yarnPreBuild = ''
export npm_config_nodedir=${nodePackages.nodejs}
'';
# So that sqlite can be found:
pkgConfig.sqlite3 = {
nativeBuildInputs = [
pkg-config
nodePackages.prebuild-install
node-gyp
python3
];
postInstall = ''
yarn --offline run install
'';
};
# Sharp need to find a vips library
pkgConfig.sharp = {
nativeBuildInputs = [
pkg-config
python3
node-gyp
nodePackages.semver
];
buildInputs = [ vips ];
postInstall = ''
yarn --offline run install
'';
};

# build need a writeable node_modules
configurePhase = ''
runHook preConfigure
buildInputs = [
vips
sqlite
];

cp -r $node_modules node_modules
chmod -R +w node_modules
runHook postConfigure
# generate .node binaries
preBuild = ''
npm rebuild --verbose --nodedir=${nodejs} --sqlite=${lib.getDev sqlite}
'';

buildPhase = ''
runHook preBuild
export HOME=$(mktemp -d)
yarn --offline build
yarn --offline pack --filename gancio.tgz
mkdir -p deps/gancio
tar -C deps/gancio/ --strip-components=1 -xf gancio.tgz
rm gancio.tgz
# the node_modules directory will be regenerated by yarnInstallHook, so we save our .node binaries
preInstall = ''
cp node_modules/sharp/build/Release/sharp.node .
cp node_modules/sqlite3/build/Release/node_sqlite3.node .
'';

runHook postBuild
# and then place them where they belong
postInstall = ''
install -Dm755 sharp.node -t $out/lib/node_modules/gancio/node_modules/sharp/build/Release
install -Dm755 node_sqlite3.node -t $out/lib/node_modules/gancio/node_modules/sqlite3/build/Release
'';

passthru = {
updateScript = ./update.sh;
inherit nodejs;
tests = {
inherit (nixosTests) gancio;
};
Expand All @@ -98,4 +80,4 @@ mkYarnPackage rec {
mainProgram = "gancio";
maintainers = with lib.maintainers; [ jbgi ];
};
}
})
40 changes: 25 additions & 15 deletions pkgs/by-name/ga/gancio/plugin-telegram-bridge/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
mkYarnPackage,
nodejs,
lib,
stdenv,
fetchFromGitLab,
fetchYarnDeps,
lib,
yarnConfigHook,
yarnInstallHook,
nodejs,
}:
mkYarnPackage rec {
inherit nodejs;

stdenv.mkDerivation rec {
pname = "gancio-plugin-telegram-bridge";
version = "1.0.4";

src = fetchFromGitLab {
Expand All @@ -17,24 +20,31 @@ mkYarnPackage rec {
hash = "sha256-Da8PxCX1Z1dKJu9AiwdRDfb1r1P2KiZe8BClYB9Rz48=";
};

# upstream doesn't provide a yarn.lock file
postPatch = ''
cp --no-preserve=all ${./yarn.lock} ./yarn.lock
'';

offlineCache = fetchYarnDeps {
inherit yarnLock;
yarnLock = ./yarn.lock;
hash = "sha256-BcRVmVA5pnFzpg2gN/nKLzENnoEdwrE0EgulDizq8Ok=";
};

packageJSON = ./package.json;

# upstream doesn't provide a yarn.lock file
yarnLock = ./yarn.lock;

doDist = false;
nativeBuildInputs = [
yarnConfigHook
yarnInstallHook
nodejs
];

postInstall = ''
rmdir $out/bin
ln -s $out/libexec/gancio-plugin-telegram/deps/gancio-plugin-telegram/index.js $out/
ln -s $out/libexec/gancio-plugin-telegram/node_modules $out/
ln -s "$out/lib/node_modules/gancio-plugin-telegram/index.js" "$out/index.js"
ln -s "$out/lib/node_modules/gancio-plugin-telegram/node_modules" "$out/node_modules"
'';

passthru = {
inherit nodejs;
};

meta = {
description = "Telegram bridge for Gancio, republishes content to Telegram channels or groups";
homepage = "https://framagit.org/bcn.convocala/gancio-plugin-telegram-bridge";
Expand Down
16 changes: 0 additions & 16 deletions pkgs/by-name/ga/gancio/plugin-telegram-bridge/package.json

This file was deleted.

19 changes: 0 additions & 19 deletions pkgs/by-name/ga/gancio/update.sh

This file was deleted.

0 comments on commit c789002

Please sign in to comment.