Files
Emily fdb820602b treewide: drop simple x86_64-darwin mentions
To reproduce:

    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: nix-x86_64-darwin
          language: nix
          rule:
            any:
              - pattern: "\"x86_64-darwin\""
                kind: list_expression > string_expression
              - pattern:
                  context: "{ \"x86_64-darwin\" = $EXPR; }"
                  selector: binding
              - pattern:
                  context: "{ x86_64-darwin = $EXPR; }"
                  selector: binding
          fix:
            template: ""
        ' pkgs
    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: json-first-x86_64-darwin
          language: json
          rule:
            kind: object > pair:nth-child(1)
            has:
              pattern: "\"x86_64-darwin\""
              field: key
          fix:
            template: ""
            expandEnd: { regex: "," }
        ' pkgs
    $ nix run nixpkgs/3b32825de172d0bc85664f495edb096b10862524#ast-grep \
        -- scan --update-all --inline-rules '
          id: json-x86_64-darwin
          language: json
          rule:
            kind: object > pair
            has:
              pattern: "\"x86_64-darwin\""
              field: key
          fix:
            template: ""
            expandStart: { regex: "," }
        ' pkgs
    $ git restore pkgs/by-name/om/omnix/package.nix
    $ git diff --name-only -z \
        | nix shell nixpkgs/3b32825de172d0bc85664f495edb096b10862524#gnused \
            -c xargs -0 sed -i '/^$/N; /^\n\? \+$/d'
    $ treefmt
2026-07-15 03:58:16 +01:00

105 lines
3.6 KiB
Nix

{
lib,
stdenv,
python,
buildPythonPackage,
callPackage,
fetchurl,
autoPatchelfHook,
bash,
dejavu_fonts,
expat,
fontconfig,
lato,
libGL,
makeWrapper,
nspr,
nss,
sqlite,
}:
buildPythonPackage rec {
pname = "kaleido";
version = "0.2.1";
format = "wheel";
src =
{
# This library is so cursed that I have to use fetchurl instead of fetchPypi. I am not happy.
x86_64-linux = fetchurl {
url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-manylinux1_x86_64.whl";
hash = "sha256-qiHPG/HHj4+lCp99ReEAPDh709b+CnZ8+780S5W9w6g=";
};
aarch64-linux = fetchurl {
url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-manylinux2014_aarch64.whl";
hash = "sha256-hFgZhEyAgslGnZwX5CYh+/hcKyN++KhuyKhSf5i2USo=";
};
aarch64-darwin = fetchurl {
url = "https://files.pythonhosted.org/packages/py2.py3/k/kaleido/kaleido-${version}-py2.py3-none-macosx_11_0_arm64.whl";
hash = "sha256-u5pdH3EDV9XUMu4kDvZlim0STD5hCTWBe0tC2px4fAU=";
};
}
."${stdenv.hostPlatform.system}"
or (throw "Unsupported system for ${pname}: ${stdenv.hostPlatform.system}");
nativeBuildInputs = (lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]) ++ [
makeWrapper
];
buildInputs = [
bash
dejavu_fonts
expat
fontconfig
lato
libGL
nspr
nss
sqlite
];
pythonImportsCheck = [ "kaleido" ];
postInstall = ''
# Expose kaleido binary
mkdir -p $out/bin
ln -s $out/${python.sitePackages}/kaleido/executable/bin/kaleido $out/bin/kaleido
# Relace bundled libraries with nixpkgs-packaged libraries
rm -rf $out/${python.sitePackages}/kaleido/executable/lib
mkdir -p $out/${python.sitePackages}/kaleido/executable/lib
ln -s ${expat}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/
ln -s ${nspr}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/
ln -s ${nss}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/
ln -s ${sqlite}/lib/* $out/${python.sitePackages}/kaleido/executable/lib/
# Replace bundled font configuration with nixpkgs-packaged font configuration
rm -rf $out/${python.sitePackages}/kaleido/executable/etc/fonts
mkdir -p $out/${python.sitePackages}/kaleido/executable/etc/fonts/conf.d
ln -s ${fontconfig.out}/etc/fonts/fonts.conf $out/${python.sitePackages}/kaleido/executable/etc/fonts/
ln -s ${fontconfig.out}/etc/fonts/conf.d/* $out/${python.sitePackages}/kaleido/executable/etc/fonts/conf.d/
''
+ lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
# Replace bundled swiftshader with libGL
rm -rf $out/${python.sitePackages}/kaleido/executable/bin/swiftshader
ln -s ${libGL}/lib $out/${python.sitePackages}/kaleido/executable/bin/swiftshader
'';
passthru.tests = lib.optionalAttrs (!stdenv.hostPlatform.isDarwin) {
kaleido = callPackage ./tests.nix { };
};
meta = {
description = "Fast static image export for web-based visualization libraries with zero dependencies";
homepage = "https://github.com/plotly/Kaleido";
changelog = "https://github.com/plotly/Kaleido/releases";
platforms = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; # Trust me, I'm not happy. But after literal hours of trying to reverse-engineer their build system and getting nowhere, I'll use the stupid binaries >:(
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ pandapip1 ];
};
}