diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index e51e730..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: "Test" -on: - pull_request: - push: -jobs: - tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v30 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - name: build statix - run: nix build -L - - name: test statix - run: nix flake check - - name: build statix and install statix in flake-compat mode - run: nix-env -if default.nix diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..406105c --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,72 @@ +{ + "jobs": { + "check": { + "needs": "get-check-names", + "runs-on": "ubuntu-latest", + "steps": [ + { + "uses": "actions/checkout@v4" + }, + { + "uses": "cachix/install-nix-action@v31", + "with": { + "github_access_token": "${{ secrets.GITHUB_TOKEN }}" + } + }, + { + "run": "nix --accept-flake-config build '.#checks.x86_64-linux.\"${{ matrix.checks }}\"'\n" + } + ], + "strategy": { + "matrix": { + "checks": "${{ fromJson(needs.get-check-names.outputs.checks) }}" + } + } + }, + "get-check-names": { + "outputs": { + "checks": "${{ steps.get-check-names.outputs.checks }}" + }, + "runs-on": "ubuntu-latest", + "steps": [ + { + "uses": "actions/checkout@v4" + }, + { + "uses": "cachix/install-nix-action@v31", + "with": { + "github_access_token": "${{ secrets.GITHUB_TOKEN }}" + } + }, + { + "id": "get-check-names", + "run": "checks=\"$(nix --accept-flake-config eval --json .#checks.x86_64-linux --apply builtins.attrNames)\"\necho \"checks=$checks\" >> $GITHUB_OUTPUT\n" + } + ] + }, + "legacy": { + "name": "Build statix via flake-compat and install it using `nix-env`", + "runs-on": "ubuntu-latest", + "steps": [ + { + "uses": "actions/checkout@v4" + }, + { + "uses": "cachix/install-nix-action@v31", + "with": { + "github_access_token": "${{ secrets.GITHUB_TOKEN }}" + } + }, + { + "run": "nix-env --install --file default.nix" + } + ] + } + }, + "name": "Check", + "on": { + "pull_request": {}, + "push": {}, + "workflow_call": {} + } +} diff --git a/.gitignore b/.gitignore index e444732..6ff7792 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ +/.pre-commit-config.yaml +/result /target -.envrc -.direnv -result diff --git a/dev-flake/flake.lock b/dev-flake/flake.lock new file mode 100644 index 0000000..5809e50 --- /dev/null +++ b/dev-flake/flake.lock @@ -0,0 +1,149 @@ +{ + "nodes": { + "files": { + "locked": { + "lastModified": 1750263550, + "narHash": "sha256-EW/QJ8i/13GgiynBb6zOMxhLU1uEkRqmzbIDEP23yVA=", + "owner": "mightyiam", + "repo": "files", + "rev": "5f4ef1fd1f9012354a9748be093e277675d10f07", + "type": "github" + }, + "original": { + "owner": "mightyiam", + "repo": "files", + "type": "github" + } + }, + "flake-compat_dedupe": { + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "flake-compat_dedupe" + ], + "gitignore": [ + "gitignore_dedupe" + ], + "nixpkgs": [ + "nixpkgs_dedupe" + ] + }, + "locked": { + "lastModified": 1750779888, + "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore_dedupe": { + "inputs": { + "nixpkgs": [ + "nixpkgs_dedupe" + ] + }, + "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" + } + }, + "make-shell": { + "inputs": { + "flake-compat": [ + "flake-compat_dedupe" + ] + }, + "locked": { + "lastModified": 1733933815, + "narHash": "sha256-9JjM7eT66W4NJAXpGUsdyAFXhBxFWR2Z9LZwUa7Hli0=", + "owner": "nicknovitski", + "repo": "make-shell", + "rev": "ffeceae9956df03571ea8e96ef77c2924f13a63c", + "type": "github" + }, + "original": { + "owner": "nicknovitski", + "repo": "make-shell", + "type": "github" + } + }, + "nixpkgs_dedupe": { + "locked": { + "lastModified": 1751949589, + "narHash": "sha256-mgFxAPLWw0Kq+C8P3dRrZrOYEQXOtKuYVlo9xvPntt8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b008d60392981ad674e04016d25619281550a9d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "files": "files", + "flake-compat_dedupe": "flake-compat_dedupe", + "git-hooks": "git-hooks", + "gitignore_dedupe": "gitignore_dedupe", + "make-shell": "make-shell", + "nixpkgs_dedupe": "nixpkgs_dedupe", + "treefmt": "treefmt" + } + }, + "treefmt": { + "inputs": { + "nixpkgs": [ + "nixpkgs_dedupe" + ] + }, + "locked": { + "lastModified": 1750931469, + "narHash": "sha256-0IEdQB1nS+uViQw4k3VGUXntjkDp7aAlqcxdewb/hAc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "ac8e6f32e11e9c7f153823abc3ab007f2a65d3e1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/dev-flake/flake.nix b/dev-flake/flake.nix new file mode 100644 index 0000000..f363843 --- /dev/null +++ b/dev-flake/flake.nix @@ -0,0 +1,28 @@ +{ + inputs = { + git-hooks = { + url = "github:cachix/git-hooks.nix"; + inputs = { + flake-compat.follows = "flake-compat_dedupe"; + gitignore.follows = "gitignore_dedupe"; + nixpkgs.follows = "nixpkgs_dedupe"; + }; + }; + make-shell = { + url = "github:nicknovitski/make-shell"; + inputs.flake-compat.follows = "flake-compat_dedupe"; + }; + nixpkgs_dedupe.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + files.url = "github:mightyiam/files"; + flake-compat_dedupe.url = "github:edolstra/flake-compat"; + gitignore_dedupe = { + url = "github:hercules-ci/gitignore.nix"; + inputs.nixpkgs.follows = "nixpkgs_dedupe"; + }; + treefmt = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs_dedupe"; + }; + }; + outputs = _: { }; +} diff --git a/docs/flake-part.nix b/docs/flake-part.nix new file mode 100644 index 0000000..c3d7a10 --- /dev/null +++ b/docs/flake-part.nix @@ -0,0 +1,3 @@ +{ + partitions.dev.module.perSystem.treefmt.settings.global.excludes = [ "docs/*.txt" ]; +} diff --git a/flake-parts/cachix.nix b/flake-parts/cachix.nix new file mode 100644 index 0000000..7d4ae55 --- /dev/null +++ b/flake-parts/cachix.nix @@ -0,0 +1,25 @@ +{ lib, ... }: +{ + perSystem = + { pkgs, ... }: + { + apps.cachix-push = { + type = "app"; + program = lib.getExe ( + pkgs.writeShellApplication { + name = "cachix-push"; + runtimeInputs = with pkgs; [ + nix + jq + cachix + ]; + text = '' + nix build --json \ + | jq -r '.[].outputs | to_entries[].value' \ + | cachix push statix + ''; + } + ); + }; + }; +} diff --git a/flake-parts/ci.nix b/flake-parts/ci.nix new file mode 100644 index 0000000..cc12794 --- /dev/null +++ b/flake-parts/ci.nix @@ -0,0 +1,97 @@ +let + filePath = ".github/workflows/check.yaml"; + + ids = { + jobs = { + getCheckNames = "get-check-names"; + check = "check"; + }; + steps.getCheckNames = "get-check-names"; + outputs = { + jobs.getCheckNames = "checks"; + steps.getCheckNames = "checks"; + }; + }; + + matrixParam = "checks"; + + nixArgs = "--accept-flake-config"; + + runner = { + name = "ubuntu-latest"; + system = "x86_64-linux"; + }; + + steps = { + checkout.uses = "actions/checkout@v4"; + cachixInstallNix = { + uses = "cachix/install-nix-action@v31"; + "with".github_access_token = "\${{ secrets.GITHUB_TOKEN }}"; + }; + }; +in +{ + partitions.dev.module = { + perSystem = + { pkgs, ... }: + { + files.files = [ + { + path_ = filePath; + drv = pkgs.writers.writeJSON "gh-actions-workflow-check.yaml" { + name = "Check"; + on = { + pull_request = { }; + push = { }; + workflow_call = { }; + }; + jobs = { + ${ids.jobs.getCheckNames} = { + runs-on = runner.name; + outputs.${ids.outputs.jobs.getCheckNames} = "\${{ steps.${ids.steps.getCheckNames}.outputs.${ids.outputs.steps.getCheckNames} }}"; + steps = [ + steps.checkout + steps.cachixInstallNix + { + id = ids.steps.getCheckNames; + run = '' + checks="$(nix ${nixArgs} eval --json .#checks.${runner.system} --apply builtins.attrNames)" + echo "${ids.outputs.steps.getCheckNames}=$checks" >> $GITHUB_OUTPUT + ''; + } + ]; + }; + + ${ids.jobs.check} = { + needs = ids.jobs.getCheckNames; + runs-on = runner.name; + strategy.matrix.${matrixParam} = "\${{ fromJson(needs.${ids.jobs.getCheckNames}.outputs.${ids.outputs.jobs.getCheckNames}) }}"; + steps = [ + steps.checkout + steps.cachixInstallNix + { + run = '' + nix ${nixArgs} build '.#checks.${runner.system}."''${{ matrix.${matrixParam} }}"' + ''; + } + ]; + }; + + legacy = { + name = "Build statix via flake-compat and install it using `nix-env`"; + runs-on = runner.name; + steps = [ + steps.checkout + steps.cachixInstallNix + { run = "nix-env --install --file default.nix"; } + ]; + }; + }; + }; + } + ]; + + treefmt.settings.global.excludes = [ filePath ]; + }; + }; +} diff --git a/flake-parts/dev-shell.nix b/flake-parts/dev-shell.nix new file mode 100644 index 0000000..91689d5 --- /dev/null +++ b/flake-parts/dev-shell.nix @@ -0,0 +1,8 @@ +{ + partitionedAttrs.devShells = "dev"; + partitions.dev.module = devPartition: { + imports = [ + devPartition.inputs.make-shell.flakeModules.default + ]; + }; +} diff --git a/flake-parts/files.nix b/flake-parts/files.nix new file mode 100644 index 0000000..20efb26 --- /dev/null +++ b/flake-parts/files.nix @@ -0,0 +1,8 @@ +{ + partitions.dev.module = devPartition: { + imports = [ devPartition.inputs.files.flakeModules.default ]; + perSystem = psArgs: { + make-shells.default.packages = [ psArgs.config.files.writer.drv ]; + }; + }; +} diff --git a/flake-parts/fmt.nix b/flake-parts/fmt.nix new file mode 100644 index 0000000..c64458a --- /dev/null +++ b/flake-parts/fmt.nix @@ -0,0 +1,24 @@ +{ + partitionedAttrs.formatter = "dev"; + partitions.dev.module = devPartition: { + imports = [ devPartition.inputs.treefmt.flakeModule ]; + + perSystem = { + pre-commit.settings.hooks.treefmt.enable = true; + + treefmt = { + projectRootFile = "flake.nix"; + programs = { + nixfmt.enable = true; + prettier.enable = true; + # https://github.com/pappasam/toml-sort/issues/62 + # toml-sort = { + # enable = true; + # all = true; + # }; + }; + settings.on-unmatched = "fatal"; + }; + }; + }; +} diff --git a/flake-parts/git-hooks.nix b/flake-parts/git-hooks.nix new file mode 100644 index 0000000..1c41dd3 --- /dev/null +++ b/flake-parts/git-hooks.nix @@ -0,0 +1,18 @@ +{ + partitions.dev.module = devPartition: { + imports = [ devPartition.inputs.git-hooks.flakeModule ]; + + gitignore = [ + "/.pre-commit-config.yaml" + ]; + + perSystem = + { config, ... }: + { + make-shells.default.shellHook = config.pre-commit.installationScript; + pre-commit.check.enable = false; + treefmt.settings.global.excludes = [ ".pre-commit-config.yaml" ]; + }; + + }; +} diff --git a/flake-parts/git-ignore.nix b/flake-parts/git-ignore.nix new file mode 100644 index 0000000..160ece4 --- /dev/null +++ b/flake-parts/git-ignore.nix @@ -0,0 +1,26 @@ +{ lib, ... }: +{ + partitions.dev.module = devPartition: { + options.gitignore = lib.mkOption { + type = lib.types.listOf lib.types.singleLineStr; + apply = lib.flip lib.pipe [ + lib.naturalSort + lib.concatLines + ]; + }; + config = { + gitignore = [ "/result" ]; + + perSystem = + { pkgs, ... }: + { + files.files = [ + { + path_ = ".gitignore"; + drv = pkgs.writeText ".gitignore" devPartition.config.gitignore; + } + ]; + }; + }; + }; +} diff --git a/flake-parts/license.nix b/flake-parts/license.nix new file mode 100644 index 0000000..4c21267 --- /dev/null +++ b/flake-parts/license.nix @@ -0,0 +1,5 @@ +{ lib, ... }: +{ + _module.args.license = lib.licenses.mit; + partitions.dev.module.perSystem.treefmt.settings.global.excludes = [ "LICENSE" ]; +} diff --git a/flake-parts/overlay.nix b/flake-parts/overlay.nix new file mode 100644 index 0000000..fa61eea --- /dev/null +++ b/flake-parts/overlay.nix @@ -0,0 +1,10 @@ +{ inputs, ... }: +{ + imports = [ inputs.flake-parts.flakeModules.easyOverlay ]; + + perSystem = psArgs: { + overlayAttrs = { + inherit (psArgs.config.packages) statix statix-vim; + }; + }; +} diff --git a/flake-parts/rust.nix b/flake-parts/rust.nix new file mode 100644 index 0000000..3f962e0 --- /dev/null +++ b/flake-parts/rust.nix @@ -0,0 +1,29 @@ +{ + partitions.dev.module = { + gitignore = [ "/target" ]; + perSystem = + psArgs@{ pkgs, ... }: + { + make-shells.default = { + inputsFrom = [ psArgs.config.packages.default ]; + packages = [ + pkgs.bacon + pkgs.cargo-insta + pkgs.rust-analyzer + ]; + env = { + RUST_LOG = "info"; + RUST_BACKTRACE = 1; + }; + }; + treefmt = { + programs.rustfmt.enable = true; + settings.global.excludes = [ + "**/Cargo.toml" + "Cargo.toml" + "bin/tests/snapshots/*.snap" + ]; + }; + }; + }; +} diff --git a/flake-parts/statix.nix b/flake-parts/statix.nix new file mode 100644 index 0000000..15d4345 --- /dev/null +++ b/flake-parts/statix.nix @@ -0,0 +1,56 @@ +{ + lib, + root, + ... +}: +{ + perSystem = + psArgs@{ pkgs, ... }: + { + packages = { + statix = pkgs.rustPlatform.buildRustPackage { + pname = "statix"; + inherit ((lib.importTOML (root + "/bin/Cargo.toml")).package) version; + + src = lib.fileset.toSource { + inherit root; + fileset = lib.fileset.unions [ + (lib.fileset.fileFilter ( + file: + lib.any lib.id [ + (file.name == "Cargo.toml") + (file.hasExt "rs") + (file.hasExt "snap") + ] + ) root) + (root + "/Cargo.lock") + (root + "/bin/tests/data") + ]; + }; + cargoLock.lockFile = root + "/Cargo.lock"; + buildFeatures = [ "json" ]; + RUSTFLAGS = "--deny warnings"; + nativeCheckInputs = [ pkgs.clippy ]; + + postCheck = '' + echo "Starting postCheck" + cargo clippy + echo "Finished postCheck" + ''; + + meta = { + description = "Lints and suggestions for the Nix programming language"; + homepage = "https://git.peppe.rs/languages/statix/about"; + license = lib.licenses.mit; + }; + }; + + default = psArgs.config.packages.statix; + }; + }; + + partitions.dev.module.perSystem = psArgs: { + treefmt.settings.global.excludes = [ "bin/tests/data/*.nix" ]; + checks."packages/statix" = psArgs.config.packages.statix; + }; +} diff --git a/flake.lock b/flake.lock index b54bc0c..f495041 100644 --- a/flake.lock +++ b/flake.lock @@ -21,6 +21,26 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1751413152, + "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1731890469, @@ -40,7 +60,9 @@ "root": { "inputs": { "fenix": "fenix", - "nixpkgs": "nixpkgs" + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems" } }, "rust-analyzer-src": { @@ -59,6 +81,22 @@ "repo": "rust-analyzer", "type": "github" } + }, + "systems": { + "flake": false, + "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", diff --git a/flake.nix b/flake.nix index 2bb7bf1..1318b8e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,127 +1,58 @@ { - inputs = { - - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixConfig = { + abort-on-warn = true; + allow-import-from-derivation = false; + }; + inputs = { fenix = { url = "github:nix-community/fenix"; inputs.nixpkgs.follows = "nixpkgs"; }; - }; - - outputs = - { self - , nixpkgs - , fenix - }: - let - supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - nixpkgsFor = forAllSystems (system: - import nixpkgs { - inherit system; - overlays = [ self.overlays.default ]; - }); - - rustChannel = p: (fenix.overlays.default p p).fenix.stable; - in - { - - overlays.default = final: prev: { - - statix = with final; - let - pname = "statix"; - packageMeta = (lib.importTOML ./bin/Cargo.toml).package; - rustPlatform = makeRustPlatform { - inherit (rustChannel final) cargo rustc; - }; - clippy = (rustChannel final).clippy; - in - rustPlatform.buildRustPackage { - inherit pname; - inherit (packageMeta) version; - - src = self; - cargoLock.lockFile = ./Cargo.lock; - - buildFeatures = [ "json" ]; - - RUSTFLAGS = "--deny warnings"; - - meta = with lib; { - description = "Lints and suggestions for the Nix programming language"; - homepage = "https://git.peppe.rs/languages/statix/about"; - license = licenses.mit; - }; - - nativeCheckInputs = [ clippy ]; - - postCheck = '' - echo "Starting postCheck" - cargo clippy - echo "Finished postCheck" - ''; - }; - - statix-vim = - with final; vimUtils.buildVimPlugin { - pname = "statix-vim"; - version = "0.1.0"; - src = ./vim-plugin; - }; - - }; - - packages = forAllSystems (system: { - inherit (nixpkgsFor."${system}") statix statix-vim; - default = (nixpkgsFor."${system}").statix; - }); - - devShells = forAllSystems (system: { - default = let - pkgs = nixpkgsFor."${system}"; - toolchain = (rustChannel pkgs).withComponents [ - "rustc" - "cargo" - "rust-std" - "rustfmt" - "clippy" - "rust-src" - ]; - inherit (fenix.packages."${system}") rust-analyzer; - in - pkgs.mkShell { - nativeBuildInputs = [ - pkgs.bacon - pkgs.cargo-insta - rust-analyzer - toolchain - ]; - RUST_LOG = "info"; - RUST_BACKTRACE = 1; - }; - }); - + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; - apps = forAllSystems - (system: - let - pkgs = nixpkgsFor."${system}"; - cachix-push-script = pkgs.writeScriptBin "cachix-push" '' - ${pkgs.nix}/bin/nix build --json \ - | ${pkgs.jq}/bin/jq -r '.[].outputs | to_entries[].value' \ - | ${pkgs.cachix}/bin/cachix push statix - ''; - in - { - cachix-push = { - type = "app"; - program = "${cachix-push-script}/bin/cachix-push"; - }; - } - ); + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + systems = { + url = "github:nix-systems/default"; + flake = false; }; + }; + outputs = + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } ( + { lib, ... }: + { + _module.args.root = ./.; + systems = import inputs.systems; + + imports = [ + inputs.flake-parts.flakeModules.partitions + ./docs/flake-part.nix + ./flake-parts/cachix.nix + ./flake-parts/ci.nix + ./flake-parts/dev-shell.nix + ./flake-parts/files.nix + ./flake-parts/fmt.nix + ./flake-parts/git-hooks.nix + ./flake-parts/git-ignore.nix + ./flake-parts/license.nix + ./flake-parts/overlay.nix + ./flake-parts/rust.nix + ./flake-parts/statix.nix + ./vim-plugin/flake-part.nix + ]; + + partitionedAttrs = lib.genAttrs [ + "checks" + "apps" + ] (_: "dev"); + + partitions.dev.extraInputsFlake = ./dev-flake; + } + ); } diff --git a/lib/src/lints/bool_comparison.rs b/lib/src/lints/bool_comparison.rs index fd2a410..cea41b7 100644 --- a/lib/src/lints/bool_comparison.rs +++ b/lib/src/lints/bool_comparison.rs @@ -106,10 +106,9 @@ enum NixBoolean { // not entirely accurate, underhanded nix programmers might write `true = false` fn boolean_ident(node: &SyntaxNode) -> Option { - Ident::cast(node.clone()) - .and_then(|ident_expr| match ident_expr.as_str() { - "true" => Some(NixBoolean::True), - "false" => Some(NixBoolean::False), - _ => None, - }) + Ident::cast(node.clone()).and_then(|ident_expr| match ident_expr.as_str() { + "true" => Some(NixBoolean::True), + "false" => Some(NixBoolean::False), + _ => None, + }) } diff --git a/lib/src/lints/eta_reduction.rs b/lib/src/lints/eta_reduction.rs index a1e483f..b6767b9 100644 --- a/lib/src/lints/eta_reduction.rs +++ b/lib/src/lints/eta_reduction.rs @@ -60,9 +60,9 @@ impl Rule for EtaReduction { if let Some(lambda_node) = body.lambda(); if !mentions_ident(&arg, &lambda_node); - // lambda body should be no more than a single Ident to - // retain code readability - if let Some(_) = Ident::cast(lambda_node); + // lambda body should be no more than a single Ident to + // retain code readability + if let Some(_) = Ident::cast(lambda_node); then { let at = node.text_range(); diff --git a/vim-plugin/flake-part.nix b/vim-plugin/flake-part.nix new file mode 100644 index 0000000..75f496e --- /dev/null +++ b/vim-plugin/flake-part.nix @@ -0,0 +1,20 @@ +{ lib, ... }: +{ + perSystem = + { pkgs, ... }: + { + packages.statix-vim = pkgs.vimUtils.buildVimPlugin { + pname = "statix-vim"; + version = "0.1.0"; + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.union ./plugin/statix.vim ./ftplugin/nix.vim; + }; + }; + }; + + partitions.dev.module.perSystem = psArgs: { + treefmt.settings.global.excludes = [ "*.vim" ]; + checks."packages/statix-vim" = psArgs.config.packages.statix-vim; + }; +}