2023-06-23 08:33:04 +02:00
|
|
|
{
|
|
|
|
description = "A Nix-flake-based Node.js development environment";
|
|
|
|
|
|
|
|
inputs = {
|
2024-11-22 07:21:53 +01:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
2023-06-23 08:33:04 +02:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2024-03-16 10:11:37 +01:00
|
|
|
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
|
2023-06-23 08:33:04 +02:00
|
|
|
};
|
|
|
|
|
2024-02-27 02:45:08 +01:00
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
flake-utils,
|
2024-03-16 10:11:37 +01:00
|
|
|
pre-commit-hooks,
|
2024-02-27 02:45:08 +01:00
|
|
|
}:
|
|
|
|
flake-utils.lib.eachDefaultSystem (system: let
|
2023-06-23 08:33:04 +02:00
|
|
|
overlays = [
|
|
|
|
(self: super: rec {
|
2023-12-06 03:23:49 +01:00
|
|
|
nodejs = super.nodejs_20;
|
2024-11-22 07:21:53 +01:00
|
|
|
pnpm = super.pnpm.override {inherit nodejs;};
|
2024-02-27 02:45:08 +01:00
|
|
|
yarn = super.yarn.override {inherit nodejs;};
|
2024-03-16 11:00:32 +01:00
|
|
|
prettier = super.nodePackages.prettier;
|
2023-06-23 08:33:04 +02:00
|
|
|
})
|
|
|
|
];
|
2024-02-27 02:45:08 +01:00
|
|
|
pkgs = import nixpkgs {inherit overlays system;};
|
|
|
|
pkgs_chromium = import nixpkgs {inherit system;};
|
2024-03-16 10:11:37 +01:00
|
|
|
packages = with pkgs; [
|
|
|
|
node2nix
|
|
|
|
nodejs
|
|
|
|
pnpm
|
|
|
|
yarn
|
2024-03-16 11:00:32 +01:00
|
|
|
prettier
|
2024-03-16 10:11:37 +01:00
|
|
|
|
|
|
|
git
|
|
|
|
typos
|
|
|
|
alejandra
|
|
|
|
];
|
2024-02-27 02:45:08 +01:00
|
|
|
in {
|
2024-03-16 10:11:37 +01:00
|
|
|
checks = {
|
|
|
|
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
|
|
|
src = ./.;
|
|
|
|
hooks = {
|
|
|
|
typos.enable = true; # Source code spell checker
|
|
|
|
alejandra.enable = true; # Nix linter
|
2024-03-16 11:00:32 +01:00
|
|
|
prettier.enable = true; # Markdown & TS formatter
|
2024-03-16 10:11:37 +01:00
|
|
|
};
|
|
|
|
settings = {
|
|
|
|
typos = {
|
|
|
|
write = true; # Automatically fix typos
|
|
|
|
ignored-words = [];
|
|
|
|
};
|
2024-03-16 11:00:32 +01:00
|
|
|
prettier = {
|
|
|
|
write = true; # Automatically format files
|
|
|
|
configPath = "./.prettierrc.yaml";
|
|
|
|
};
|
2024-03-16 10:11:37 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-06-23 08:33:04 +02:00
|
|
|
devShells.default = pkgs.mkShell {
|
2024-02-27 02:45:08 +01:00
|
|
|
inherit packages;
|
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
echo "node `${pkgs.nodejs}/bin/node --version`"
|
2024-03-16 10:11:37 +01:00
|
|
|
${self.checks.${system}.pre-commit-check.shellHook}
|
2024-02-27 02:45:08 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
devShells.export-pdf = pkgs.mkShell {
|
|
|
|
inherit packages;
|
2023-06-23 08:33:04 +02:00
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
echo "node `${pkgs.nodejs}/bin/node --version`"
|
2023-08-05 09:05:56 +02:00
|
|
|
|
|
|
|
# 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 16:19:17 +01:00
|
|
|
export PUPPETEER_EXECUTABLE_PATH=${pkgs_chromium.chromium.outPath}/bin/chromium
|
2023-06-23 08:33:04 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
});
|
2023-08-05 09:05:56 +02:00
|
|
|
}
|