From 1102e5dcc0b6cda0a9410c57c523178bea3697d4 Mon Sep 17 00:00:00 2001 From: Ryan Bas Date: Mon, 11 May 2026 22:11:50 -0600 Subject: [PATCH 1/2] feat: add flake.nix for reproducible dev environment Adds a Nix flake that provides Node 24, pnpm, and lefthook in a dev shell. Includes .envrc for automatic direnv activation and adds .direnv/ to .gitignore. Co-Authored-By: Claude Opus 4.6 (1M context) --- .envrc | 1 + .gitignore | 1 + flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 9fd68e8..0f71453 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ elm-stuff/ *.zip packged/ out-tsc/ +.direnv/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e9e04e4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1778458615, + "narHash": "sha256-cY07EsdhBJ8tFXPzDYevgqxRev9ZLxFonuq9wmq5kwg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c6e5ca3c836a5f4dd9af9f2c1fc1c38f0fac988a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0286b5e --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "wolfcola-devtools development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + nodejs_24 + pnpm + lefthook + ]; + + shellHook = '' + echo "wolfcola-devtools dev shell" + echo " node $(node --version)" + echo " pnpm $(pnpm --version)" + ''; + }; + } + ); +} From 4ba462c5067fbcb3ac51969bcb231a26630a608f Mon Sep 17 00:00:00 2001 From: Ryan Bas Date: Mon, 11 May 2026 22:20:21 -0600 Subject: [PATCH 2/2] feat: optimize flake with corepack, auto-install, and formatter - Replace flake-utils with lightweight nix-systems/default - Swap Nix-provided pnpm for corepack (respects packageManager pin) - Auto-install deps when node_modules is missing or stale - Add nix fmt via nixfmt - Gitignore .corepack/ directory Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 1 + flake.lock | 22 ++------------------- flake.nix | 58 +++++++++++++++++++++++++++++++++--------------------- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 0f71453..e26b234 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ elm-stuff/ packged/ out-tsc/ .direnv/ +.corepack/ diff --git a/flake.lock b/flake.lock index e9e04e4..c9c37b3 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1778458615, @@ -36,8 +18,8 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "systems": "systems" } }, "systems": { diff --git a/flake.nix b/flake.nix index 0286b5e..ab19998 100644 --- a/flake.nix +++ b/flake.nix @@ -3,34 +3,48 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; + systems.url = "github:nix-systems/default"; }; outputs = { nixpkgs, - flake-utils, + systems, ... }: - flake-utils.lib.eachDefaultSystem ( - system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - devShells.default = pkgs.mkShell { - packages = with pkgs; [ - nodejs_24 - pnpm - lefthook - ]; + let + eachSystem = nixpkgs.lib.genAttrs (import systems); + in + { + devShells = eachSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = pkgs.mkShell { + packages = with pkgs; [ + nodejs_24 + corepack + lefthook + ]; + + shellHook = '' + corepack enable --install-directory "$PWD/.corepack" >/dev/null 2>&1 + export PATH="$PWD/.corepack:$PATH" + + if [ ! -d node_modules ]; then + echo "node_modules missing — running pnpm install..." + pnpm install + elif [ pnpm-lock.yaml -nt node_modules ]; then + echo "pnpm-lock.yaml is newer than node_modules — running pnpm install..." + pnpm install + fi + ''; + }; + } + ); - shellHook = '' - echo "wolfcola-devtools dev shell" - echo " node $(node --version)" - echo " pnpm $(pnpm --version)" - ''; - }; - } - ); + formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt); + }; }