From ffad04acea7470780e8a2632aff67062d6b24654 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Wed, 15 Oct 2025 21:17:40 -0300 Subject: [PATCH 01/10] git hooks for all repos --- .github/workflows/check-shell.yml | 15 +-- .github/workflows/pr-assessment.yaml | 1 - .github/workflows/test.yml | 3 - .gitignore | 3 +- .vscode/extensions.json | 8 +- REUSE.toml | 2 +- flake.lock | 102 ++++++++++++++++--- flake.nix | 67 +++++++++--- test/bats/devshell/tauri/shellhook.test.bats | 3 +- test/fixture/.github/workflows/test.yml | 7 -- test/fixture/Cargo.toml | 4 +- test/fixture/README.md | 12 ++- test/fixture/REUSE.toml | 2 +- 13 files changed, 163 insertions(+), 66 deletions(-) diff --git a/.github/workflows/check-shell.yml b/.github/workflows/check-shell.yml index 6f63cb8..6fd386e 100644 --- a/.github/workflows/check-shell.yml +++ b/.github/workflows/check-shell.yml @@ -1,22 +1,18 @@ name: Rainix CI check shell on: [push] - jobs: rainix-check-shell: strategy: matrix: - os: [ - ubuntu-latest, - # intel mac - macos-13, - # apple silicon - macos-latest, - ] + os: [ubuntu-latest, + # intel mac + macos-13, + # apple silicon + macos-latest] fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - - uses: nixbuild/nix-quick-install-action@v30 with: nix_conf: | @@ -33,7 +29,6 @@ jobs: # before trying to save a new cache # 1G = 1073741824 gc-max-store-size-linux: 1G - - run: nix develop --command cargo release --version - run: nix develop --command flamegraph --help - run: nix develop --command graph --version diff --git a/.github/workflows/pr-assessment.yaml b/.github/workflows/pr-assessment.yaml index 71c5461..18e484f 100644 --- a/.github/workflows/pr-assessment.yaml +++ b/.github/workflows/pr-assessment.yaml @@ -3,7 +3,6 @@ on: pull_request: types: - closed - jobs: assess-pr-size-on-merge: uses: rainlanguage/github-chore/.github/workflows/pr-assessment.yml@main diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc4aabb..bbc3f0a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,5 @@ name: Rainix CI on: [push] - jobs: rainix: strategy: @@ -29,7 +28,6 @@ jobs: working-directory: test/fixture steps: - uses: actions/checkout@v4 - - uses: nixbuild/nix-quick-install-action@v30 with: nix_conf: | @@ -46,7 +44,6 @@ jobs: # before trying to save a new cache # 1G = 1073741824 gc-max-store-size-linux: 1G - - run: nix run ../..#rainix-sol-prelude - run: nix run ../..#rainix-rs-prelude - name: Run ${{ matrix.task }} diff --git a/.gitignore b/.gitignore index d38617e..6bfc3f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ result -.env \ No newline at end of file +.env +.pre-commit-config.yaml diff --git a/.vscode/extensions.json b/.vscode/extensions.json index fce5ab4..76d746c 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,5 @@ { - "recommendations": [ - "jnoortheen.nix-ide" - ] -} \ No newline at end of file + "recommendations": [ + "jnoortheen.nix-ide" + ] +} diff --git a/REUSE.toml b/REUSE.toml index 6a47568..80217e4 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -9,7 +9,7 @@ path = [ "REUSE.toml", ".github/**/", ".vscode/**/", - "test/**/" + "test/**/", ] SPDX-FileCopyrightText = "Copyright (c) 2020 thedavidmeister" SPDX-License-Identifier = "LicenseRef-DCL-1.0" diff --git a/flake.lock b/flake.lock index 13c4ebc..0f02b53 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -57,11 +73,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1758705030, - "narHash": "sha256-zYM8PiEXANNrtjfyGUc7w37/D/kCynp0cQS+wCQ77GI=", + "lastModified": 1762758214, + "narHash": "sha256-ZMmfyWLFDPuSPUGTLRUyO+YBbsLh1ezhfX8XH73BQ7M=", "owner": "shazow", "repo": "foundry.nix", - "rev": "b59a55014050110170023e3e1c277c1d4a2f055b", + "rev": "018aec114ac46c6ac68c27ac29bf20b03fb55d5d", "type": "github" }, "original": { @@ -70,6 +86,47 @@ "type": "github" } }, + "git-hooks-nix": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1762441963, + "narHash": "sha256-j+rNQ119ffYUkYt2YYS6rnd6Jh/crMZmbqpkGLXaEt0=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "8e7576e79b88c16d7ee3bbd112c8d90070832885", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1666753130, @@ -102,11 +159,27 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1758711836, - "narHash": "sha256-uBqPg7wNX2v6YUdTswH7wWU8wqb60cFZx0tHaWTGF30=", + "lastModified": 1759417375, + "narHash": "sha256-O7eHcgkQXJNygY6AypkF9tFhsoDQjpNEojw3eFs73Ow=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dc704e6102e76aad573f63b74c742cd96f8f1e6c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1762808364, + "narHash": "sha256-nwxa9s+cjXZyFuTdFSKP5enPmhLfVOnNLlMhF25Uyf4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "46f97b78e825ae762c0224e3983c47687436a498", + "rev": "e1ce86c3e40327779390e98edab843d4a1cc9224", "type": "github" }, "original": { @@ -115,7 +188,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1744536153, "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", @@ -131,7 +204,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_5": { "locked": { "lastModified": 1748662220, "narHash": "sha256-7gGa49iB9nCnFk4h/g9zwjlQAyjtpgcFkODjcOQS0Es=", @@ -151,7 +224,8 @@ "inputs": { "flake-utils": "flake-utils", "foundry": "foundry", - "nixpkgs": "nixpkgs_2", + "git-hooks-nix": "git-hooks-nix", + "nixpkgs": "nixpkgs_3", "nixpkgs-old": "nixpkgs-old", "rust-overlay": "rust-overlay", "solc": "solc" @@ -159,14 +233,14 @@ }, "rust-overlay": { "inputs": { - "nixpkgs": "nixpkgs_3" + "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1758681214, - "narHash": "sha256-8cW731vev6kfr58cILO2ZsjHwaPhm88dQ8Q6nTSjP9I=", + "lastModified": 1762742448, + "narHash": "sha256-XMxV0h13gg63s0sV6beihCIqdpcJhtbse6DHI743nvo=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "b12ed88d8d33d4f3cbc842bf29fad93bb1437299", + "rev": "7f3556887e3375dc26ff1601b57c93ee286f2c5e", "type": "github" }, "original": { @@ -178,7 +252,7 @@ "solc": { "inputs": { "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_5", "solc-macos-amd64-list-json": "solc-macos-amd64-list-json" }, "locked": { diff --git a/flake.nix b/flake.nix index 1d154b4..9db5990 100644 --- a/flake.nix +++ b/flake.nix @@ -9,9 +9,11 @@ solc.url = "github:hellwolf/solc.nix"; # old nixpkgs, pinned for webkitgtk and libsoup-2.4 needed for tauri shell and build nixpkgs-old.url = "github:nixos/nixpkgs?rev=48975d7f9b9960ed33c4e8561bcce20cc0c2de5b"; + git-hooks-nix.url = "github:cachix/git-hooks.nix"; }; - outputs = { self, nixpkgs, flake-utils, rust-overlay, foundry, solc, nixpkgs-old }: + outputs = + { nixpkgs, flake-utils, rust-overlay, foundry, solc, nixpkgs-old, git-hooks-nix, ... }: flake-utils.lib.eachDefaultSystem (system: let overlays = [ (import rust-overlay) foundry.overlay solc.overlay ]; @@ -38,9 +40,8 @@ pkgs.cargo-flamegraph ] ++ (pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [ # pkgs.glibc - ]) ++ (pkgs.lib.optionals pkgs.stdenv.isDarwin [ - pkgs.darwin.DarwinTools - ]); + ]) ++ (pkgs.lib.optionals pkgs.stdenv.isDarwin + [ pkgs.darwin.DarwinTools ]); sol-build-inputs = [ pkgs.git @@ -147,7 +148,7 @@ # https://ertt.ca/nix/shell-scripts/ mkTask = { name, body, additionalBuildInputs ? [ ] }: pkgs.symlinkJoin { - name = name; + inherit name; paths = [ ((pkgs.writeScriptBin name body).overrideAttrs (old: { buildCommand = '' @@ -348,15 +349,47 @@ additionalBuildInputs = [ pkgs.bats ]; }; + pre-commit = git-hooks-nix.lib.${system}.run { + src = ./.; + hooks = { + # Nix + nil.enable = true; + nixfmt-classic.enable = true; + deadnix.enable = true; + statix.enable = true; + statix.settings.ignore = [ "lib/" ]; + + # Rust + taplo.enable = true; + + # Conditional rustfmt - only runs if Cargo.toml exists + rustfmt-conditional = { + enable = true; + name = "rustfmt"; + entry = "${pkgs.writeShellScript "rustfmt-conditional" '' + if [ -f Cargo.toml ] || [ -f */Cargo.toml ]; then + exec ${rust-toolchain}/bin/cargo-fmt fmt -- --check "$@" + else + exit 0 + fi + ''}"; + files = "\\.rs$"; + pass_filenames = true; + }; + + # Misc + denofmt.enable = true; + yamlfmt.enable = true; + yamlfmt.settings.lint-only = false; + shellcheck.enable = true; + }; + }; + in { - pkgs = pkgs; - old-pkgs = old-pkgs; - rust-toolchain = rust-toolchain; - rust-build-inputs = rust-build-inputs; - sol-build-inputs = sol-build-inputs; - node-build-inputs = node-build-inputs; - mkTask = mkTask; - network-list = network-list; + checks.pre-commit = pre-commit; + + inherit pkgs old-pkgs rust-toolchain rust-build-inputs sol-build-inputs + node-build-inputs mkTask network-list; packages = { inherit rainix-sol-prelude rainix-sol-static rainix-sol-test @@ -368,8 +401,10 @@ devShells.default = pkgs.mkShell { buildInputs = sol-build-inputs ++ rust-build-inputs ++ node-build-inputs ++ rainix-tasks ++ subgraph-tasks - ++ [ the-graph goldsky pkgs.sqlite ]; + ++ [ the-graph goldsky pkgs.sqlite pkgs.pre-commit ] + ++ pre-commit.enabledPackages; shellHook = '' + ${pre-commit.shellHook} ${source-dotenv} if [ -f ./package.json ]; then @@ -382,8 +417,10 @@ devShells.tauri-shell = pkgs.mkShell { packages = [ tauri-shellhook-test ]; buildInputs = sol-build-inputs ++ rust-build-inputs - ++ node-build-inputs ++ tauri-build-inputs; + ++ node-build-inputs ++ tauri-build-inputs ++ [ pkgs.pre-commit ] + ++ pre-commit.enabledPackages; shellHook = '' + ${pre-commit.shellHook} ${source-dotenv} export TMP_BASE64_PATH=$(mktemp -d) diff --git a/test/bats/devshell/tauri/shellhook.test.bats b/test/bats/devshell/tauri/shellhook.test.bats index 1f2dbdd..4794c7e 100644 --- a/test/bats/devshell/tauri/shellhook.test.bats +++ b/test/bats/devshell/tauri/shellhook.test.bats @@ -3,7 +3,8 @@ } @test "nixpkgs apple_sdk xcrun should NOT be in PATH" { - ! bash -c 'echo "$PATH" | grep -q "xcrun"' + # shellcheck disable=SC2016 + run ! bash -c 'echo "$PATH" | grep -q "xcrun"' } @test "should have access to native macos xcrun" { diff --git a/test/fixture/.github/workflows/test.yml b/test/fixture/.github/workflows/test.yml index 9282e82..f5cc201 100644 --- a/test/fixture/.github/workflows/test.yml +++ b/test/fixture/.github/workflows/test.yml @@ -1,33 +1,26 @@ name: test - on: workflow_dispatch - env: FOUNDRY_PROFILE: ci - jobs: check: strategy: fail-fast: true - name: Foundry project runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: recursive - - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: version: nightly - - name: Run Forge build run: | forge --version forge build --sizes id: build - - name: Run Forge tests run: | forge test -vvv diff --git a/test/fixture/Cargo.toml b/test/fixture/Cargo.toml index fc7afe7..c5b7fed 100644 --- a/test/fixture/Cargo.toml +++ b/test/fixture/Cargo.toml @@ -1,5 +1,3 @@ [workspace] resolver = "2" -members = [ - "crates/test-rs" -] \ No newline at end of file +members = ["crates/test-rs"] diff --git a/test/fixture/README.md b/test/fixture/README.md index 9265b45..fb26d44 100644 --- a/test/fixture/README.md +++ b/test/fixture/README.md @@ -1,13 +1,15 @@ ## Foundry -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** +**Foundry is a blazing fast, portable and modular toolkit for Ethereum +application development written in Rust.** Foundry consists of: -- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). -- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. -- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. -- **Chisel**: Fast, utilitarian, and verbose solidity REPL. +- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). +- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending + transactions and getting chain data. +- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. +- **Chisel**: Fast, utilitarian, and verbose solidity REPL. ## Documentation diff --git a/test/fixture/REUSE.toml b/test/fixture/REUSE.toml index 6ef901d..8fb9753 100644 --- a/test/fixture/REUSE.toml +++ b/test/fixture/REUSE.toml @@ -11,7 +11,7 @@ path = [ "foundry.toml", "crates/**/", "devshell/**/", - "foundry.lock" + "foundry.lock", ] SPDX-FileCopyrightText = "Copyright (c) 2020 thedavidmeister" SPDX-License-Identifier = "LicenseRef-DCL-1.0" From 11ff3bf4fdf067d667dfc3e054cadbe858c759c2 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Wed, 15 Oct 2025 21:24:45 -0300 Subject: [PATCH 02/10] run flake check in ci --- .github/workflows/check-shell.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/check-shell.yml b/.github/workflows/check-shell.yml index 6fd386e..2df2815 100644 --- a/.github/workflows/check-shell.yml +++ b/.github/workflows/check-shell.yml @@ -29,6 +29,7 @@ jobs: # before trying to save a new cache # 1G = 1073741824 gc-max-store-size-linux: 1G + - run: nix flake check - run: nix develop --command cargo release --version - run: nix develop --command flamegraph --help - run: nix develop --command graph --version From b0a6b4e6c8b57c11aa14a555f0ac95b4376348b0 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Wed, 15 Oct 2025 21:28:40 -0300 Subject: [PATCH 03/10] --impure --- .github/workflows/check-shell.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-shell.yml b/.github/workflows/check-shell.yml index 2df2815..c1c2b4e 100644 --- a/.github/workflows/check-shell.yml +++ b/.github/workflows/check-shell.yml @@ -29,7 +29,7 @@ jobs: # before trying to save a new cache # 1G = 1073741824 gc-max-store-size-linux: 1G - - run: nix flake check + - run: NIXPKGS_ALLOW_INSECURE=1 nix flake check --impure - run: nix develop --command cargo release --version - run: nix develop --command flamegraph --help - run: nix develop --command graph --version From 03b0c9d0529e7ebb48b403184b457922fb4eecfd Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Thu, 16 Oct 2025 23:59:43 -0300 Subject: [PATCH 04/10] no --check in cargo fmt --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 9db5990..5a6143f 100644 --- a/flake.nix +++ b/flake.nix @@ -368,7 +368,7 @@ name = "rustfmt"; entry = "${pkgs.writeShellScript "rustfmt-conditional" '' if [ -f Cargo.toml ] || [ -f */Cargo.toml ]; then - exec ${rust-toolchain}/bin/cargo-fmt fmt -- --check "$@" + exec ${rust-toolchain}/bin/cargo-fmt fmt "$@" else exit 0 fi From 2b6b008697e6dfcce0dc84b4fd900d7d7231e8bd Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Fri, 17 Oct 2025 00:52:37 -0300 Subject: [PATCH 05/10] fix cargo fmt --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 5a6143f..3112fc7 100644 --- a/flake.nix +++ b/flake.nix @@ -368,13 +368,13 @@ name = "rustfmt"; entry = "${pkgs.writeShellScript "rustfmt-conditional" '' if [ -f Cargo.toml ] || [ -f */Cargo.toml ]; then - exec ${rust-toolchain}/bin/cargo-fmt fmt "$@" + exec ${rust-toolchain}/bin/cargo-fmt fmt else exit 0 fi ''}"; files = "\\.rs$"; - pass_filenames = true; + pass_filenames = false; }; # Misc From fc4a7b539291e8227bce3b7a85479692f9e3e2a9 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Fri, 12 Dec 2025 14:28:09 -0300 Subject: [PATCH 06/10] fix prettier --- flake.nix | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 3112fc7..9161c63 100644 --- a/flake.nix +++ b/flake.nix @@ -8,12 +8,13 @@ foundry.url = "github:shazow/foundry.nix"; solc.url = "github:hellwolf/solc.nix"; # old nixpkgs, pinned for webkitgtk and libsoup-2.4 needed for tauri shell and build - nixpkgs-old.url = "github:nixos/nixpkgs?rev=48975d7f9b9960ed33c4e8561bcce20cc0c2de5b"; + nixpkgs-old.url = + "github:nixos/nixpkgs?rev=48975d7f9b9960ed33c4e8561bcce20cc0c2de5b"; git-hooks-nix.url = "github:cachix/git-hooks.nix"; }; - outputs = - { nixpkgs, flake-utils, rust-overlay, foundry, solc, nixpkgs-old, git-hooks-nix, ... }: + outputs = { nixpkgs, flake-utils, rust-overlay, foundry, solc, nixpkgs-old + , git-hooks-nix, ... }: flake-utils.lib.eachDefaultSystem (system: let overlays = [ (import rust-overlay) foundry.overlay solc.overlay ]; @@ -361,7 +362,6 @@ # Rust taplo.enable = true; - # Conditional rustfmt - only runs if Cargo.toml exists rustfmt-conditional = { enable = true; @@ -377,8 +377,15 @@ pass_filenames = false; }; + # TypeScript + eslint.enable = true; + prettier.enable = true; + # Misc - denofmt.enable = true; + denofmt = { + enable = true; + excludes = [ ".*\\.ts$" ".*\\.js$" ".*\\.json$" ]; + }; yamlfmt.enable = true; yamlfmt.settings.lint-only = false; shellcheck.enable = true; From 89c4aafeec60937cb8905befc454366bd8deb163 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Fri, 12 Dec 2025 15:38:27 -0300 Subject: [PATCH 07/10] conditional eslint and prettier hooks --- flake.nix | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 9161c63..7889eec 100644 --- a/flake.nix +++ b/flake.nix @@ -377,9 +377,75 @@ pass_filenames = false; }; - # TypeScript - eslint.enable = true; - prettier.enable = true; + # TypeScript/JavaScript - conditional, only runs if config exists + eslint-conditional = { + enable = true; + name = "eslint"; + entry = "${pkgs.writeShellScript "eslint-conditional" '' + set -euxo pipefail + + find_eslint_config() { + local dir="$1" + while [ "$dir" != "/" ] && [ "$dir" != "." ]; do + if [ -f "$dir/eslint.config.js" ] || [ -f "$dir/eslint.config.mjs" ] || [ -f "$dir/eslint.config.cjs" ]; then + echo "$dir" + return 0 + fi + dir="$(dirname "$dir")" + done + return 1 + } + + declare -A config_files + for file in "$@"; do + dir="$(dirname "$(realpath "$file")")" + config_dir="$(find_eslint_config "$dir")" || continue + config_files["$config_dir"]+=" $file" + done + + for config_dir in "''${!config_files[@]}"; do + files="''${config_files[$config_dir]}" + (cd "$config_dir" && ${pkgs.eslint}/bin/eslint --fix $files) + done + ''}"; + files = "\\.(js|mjs|cjs|ts|tsx|svelte)$"; + pass_filenames = true; + }; + + prettier-conditional = { + enable = true; + name = "prettier"; + entry = "${pkgs.writeShellScript "prettier-conditional" '' + set -euxo pipefail + + find_prettier_root() { + local dir="$1" + while [ "$dir" != "/" ] && [ "$dir" != "." ]; do + if [ -f "$dir/.prettierrc" ] || [ -f "$dir/.prettierrc.json" ] || [ -f "$dir/.prettierrc.js" ] || [ -f "$dir/prettier.config.js" ] || [ -f "$dir/package.json" ]; then + echo "$dir" + return 0 + fi + dir="$(dirname "$dir")" + done + return 1 + } + + declare -A config_files + for file in "$@"; do + dir="$(dirname "$(realpath "$file")")" + config_dir="$(find_prettier_root "$dir")" || continue + config_files["$config_dir"]+=" $file" + done + + for config_dir in "''${!config_files[@]}"; do + files="''${config_files[$config_dir]}" + (cd "$config_dir" && npx prettier --ignore-unknown --list-different --write $files) + done + ''}"; + files = + "\\.(js|mjs|cjs|ts|tsx|json|css|scss|md|yaml|yml|svelte|html)$"; + pass_filenames = true; + }; # Misc denofmt = { From 49c4a3e151f232953e1c2370ab526f74c25eb6d2 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Fri, 12 Dec 2025 16:09:55 -0300 Subject: [PATCH 08/10] revert broken eslint and prettier hooks --- flake.nix | 70 ------------------------------------------------------- 1 file changed, 70 deletions(-) diff --git a/flake.nix b/flake.nix index 7889eec..7a7f737 100644 --- a/flake.nix +++ b/flake.nix @@ -377,76 +377,6 @@ pass_filenames = false; }; - # TypeScript/JavaScript - conditional, only runs if config exists - eslint-conditional = { - enable = true; - name = "eslint"; - entry = "${pkgs.writeShellScript "eslint-conditional" '' - set -euxo pipefail - - find_eslint_config() { - local dir="$1" - while [ "$dir" != "/" ] && [ "$dir" != "." ]; do - if [ -f "$dir/eslint.config.js" ] || [ -f "$dir/eslint.config.mjs" ] || [ -f "$dir/eslint.config.cjs" ]; then - echo "$dir" - return 0 - fi - dir="$(dirname "$dir")" - done - return 1 - } - - declare -A config_files - for file in "$@"; do - dir="$(dirname "$(realpath "$file")")" - config_dir="$(find_eslint_config "$dir")" || continue - config_files["$config_dir"]+=" $file" - done - - for config_dir in "''${!config_files[@]}"; do - files="''${config_files[$config_dir]}" - (cd "$config_dir" && ${pkgs.eslint}/bin/eslint --fix $files) - done - ''}"; - files = "\\.(js|mjs|cjs|ts|tsx|svelte)$"; - pass_filenames = true; - }; - - prettier-conditional = { - enable = true; - name = "prettier"; - entry = "${pkgs.writeShellScript "prettier-conditional" '' - set -euxo pipefail - - find_prettier_root() { - local dir="$1" - while [ "$dir" != "/" ] && [ "$dir" != "." ]; do - if [ -f "$dir/.prettierrc" ] || [ -f "$dir/.prettierrc.json" ] || [ -f "$dir/.prettierrc.js" ] || [ -f "$dir/prettier.config.js" ] || [ -f "$dir/package.json" ]; then - echo "$dir" - return 0 - fi - dir="$(dirname "$dir")" - done - return 1 - } - - declare -A config_files - for file in "$@"; do - dir="$(dirname "$(realpath "$file")")" - config_dir="$(find_prettier_root "$dir")" || continue - config_files["$config_dir"]+=" $file" - done - - for config_dir in "''${!config_files[@]}"; do - files="''${config_files[$config_dir]}" - (cd "$config_dir" && npx prettier --ignore-unknown --list-different --write $files) - done - ''}"; - files = - "\\.(js|mjs|cjs|ts|tsx|json|css|scss|md|yaml|yml|svelte|html)$"; - pass_filenames = true; - }; - # Misc denofmt = { enable = true; From 6e14de54456eb33821c2f334cf4d250bcc22c121 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Thu, 29 Jan 2026 22:42:04 +0400 Subject: [PATCH 09/10] ignore bun.nix in deadnix --- flake.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flake.nix b/flake.nix index 7a7f737..1ab4c16 100644 --- a/flake.nix +++ b/flake.nix @@ -356,7 +356,11 @@ # Nix nil.enable = true; nixfmt-classic.enable = true; + deadnix.enable = true; + # excluded for files generated by bun2nix + deadnix.excludes = [ "bun\\.nix$" ]; + statix.enable = true; statix.settings.ignore = [ "lib/" ]; From 2315977a237a19724413382dcbb270e647a534dc Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Wed, 11 Mar 2026 00:02:14 +0700 Subject: [PATCH 10/10] nix flake update --- flake.lock | 58 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/flake.lock b/flake.lock index 91ebc78..1c332c7 100644 --- a/flake.lock +++ b/flake.lock @@ -3,15 +3,15 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1747046372, - "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", - "owner": "edolstra", + "lastModified": 1767039857, + "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", + "owner": "NixOS", "repo": "flake-compat", - "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", "type": "github" }, "original": { - "owner": "edolstra", + "owner": "NixOS", "repo": "flake-compat", "type": "github" } @@ -73,11 +73,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1762758214, - "narHash": "sha256-ZMmfyWLFDPuSPUGTLRUyO+YBbsLh1ezhfX8XH73BQ7M=", + "lastModified": 1773126975, + "narHash": "sha256-f3bmp4aJTAaruN5SNzz/uwZ4zUTBRanUz8BLfLxVC20=", "owner": "shazow", "repo": "foundry.nix", - "rev": "018aec114ac46c6ac68c27ac29bf20b03fb55d5d", + "rev": "56aa74fe1db1c57600328eb87fdd5ad33f54beb8", "type": "github" }, "original": { @@ -93,11 +93,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1762441963, - "narHash": "sha256-j+rNQ119ffYUkYt2YYS6rnd6Jh/crMZmbqpkGLXaEt0=", + "lastModified": 1772893680, + "narHash": "sha256-JDqZMgxUTCq85ObSaFw0HhE+lvdOre1lx9iI6vYyOEs=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "8e7576e79b88c16d7ee3bbd112c8d90070832885", + "rev": "8baab586afc9c9b57645a734c820e4ac0a604af9", "type": "github" }, "original": { @@ -159,11 +159,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1759417375, - "narHash": "sha256-O7eHcgkQXJNygY6AypkF9tFhsoDQjpNEojw3eFs73Ow=", + "lastModified": 1770073757, + "narHash": "sha256-Vy+G+F+3E/Tl+GMNgiHl9Pah2DgShmIUBJXmbiQPHbI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "dc704e6102e76aad573f63b74c742cd96f8f1e6c", + "rev": "47472570b1e607482890801aeaf29bfb749884f6", "type": "github" }, "original": { @@ -175,11 +175,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1762808364, - "narHash": "sha256-nwxa9s+cjXZyFuTdFSKP5enPmhLfVOnNLlMhF25Uyf4=", + "lastModified": 1773161593, + "narHash": "sha256-oM5Nhob3rAu3CVNr/FhDreDlIyLNL239kZYtDVm6+m8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "e1ce86c3e40327779390e98edab843d4a1cc9224", + "rev": "d292ac24f957a689b2f0e48a44cdb41fa4c59046", "type": "github" }, "original": { @@ -206,11 +206,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1766653575, - "narHash": "sha256-TPgxCS7+hWc4kPhzkU5dD2M5UuPhLuuaMNZ/IpwKQvI=", + "lastModified": 1771923393, + "narHash": "sha256-Fy0+UXELv9hOE8WjYhJt8fMDLYTU2Dqn3cX4BwoGBos=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3c1016e6acd16ad96053116d0d3043029c9e2649", + "rev": "ea7f1f06811ce7fcc81d6c6fd4213150c23edcf2", "type": "github" }, "original": { @@ -236,11 +236,11 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1762742448, - "narHash": "sha256-XMxV0h13gg63s0sV6beihCIqdpcJhtbse6DHI743nvo=", + "lastModified": 1773115373, + "narHash": "sha256-bfK9FJFcQth6f3ydYggS5m0z2NRGF/PY6Y2XgZDJ6pg=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "7f3556887e3375dc26ff1601b57c93ee286f2c5e", + "rev": "1924b4672a2b8e4aee6e6652ec2e59a8d3c5648e", "type": "github" }, "original": { @@ -256,11 +256,11 @@ "solc-macos-amd64-list-json": "solc-macos-amd64-list-json" }, "locked": { - "lastModified": 1768831671, - "narHash": "sha256-0mmlYRtZK+eomevkQCCH7PL8QlSuALZQsjLroCWGE08=", + "lastModified": 1772085240, + "narHash": "sha256-+NEcuhT2A0QQumVx9Ze6g2iuNicyuW028Jq/HUJHGh4=", "owner": "hellwolf", "repo": "solc.nix", - "rev": "80ad871b93d15c7bccf71617f78f73c2d291a9c7", + "rev": "d3cc119973e484ea366f4b997b404bb00d7829ca", "type": "github" }, "original": { @@ -272,13 +272,13 @@ "solc-macos-amd64-list-json": { "flake": false, "locked": { - "narHash": "sha256-P+ZslplK4cQ/wnV/wykVKb+yTCviI0eylA3sk9uHmRo=", + "narHash": "sha256-oEiXc95EghuYCudzkPA9XBFOnMdgWFfTO2/4XUfSTpc=", "type": "file", - "url": "https://github.com/argotorg/solc-bin/raw/a11f1ad/macosx-amd64/list.json" + "url": "https://github.com/argotorg/solc-bin/raw/83cb756/macosx-amd64/list.json" }, "original": { "type": "file", - "url": "https://github.com/argotorg/solc-bin/raw/a11f1ad/macosx-amd64/list.json" + "url": "https://github.com/argotorg/solc-bin/raw/83cb756/macosx-amd64/list.json" } }, "systems": {