syncyomi: refactor derivation

1. use finalAttrs param instead of rec attrs

  using a "fix-point" style derivation that takes a self arg (aka
  finalAttrs) makes it easier to override things for consumers than
  when using a `rec` attr set, which is just syntactic sugar and
  doesn't propagate overriding. this is especially useful since the
  the build's ldflags and the web sub-derivation definition both
  used the `src` and `version` attributes.

2. refact esbuild override

  the derivation forces esbuild to be the same version as declared
  in its web/pnpm-lock.yaml file, but it did it by overriding the
  definition of `buildGoModule` used by the esbuild drv. however,
  it seems like this was unecessary, since just doing .overrideAttrs
  also worked fine for changing the esbuild version.
This commit is contained in:
blokyk
2026-01-30 01:15:12 +00:00
parent be2eb5aaf9
commit 41514f6505
+25 -29
View File
@@ -9,26 +9,40 @@
pnpmConfigHook,
esbuild,
}:
buildGoModule rec {
let
lockedEsbuild = esbuild.overrideAttrs (
finalAttrs: prevAttrs: {
version = "0.17.19";
src = fetchFromGitHub {
owner = "evanw";
repo = "esbuild";
rev = "v${finalAttrs.version}";
hash = "sha256-PLC7OJLSOiDq4OjvrdfCawZPfbfuZix4Waopzrj8qsU=";
};
vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
}
);
in
buildGoModule (finalAttrs: {
pname = "syncyomi";
version = "1.1.2";
src = fetchFromGitHub {
owner = "SyncYomi";
repo = "SyncYomi";
tag = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-PPE6UXHo2ZlN0A0VkUH+8pkdfm6WEvpofusk6c3RBHk=";
};
vendorHash = "sha256-/rpT6SatIZ+GVzmVg6b8Zy32pGybprObotyvEgvdL2w=";
web = stdenvNoCC.mkDerivation (finalAttrs: {
pname = "${pname}-web";
inherit src version;
sourceRoot = "${finalAttrs.src.name}/web";
web = stdenvNoCC.mkDerivation (webFinalAttrs: {
pname = "${finalAttrs.pname}-web";
inherit (finalAttrs) src version;
sourceRoot = "${webFinalAttrs.src.name}/web";
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs)
inherit (webFinalAttrs)
pname
version
src
@@ -45,25 +59,7 @@ buildGoModule rec {
pnpm_9
];
env.ESBUILD_BINARY_PATH = lib.getExe (
esbuild.override {
buildGoModule =
args:
buildGoModule (
args
// rec {
version = "0.17.19";
src = fetchFromGitHub {
owner = "evanw";
repo = "esbuild";
rev = "v${version}";
hash = "sha256-PLC7OJLSOiDq4OjvrdfCawZPfbfuZix4Waopzrj8qsU=";
};
vendorHash = "sha256-+BfxCyg0KkDQpHt/wycy/8CTG6YBA/VJvJFhhzUnSiQ=";
}
);
}
);
env.ESBUILD_BINARY_PATH = lib.getExe lockedEsbuild;
buildPhase = ''
runHook preBuild
@@ -85,7 +81,7 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-X main.version=v${version}"
"-X main.version=v${finalAttrs.version}"
];
postInstall = lib.optionalString (!stdenvNoCC.hostPlatform.isDarwin) ''
@@ -95,10 +91,10 @@ buildGoModule rec {
meta = {
description = "Open-source project to synchronize Tachiyomi manga reading progress and library across multiple devices";
homepage = "https://github.com/SyncYomi/SyncYomi";
changelog = "https://github.com/SyncYomi/SyncYomi/releases/tag/v${version}";
changelog = "https://github.com/SyncYomi/SyncYomi/releases/tag/v${finalAttrs.version}";
license = lib.licenses.gpl2Only;
maintainers = with lib.maintainers; [ eriedaberrie ];
mainProgram = "syncyomi";
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
}
})