Unverified Commit 574609cb authored by Felix Bargfeldt's avatar Felix Bargfeldt Committed by GitHub
Browse files

zipline: properly built sharp dependency against system libvips (#415805)

parents d80ebfd6 ad0130f5
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
{ lib, ... }:
{ lib, pkgs, ... }:

{
  name = "zipline";
  meta.maintainers = with lib.maintainers; [ defelo ];

  nodes.machine = {
    # On x86, testing with a CPU without SSE 4.2 support
    # to ensure native libvips is used
    virtualisation.qemu.options = lib.mkIf pkgs.stdenv.hostPlatform.isx86 [ "-cpu core2duo" ];
    services.zipline = {
      enable = true;
      settings = {
@@ -38,7 +41,7 @@
    import re

    machine.wait_for_unit("zipline.service")
    machine.wait_for_open_port(8000)
    machine.wait_for_open_port(8000, timeout=300)

    resp = machine.succeed("curl zipline.local:8000/api/setup -v -X POST -H 'Content-Type: application/json' -d '{\"username\": \"administrator\", \"password\": \"password\"}' 2>&1")
    data = json.loads(resp.splitlines()[-1])
+16 −9
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@
  versionCheckHook,
  nix-update-script,
  nixosTests,
  node-gyp,
  pkg-config,
  python3,
}:

let
@@ -43,12 +46,19 @@ stdenv.mkDerivation (finalAttrs: {
    hash = "sha256-O8RLaKff4Dj/JDeUOyf7GtcFcOu/aOuclyaZmVqVi5s=";
  };

  buildInputs = [ vips ];
  buildInputs = [
    openssl
    vips
  ];

  nativeBuildInputs = [
    pnpm_10.configHook
    nodejs_24
    makeWrapper
    # for sharp build:
    node-gyp
    pkg-config
    python3
  ];

  env = environment;
@@ -56,6 +66,11 @@ stdenv.mkDerivation (finalAttrs: {
  buildPhase = ''
    runHook preBuild

    # Force build of sharp against native libvips (requires running install scripts).
    # This is necessary for supporting old CPUs (ie. without SSE 4.2 instruction set).
    pnpm config set nodedir ${nodejs_24}
    pnpm install --force --offline --frozen-lockfile

    pnpm build

    runHook postBuild
@@ -88,14 +103,6 @@ stdenv.mkDerivation (finalAttrs: {
    runHook postInstall
  '';

  preFixup = ''
    find $out -name libvips-cpp.so.42 -print0 | while read -d $'\0' libvips; do
      echo replacing libvips at $libvips
      rm $libvips
      ln -s ${lib.getLib vips}/lib/libvips-cpp.so.42 $libvips
    done
  '';

  nativeInstallCheckInputs = [ versionCheckHook ];
  versionCheckProgram = "${placeholder "out"}/bin/ziplinectl";
  versionCheckProgramArg = "--version";