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..e26b234 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ elm-stuff/ *.zip packged/ out-tsc/ +.direnv/ +.corepack/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c9c37b3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "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": { + "nixpkgs": "nixpkgs", + "systems": "systems" + } + }, + "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..ab19998 --- /dev/null +++ b/flake.nix @@ -0,0 +1,50 @@ +{ + description = "wolfcola-devtools development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + systems.url = "github:nix-systems/default"; + }; + + outputs = + { + nixpkgs, + systems, + ... + }: + 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 + ''; + }; + } + ); + + formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt); + }; +}