chromium,chromedriver: 129.0.6668.91 -> 129.0.6668.100
[NixPkgs.git] / pkgs / by-name / ze / zenn-cli / package.nix
blobe6fbacccaf7be2bdf33922756f4c6dcf3bebf2cc
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   fetchurl,
6   autoPatchelfHook,
7   makeWrapper,
8   nodejs,
9   pnpm_9,
10   testers,
12 let
13   go-turbo-version = "1.7.4";
14   go-turbo-srcs = {
15     x86_64-linux = fetchurl {
16       url = "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-${go-turbo-version}.tgz";
17       hash = "sha256-bwi+jthoDe+SEvCPPNNNv9AR8n5IA1fc4I8cnfC095Y=";
18     };
19     aarch64-linux = fetchurl {
20       url = "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-${go-turbo-version}.tgz";
21       hash = "sha256-j3mUd3x16tYR3QQweIB07IbCKYuKPeEkKkUHhrpHzyc=";
22     };
23   };
24   go-turbo = stdenv.mkDerivation {
25     pname = "go-turbo";
26     version = go-turbo-version;
27     src = go-turbo-srcs.${stdenv.hostPlatform.system};
28     nativeBuildInputs = [ autoPatchelfHook ];
29     dontBuild = true;
30     installPhase = ''
31       install -Dm755 bin/go-turbo -t $out/bin
32     '';
33   };
36 stdenv.mkDerivation (finalAttrs: {
37   pname = "zenn-cli";
38   version = "0.1.157";
40   src = fetchFromGitHub {
41     owner = "zenn-dev";
42     repo = "zenn-editor";
43     rev = "refs/tags/${finalAttrs.version}";
44     hash = "sha256-1+5UaSYtY00F+1oJfovLIBPnmfRnKpIkQHpxb93rO2k=";
45     # turborepo requires .git directory
46     leaveDotGit = true;
47   };
49   nativeBuildInputs = [
50     nodejs
51     pnpm_9.configHook
52     makeWrapper
53   ];
55   pnpmDeps = pnpm_9.fetchDeps {
56     inherit (finalAttrs) pname version src;
57     hash = "sha256-FfqBe1WQc6ditizjxYLmjb8mvCjQJMpvyUDdaW29sXY=";
58   };
60   preBuild =
61     ''
62       echo VITE_EMBED_SERVER_ORIGIN="https://embed.zenn.studio" > packages/zenn-cli/.env
63     ''
64     # replace go-turbo since the existing one can't be executed
65     + lib.optionalString stdenv.hostPlatform.isLinux ''
66       cp ${go-turbo}/bin/go-turbo node_modules/.pnpm/turbo-linux-*/node_modules/turbo-linux*/bin/go-turbo
67     '';
69   buildPhase = ''
70     runHook preBuild
72     pnpm build --no-daemon
74     runHook postBuild
75   '';
77   installPhase = ''
78     runHook preInstall
80     mkdir -p $out/{bin,lib/node_modules/zenn-cli}
81     cp -r packages/zenn-cli/{dist,LICENSE,package.json,README.md} $out/lib/node_modules/zenn-cli
83     makeWrapper "${lib.getExe nodejs}" "$out/bin/zenn" \
84       --add-flags "$out/lib/node_modules/zenn-cli/dist/server/zenn.js"
86     runHook postInstall
87   '';
89   passthru = {
90     tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
91   };
93   meta = {
94     description = "Preview Zenn content locally";
95     homepage = "https://github.com/zenn-dev/zenn-editor";
96     changelog = "https://github.com/zenn-dev/zenn-editor/releases/tag/${finalAttrs.version}";
97     license = lib.licenses.mit;
98     maintainers = with lib.maintainers; [ natsukium ];
99     mainProgram = "zenn";
100     platforms = nodejs.meta.platforms;
101   };