nixos-and-flakes-book/flake.nix

48 lines
1.3 KiB
Nix
Raw Normal View History

{
description = "A Nix-flake-based Node.js development environment";
inputs = {
2023-12-08 15:19:17 +00:00
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
};
2024-02-27 01:45:08 +00:00
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [
(self: super: rec {
2023-12-06 02:23:49 +00:00
nodejs = super.nodejs_20;
pnpm = super.nodePackages.pnpm;
2024-02-27 01:45:08 +00:00
yarn = super.yarn.override {inherit nodejs;};
})
];
2024-02-27 01:45:08 +00:00
pkgs = import nixpkgs {inherit overlays system;};
pkgs_chromium = import nixpkgs {inherit system;};
packages = with pkgs; [node2nix nodejs pnpm yarn git];
in {
devShells.default = pkgs.mkShell {
2024-02-27 01:45:08 +00:00
inherit packages;
shellHook = ''
echo "node `${pkgs.nodejs}/bin/node --version`"
'';
};
devShells.export-pdf = pkgs.mkShell {
inherit packages;
shellHook = ''
echo "node `${pkgs.nodejs}/bin/node --version`"
# Set Puppeteer to not download Chrome, cause it doesn't work on NixOS
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
# Set Puppeteer to use Chromium from Nixpkgs
2023-12-08 15:19:17 +00:00
export PUPPETEER_EXECUTABLE_PATH=${pkgs_chromium.chromium.outPath}/bin/chromium
'';
};
});
}