Files
wpep/tools/gp/flake.nix
T
2026-10-26 12:49:29 +08:00

69 lines
2.0 KiB
Nix

{
description = "GP markdown to PDF toolchain (Deno + Playwright + Chromium)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachSystem
[
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(
system:
let
pkgs = import nixpkgs { inherit system; };
lib = pkgs.lib;
in
{
devShells.default = pkgs.mkShell {
packages = [
pkgs.deno
pkgs.nodejs_22
pkgs.qpdf
pkgs.ripgrep
]
++ lib.optionals pkgs.stdenv.isLinux [
pkgs.chromium
pkgs.noto-fonts-cjk-sans
];
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1";
shellHook = ''
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
if [ -z "$CHROMIUM_PATH" ]; then
if command -v chromium >/dev/null 2>&1; then
export CHROMIUM_PATH="$(command -v chromium)"
elif command -v chromium-browser >/dev/null 2>&1; then
export CHROMIUM_PATH="$(command -v chromium-browser)"
elif [ -x "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" ]; then
export CHROMIUM_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
fi
fi
echo "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=$PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD"
if [ -n "$CHROMIUM_PATH" ]; then
echo "CHROMIUM_PATH=$CHROMIUM_PATH"
else
echo "CHROMIUM_PATH is not set."
echo "Linux: add nixpkgs#chromium or install chromium system-wide."
echo "macOS: install Google Chrome/Chromium and set CHROMIUM_PATH."
fi
'';
};
}
);
}