Moved from nix-shell -> flakes
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m27s
All checks were successful
Docker Deploy / build-and-push (push) Successful in 4m27s
This commit is contained in:
120
flake.nix
Normal file
120
flake.nix
Normal file
@@ -0,0 +1,120 @@
|
||||
# flake.nix
|
||||
{
|
||||
description = "A portable development environment for atridotdad with Nix Flakes";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # Pin to a specific branch or commit for stability
|
||||
flake-utils.url = "github:numtide/flake-utils"; # Helps with system boilerplate
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
isDarwin = pkgs.stdenv.isDarwin;
|
||||
isLinux = pkgs.stdenv.isLinux;
|
||||
|
||||
commonDevTools = with pkgs; [
|
||||
nodejs_24
|
||||
nodePackages.pnpm
|
||||
git
|
||||
curl
|
||||
];
|
||||
|
||||
# Common libraries needed for Playwright across platforms (e.g., for WebKit/Firefox)
|
||||
playwrightCommonLibs = with pkgs; [
|
||||
glib
|
||||
nss
|
||||
nspr
|
||||
dbus
|
||||
atk
|
||||
at-spi2-atk
|
||||
at-spi2-core
|
||||
cups
|
||||
expat
|
||||
libxkbcommon
|
||||
cairo
|
||||
pango
|
||||
fontconfig
|
||||
freetype
|
||||
harfbuzz
|
||||
icu
|
||||
libpng
|
||||
gnutls
|
||||
];
|
||||
|
||||
# Linux-specific libraries for Playwright (mostly Chromium dependencies)
|
||||
playwrightLinuxSpecificLibs = with pkgs; [
|
||||
glibc
|
||||
libgcc
|
||||
xorg.libX11
|
||||
xorg.libxcb
|
||||
xorg.libXext
|
||||
xorg.libXfixes
|
||||
xorg.libXrandr
|
||||
xorg.libXcomposite
|
||||
xorg.libXdamage
|
||||
xorg.libXcursor
|
||||
xorg.libXi
|
||||
xorg.libXrender
|
||||
xorg.libXtst
|
||||
mesa
|
||||
libglvnd
|
||||
libdrm
|
||||
udev
|
||||
alsa-lib
|
||||
];
|
||||
|
||||
playwrightSelfDownloadLibs = playwrightCommonLibs ++ (if isLinux then playwrightLinuxSpecificLibs else []);
|
||||
|
||||
playwrightLibPath = pkgs.lib.makeBinPath playwrightSelfDownloadLibs;
|
||||
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = commonDevTools ++ (
|
||||
if isDarwin
|
||||
then playwrightCommonLibs # For macOS, Playwright will download Chromium. Provide base libs.
|
||||
else [ pkgs.chromium ] ++ playwrightSelfDownloadLibs # For Linux, provide Chromium and its dependencies
|
||||
);
|
||||
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = if isDarwin then "0" else "1";
|
||||
|
||||
PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH = pkgs.lib.optionalString isLinux "${pkgs.chromium}/bin/chromium";
|
||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = if isDarwin then "false" else "true";
|
||||
PUPPETEER_EXECUTABLE_PATH = pkgs.lib.optionalString isLinux "${pkgs.chromium}/bin/chromium";
|
||||
|
||||
shellHook = ''
|
||||
echo "🚀 atridotdad development environment loaded!"
|
||||
echo "Node version: $(node --version)"
|
||||
echo "pnpm version: $(pnpm --version)"
|
||||
|
||||
${pkgs.lib.optionalString isDarwin ''
|
||||
echo "Chromium path: Playwright will download its own for macOS"
|
||||
|
||||
export LD_LIBRARY_PATH="${playwrightLibPath}:$LD_LIBRARY_PATH"
|
||||
|
||||
PLAYWRIGHT_BROWSERS_PATH="''${TMPDIR:-$HOME/.cache}/ms-playwright"
|
||||
export PLAYWRIGHT_BROWSERS_PATH
|
||||
|
||||
if [ ! -d "$PLAYWRIGHT_BROWSERS_PATH" ] || [ -z "$(ls -A "$PLAYWRIGHT_BROWSERS_PATH")" ]; then
|
||||
echo "🌐 Installing Playwright browsers (for macOS)..."
|
||||
pnpm exec playwright install chromium
|
||||
else
|
||||
echo "✅ Playwright browsers already installed (for macOS)."
|
||||
fi
|
||||
''}
|
||||
|
||||
${pkgs.lib.optionalString isLinux ''
|
||||
echo "Chromium path: ${pkgs.chromium}/bin/chromium"
|
||||
''}
|
||||
|
||||
if [ ! -d "node_modules" ]; then
|
||||
echo "📦 Installing pnpm dependencies..."
|
||||
pnpm install --frozen-lockfile # Use --frozen-lockfile for more consistent builds
|
||||
fi
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user