Lints and suggestions for the Nix programming language
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rewrite flake

- use flake-parts
- formatting with treefmt-nix
- mightyiam/files to generate a new GH Actions workflow
- flake-parts dev partition
- comprehensive flake checks
- git hooks
- bump inputs
- should be backwards compatible
- new non-dev inputs that users might notice:
- flake-parts (all the partitions trickery in the world cannot remove
that I suppose)
- systems (`github:nix-systems/default`)

+672 -145
-18
.github/workflows/build.yml
··· 1 - name: "Test" 2 - on: 3 - pull_request: 4 - push: 5 - jobs: 6 - tests: 7 - runs-on: ubuntu-latest 8 - steps: 9 - - uses: actions/checkout@v4 10 - - uses: cachix/install-nix-action@v30 11 - with: 12 - github_access_token: ${{ secrets.GITHUB_TOKEN }} 13 - - name: build statix 14 - run: nix build -L 15 - - name: test statix 16 - run: nix flake check 17 - - name: build statix and install statix in flake-compat mode 18 - run: nix-env -if default.nix
+72
.github/workflows/check.yaml
··· 1 + { 2 + "jobs": { 3 + "check": { 4 + "needs": "get-check-names", 5 + "runs-on": "ubuntu-latest", 6 + "steps": [ 7 + { 8 + "uses": "actions/checkout@v4" 9 + }, 10 + { 11 + "uses": "cachix/install-nix-action@v31", 12 + "with": { 13 + "github_access_token": "${{ secrets.GITHUB_TOKEN }}" 14 + } 15 + }, 16 + { 17 + "run": "nix --accept-flake-config build '.#checks.x86_64-linux.\"${{ matrix.checks }}\"'\n" 18 + } 19 + ], 20 + "strategy": { 21 + "matrix": { 22 + "checks": "${{ fromJson(needs.get-check-names.outputs.checks) }}" 23 + } 24 + } 25 + }, 26 + "get-check-names": { 27 + "outputs": { 28 + "checks": "${{ steps.get-check-names.outputs.checks }}" 29 + }, 30 + "runs-on": "ubuntu-latest", 31 + "steps": [ 32 + { 33 + "uses": "actions/checkout@v4" 34 + }, 35 + { 36 + "uses": "cachix/install-nix-action@v31", 37 + "with": { 38 + "github_access_token": "${{ secrets.GITHUB_TOKEN }}" 39 + } 40 + }, 41 + { 42 + "id": "get-check-names", 43 + "run": "checks=\"$(nix --accept-flake-config eval --json .#checks.x86_64-linux --apply builtins.attrNames)\"\necho \"checks=$checks\" >> $GITHUB_OUTPUT\n" 44 + } 45 + ] 46 + }, 47 + "legacy": { 48 + "name": "Build statix via flake-compat and install it using `nix-env`", 49 + "runs-on": "ubuntu-latest", 50 + "steps": [ 51 + { 52 + "uses": "actions/checkout@v4" 53 + }, 54 + { 55 + "uses": "cachix/install-nix-action@v31", 56 + "with": { 57 + "github_access_token": "${{ secrets.GITHUB_TOKEN }}" 58 + } 59 + }, 60 + { 61 + "run": "nix-env --install --file default.nix" 62 + } 63 + ] 64 + } 65 + }, 66 + "name": "Check", 67 + "on": { 68 + "pull_request": {}, 69 + "push": {}, 70 + "workflow_call": {} 71 + } 72 + }
+2 -3
.gitignore
··· 1 + /.pre-commit-config.yaml 2 + /result 1 3 /target 2 - .envrc 3 - .direnv 4 - result
+149
dev-flake/flake.lock
··· 1 + { 2 + "nodes": { 3 + "files": { 4 + "locked": { 5 + "lastModified": 1750263550, 6 + "narHash": "sha256-EW/QJ8i/13GgiynBb6zOMxhLU1uEkRqmzbIDEP23yVA=", 7 + "owner": "mightyiam", 8 + "repo": "files", 9 + "rev": "5f4ef1fd1f9012354a9748be093e277675d10f07", 10 + "type": "github" 11 + }, 12 + "original": { 13 + "owner": "mightyiam", 14 + "repo": "files", 15 + "type": "github" 16 + } 17 + }, 18 + "flake-compat_dedupe": { 19 + "locked": { 20 + "lastModified": 1747046372, 21 + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", 22 + "owner": "edolstra", 23 + "repo": "flake-compat", 24 + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", 25 + "type": "github" 26 + }, 27 + "original": { 28 + "owner": "edolstra", 29 + "repo": "flake-compat", 30 + "type": "github" 31 + } 32 + }, 33 + "git-hooks": { 34 + "inputs": { 35 + "flake-compat": [ 36 + "flake-compat_dedupe" 37 + ], 38 + "gitignore": [ 39 + "gitignore_dedupe" 40 + ], 41 + "nixpkgs": [ 42 + "nixpkgs_dedupe" 43 + ] 44 + }, 45 + "locked": { 46 + "lastModified": 1750779888, 47 + "narHash": "sha256-wibppH3g/E2lxU43ZQHC5yA/7kIKLGxVEnsnVK1BtRg=", 48 + "owner": "cachix", 49 + "repo": "git-hooks.nix", 50 + "rev": "16ec914f6fb6f599ce988427d9d94efddf25fe6d", 51 + "type": "github" 52 + }, 53 + "original": { 54 + "owner": "cachix", 55 + "repo": "git-hooks.nix", 56 + "type": "github" 57 + } 58 + }, 59 + "gitignore_dedupe": { 60 + "inputs": { 61 + "nixpkgs": [ 62 + "nixpkgs_dedupe" 63 + ] 64 + }, 65 + "locked": { 66 + "lastModified": 1709087332, 67 + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", 68 + "owner": "hercules-ci", 69 + "repo": "gitignore.nix", 70 + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", 71 + "type": "github" 72 + }, 73 + "original": { 74 + "owner": "hercules-ci", 75 + "repo": "gitignore.nix", 76 + "type": "github" 77 + } 78 + }, 79 + "make-shell": { 80 + "inputs": { 81 + "flake-compat": [ 82 + "flake-compat_dedupe" 83 + ] 84 + }, 85 + "locked": { 86 + "lastModified": 1733933815, 87 + "narHash": "sha256-9JjM7eT66W4NJAXpGUsdyAFXhBxFWR2Z9LZwUa7Hli0=", 88 + "owner": "nicknovitski", 89 + "repo": "make-shell", 90 + "rev": "ffeceae9956df03571ea8e96ef77c2924f13a63c", 91 + "type": "github" 92 + }, 93 + "original": { 94 + "owner": "nicknovitski", 95 + "repo": "make-shell", 96 + "type": "github" 97 + } 98 + }, 99 + "nixpkgs_dedupe": { 100 + "locked": { 101 + "lastModified": 1751949589, 102 + "narHash": "sha256-mgFxAPLWw0Kq+C8P3dRrZrOYEQXOtKuYVlo9xvPntt8=", 103 + "owner": "NixOS", 104 + "repo": "nixpkgs", 105 + "rev": "9b008d60392981ad674e04016d25619281550a9d", 106 + "type": "github" 107 + }, 108 + "original": { 109 + "owner": "NixOS", 110 + "ref": "nixpkgs-unstable", 111 + "repo": "nixpkgs", 112 + "type": "github" 113 + } 114 + }, 115 + "root": { 116 + "inputs": { 117 + "files": "files", 118 + "flake-compat_dedupe": "flake-compat_dedupe", 119 + "git-hooks": "git-hooks", 120 + "gitignore_dedupe": "gitignore_dedupe", 121 + "make-shell": "make-shell", 122 + "nixpkgs_dedupe": "nixpkgs_dedupe", 123 + "treefmt": "treefmt" 124 + } 125 + }, 126 + "treefmt": { 127 + "inputs": { 128 + "nixpkgs": [ 129 + "nixpkgs_dedupe" 130 + ] 131 + }, 132 + "locked": { 133 + "lastModified": 1750931469, 134 + "narHash": "sha256-0IEdQB1nS+uViQw4k3VGUXntjkDp7aAlqcxdewb/hAc=", 135 + "owner": "numtide", 136 + "repo": "treefmt-nix", 137 + "rev": "ac8e6f32e11e9c7f153823abc3ab007f2a65d3e1", 138 + "type": "github" 139 + }, 140 + "original": { 141 + "owner": "numtide", 142 + "repo": "treefmt-nix", 143 + "type": "github" 144 + } 145 + } 146 + }, 147 + "root": "root", 148 + "version": 7 149 + }
+28
dev-flake/flake.nix
··· 1 + { 2 + inputs = { 3 + git-hooks = { 4 + url = "github:cachix/git-hooks.nix"; 5 + inputs = { 6 + flake-compat.follows = "flake-compat_dedupe"; 7 + gitignore.follows = "gitignore_dedupe"; 8 + nixpkgs.follows = "nixpkgs_dedupe"; 9 + }; 10 + }; 11 + make-shell = { 12 + url = "github:nicknovitski/make-shell"; 13 + inputs.flake-compat.follows = "flake-compat_dedupe"; 14 + }; 15 + nixpkgs_dedupe.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 16 + files.url = "github:mightyiam/files"; 17 + flake-compat_dedupe.url = "github:edolstra/flake-compat"; 18 + gitignore_dedupe = { 19 + url = "github:hercules-ci/gitignore.nix"; 20 + inputs.nixpkgs.follows = "nixpkgs_dedupe"; 21 + }; 22 + treefmt = { 23 + url = "github:numtide/treefmt-nix"; 24 + inputs.nixpkgs.follows = "nixpkgs_dedupe"; 25 + }; 26 + }; 27 + outputs = _: { }; 28 + }
+3
docs/flake-part.nix
··· 1 + { 2 + partitions.dev.module.perSystem.treefmt.settings.global.excludes = [ "docs/*.txt" ]; 3 + }
+25
flake-parts/cachix.nix
··· 1 + { lib, ... }: 2 + { 3 + perSystem = 4 + { pkgs, ... }: 5 + { 6 + apps.cachix-push = { 7 + type = "app"; 8 + program = lib.getExe ( 9 + pkgs.writeShellApplication { 10 + name = "cachix-push"; 11 + runtimeInputs = with pkgs; [ 12 + nix 13 + jq 14 + cachix 15 + ]; 16 + text = '' 17 + nix build --json \ 18 + | jq -r '.[].outputs | to_entries[].value' \ 19 + | cachix push statix 20 + ''; 21 + } 22 + ); 23 + }; 24 + }; 25 + }
+97
flake-parts/ci.nix
··· 1 + let 2 + filePath = ".github/workflows/check.yaml"; 3 + 4 + ids = { 5 + jobs = { 6 + getCheckNames = "get-check-names"; 7 + check = "check"; 8 + }; 9 + steps.getCheckNames = "get-check-names"; 10 + outputs = { 11 + jobs.getCheckNames = "checks"; 12 + steps.getCheckNames = "checks"; 13 + }; 14 + }; 15 + 16 + matrixParam = "checks"; 17 + 18 + nixArgs = "--accept-flake-config"; 19 + 20 + runner = { 21 + name = "ubuntu-latest"; 22 + system = "x86_64-linux"; 23 + }; 24 + 25 + steps = { 26 + checkout.uses = "actions/checkout@v4"; 27 + cachixInstallNix = { 28 + uses = "cachix/install-nix-action@v31"; 29 + "with".github_access_token = "\${{ secrets.GITHUB_TOKEN }}"; 30 + }; 31 + }; 32 + in 33 + { 34 + partitions.dev.module = { 35 + perSystem = 36 + { pkgs, ... }: 37 + { 38 + files.files = [ 39 + { 40 + path_ = filePath; 41 + drv = pkgs.writers.writeJSON "gh-actions-workflow-check.yaml" { 42 + name = "Check"; 43 + on = { 44 + pull_request = { }; 45 + push = { }; 46 + workflow_call = { }; 47 + }; 48 + jobs = { 49 + ${ids.jobs.getCheckNames} = { 50 + runs-on = runner.name; 51 + outputs.${ids.outputs.jobs.getCheckNames} = "\${{ steps.${ids.steps.getCheckNames}.outputs.${ids.outputs.steps.getCheckNames} }}"; 52 + steps = [ 53 + steps.checkout 54 + steps.cachixInstallNix 55 + { 56 + id = ids.steps.getCheckNames; 57 + run = '' 58 + checks="$(nix ${nixArgs} eval --json .#checks.${runner.system} --apply builtins.attrNames)" 59 + echo "${ids.outputs.steps.getCheckNames}=$checks" >> $GITHUB_OUTPUT 60 + ''; 61 + } 62 + ]; 63 + }; 64 + 65 + ${ids.jobs.check} = { 66 + needs = ids.jobs.getCheckNames; 67 + runs-on = runner.name; 68 + strategy.matrix.${matrixParam} = "\${{ fromJson(needs.${ids.jobs.getCheckNames}.outputs.${ids.outputs.jobs.getCheckNames}) }}"; 69 + steps = [ 70 + steps.checkout 71 + steps.cachixInstallNix 72 + { 73 + run = '' 74 + nix ${nixArgs} build '.#checks.${runner.system}."''${{ matrix.${matrixParam} }}"' 75 + ''; 76 + } 77 + ]; 78 + }; 79 + 80 + legacy = { 81 + name = "Build statix via flake-compat and install it using `nix-env`"; 82 + runs-on = runner.name; 83 + steps = [ 84 + steps.checkout 85 + steps.cachixInstallNix 86 + { run = "nix-env --install --file default.nix"; } 87 + ]; 88 + }; 89 + }; 90 + }; 91 + } 92 + ]; 93 + 94 + treefmt.settings.global.excludes = [ filePath ]; 95 + }; 96 + }; 97 + }
+8
flake-parts/dev-shell.nix
··· 1 + { 2 + partitionedAttrs.devShells = "dev"; 3 + partitions.dev.module = devPartition: { 4 + imports = [ 5 + devPartition.inputs.make-shell.flakeModules.default 6 + ]; 7 + }; 8 + }
+8
flake-parts/files.nix
··· 1 + { 2 + partitions.dev.module = devPartition: { 3 + imports = [ devPartition.inputs.files.flakeModules.default ]; 4 + perSystem = psArgs: { 5 + make-shells.default.packages = [ psArgs.config.files.writer.drv ]; 6 + }; 7 + }; 8 + }
+24
flake-parts/fmt.nix
··· 1 + { 2 + partitionedAttrs.formatter = "dev"; 3 + partitions.dev.module = devPartition: { 4 + imports = [ devPartition.inputs.treefmt.flakeModule ]; 5 + 6 + perSystem = { 7 + pre-commit.settings.hooks.treefmt.enable = true; 8 + 9 + treefmt = { 10 + projectRootFile = "flake.nix"; 11 + programs = { 12 + nixfmt.enable = true; 13 + prettier.enable = true; 14 + # https://github.com/pappasam/toml-sort/issues/62 15 + # toml-sort = { 16 + # enable = true; 17 + # all = true; 18 + # }; 19 + }; 20 + settings.on-unmatched = "fatal"; 21 + }; 22 + }; 23 + }; 24 + }
+18
flake-parts/git-hooks.nix
··· 1 + { 2 + partitions.dev.module = devPartition: { 3 + imports = [ devPartition.inputs.git-hooks.flakeModule ]; 4 + 5 + gitignore = [ 6 + "/.pre-commit-config.yaml" 7 + ]; 8 + 9 + perSystem = 10 + { config, ... }: 11 + { 12 + make-shells.default.shellHook = config.pre-commit.installationScript; 13 + pre-commit.check.enable = false; 14 + treefmt.settings.global.excludes = [ ".pre-commit-config.yaml" ]; 15 + }; 16 + 17 + }; 18 + }
+26
flake-parts/git-ignore.nix
··· 1 + { lib, ... }: 2 + { 3 + partitions.dev.module = devPartition: { 4 + options.gitignore = lib.mkOption { 5 + type = lib.types.listOf lib.types.singleLineStr; 6 + apply = lib.flip lib.pipe [ 7 + lib.naturalSort 8 + lib.concatLines 9 + ]; 10 + }; 11 + config = { 12 + gitignore = [ "/result" ]; 13 + 14 + perSystem = 15 + { pkgs, ... }: 16 + { 17 + files.files = [ 18 + { 19 + path_ = ".gitignore"; 20 + drv = pkgs.writeText ".gitignore" devPartition.config.gitignore; 21 + } 22 + ]; 23 + }; 24 + }; 25 + }; 26 + }
+5
flake-parts/license.nix
··· 1 + { lib, ... }: 2 + { 3 + _module.args.license = lib.licenses.mit; 4 + partitions.dev.module.perSystem.treefmt.settings.global.excludes = [ "LICENSE" ]; 5 + }
+10
flake-parts/overlay.nix
··· 1 + { inputs, ... }: 2 + { 3 + imports = [ inputs.flake-parts.flakeModules.easyOverlay ]; 4 + 5 + perSystem = psArgs: { 6 + overlayAttrs = { 7 + inherit (psArgs.config.packages) statix statix-vim; 8 + }; 9 + }; 10 + }
+29
flake-parts/rust.nix
··· 1 + { 2 + partitions.dev.module = { 3 + gitignore = [ "/target" ]; 4 + perSystem = 5 + psArgs@{ pkgs, ... }: 6 + { 7 + make-shells.default = { 8 + inputsFrom = [ psArgs.config.packages.default ]; 9 + packages = [ 10 + pkgs.bacon 11 + pkgs.cargo-insta 12 + pkgs.rust-analyzer 13 + ]; 14 + env = { 15 + RUST_LOG = "info"; 16 + RUST_BACKTRACE = 1; 17 + }; 18 + }; 19 + treefmt = { 20 + programs.rustfmt.enable = true; 21 + settings.global.excludes = [ 22 + "**/Cargo.toml" 23 + "Cargo.toml" 24 + "bin/tests/snapshots/*.snap" 25 + ]; 26 + }; 27 + }; 28 + }; 29 + }
+56
flake-parts/statix.nix
··· 1 + { 2 + lib, 3 + root, 4 + ... 5 + }: 6 + { 7 + perSystem = 8 + psArgs@{ pkgs, ... }: 9 + { 10 + packages = { 11 + statix = pkgs.rustPlatform.buildRustPackage { 12 + pname = "statix"; 13 + inherit ((lib.importTOML (root + "/bin/Cargo.toml")).package) version; 14 + 15 + src = lib.fileset.toSource { 16 + inherit root; 17 + fileset = lib.fileset.unions [ 18 + (lib.fileset.fileFilter ( 19 + file: 20 + lib.any lib.id [ 21 + (file.name == "Cargo.toml") 22 + (file.hasExt "rs") 23 + (file.hasExt "snap") 24 + ] 25 + ) root) 26 + (root + "/Cargo.lock") 27 + (root + "/bin/tests/data") 28 + ]; 29 + }; 30 + cargoLock.lockFile = root + "/Cargo.lock"; 31 + buildFeatures = [ "json" ]; 32 + RUSTFLAGS = "--deny warnings"; 33 + nativeCheckInputs = [ pkgs.clippy ]; 34 + 35 + postCheck = '' 36 + echo "Starting postCheck" 37 + cargo clippy 38 + echo "Finished postCheck" 39 + ''; 40 + 41 + meta = { 42 + description = "Lints and suggestions for the Nix programming language"; 43 + homepage = "https://git.peppe.rs/languages/statix/about"; 44 + license = lib.licenses.mit; 45 + }; 46 + }; 47 + 48 + default = psArgs.config.packages.statix; 49 + }; 50 + }; 51 + 52 + partitions.dev.module.perSystem = psArgs: { 53 + treefmt.settings.global.excludes = [ "bin/tests/data/*.nix" ]; 54 + checks."packages/statix" = psArgs.config.packages.statix; 55 + }; 56 + }
+39 -1
flake.lock
··· 21 21 "type": "github" 22 22 } 23 23 }, 24 + "flake-parts": { 25 + "inputs": { 26 + "nixpkgs-lib": [ 27 + "nixpkgs" 28 + ] 29 + }, 30 + "locked": { 31 + "lastModified": 1751413152, 32 + "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", 33 + "owner": "hercules-ci", 34 + "repo": "flake-parts", 35 + "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", 36 + "type": "github" 37 + }, 38 + "original": { 39 + "owner": "hercules-ci", 40 + "repo": "flake-parts", 41 + "type": "github" 42 + } 43 + }, 24 44 "nixpkgs": { 25 45 "locked": { 26 46 "lastModified": 1731890469, ··· 40 60 "root": { 41 61 "inputs": { 42 62 "fenix": "fenix", 43 - "nixpkgs": "nixpkgs" 63 + "flake-parts": "flake-parts", 64 + "nixpkgs": "nixpkgs", 65 + "systems": "systems" 44 66 } 45 67 }, 46 68 "rust-analyzer-src": { ··· 57 79 "owner": "rust-lang", 58 80 "ref": "nightly", 59 81 "repo": "rust-analyzer", 82 + "type": "github" 83 + } 84 + }, 85 + "systems": { 86 + "flake": false, 87 + "locked": { 88 + "lastModified": 1681028828, 89 + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 90 + "owner": "nix-systems", 91 + "repo": "default", 92 + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 93 + "type": "github" 94 + }, 95 + "original": { 96 + "owner": "nix-systems", 97 + "repo": "default", 60 98 "type": "github" 61 99 } 62 100 }
+45 -114
flake.nix
··· 1 1 { 2 - inputs = { 3 - 4 - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 2 + nixConfig = { 3 + abort-on-warn = true; 4 + allow-import-from-derivation = false; 5 + }; 5 6 7 + inputs = { 6 8 fenix = { 7 9 url = "github:nix-community/fenix"; 8 10 inputs.nixpkgs.follows = "nixpkgs"; 9 11 }; 10 12 11 - }; 13 + flake-parts = { 14 + url = "github:hercules-ci/flake-parts"; 15 + inputs.nixpkgs-lib.follows = "nixpkgs"; 16 + }; 12 17 13 - outputs = 14 - { self 15 - , nixpkgs 16 - , fenix 17 - }: 18 - let 19 - supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; 20 - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; 21 - nixpkgsFor = forAllSystems (system: 22 - import nixpkgs { 23 - inherit system; 24 - overlays = [ self.overlays.default ]; 25 - }); 18 + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 26 19 27 - rustChannel = p: (fenix.overlays.default p p).fenix.stable; 28 - in 29 - { 20 + systems = { 21 + url = "github:nix-systems/default"; 22 + flake = false; 23 + }; 24 + }; 25 + outputs = 26 + inputs: 27 + inputs.flake-parts.lib.mkFlake { inherit inputs; } ( 28 + { lib, ... }: 29 + { 30 + _module.args.root = ./.; 31 + systems = import inputs.systems; 30 32 31 - overlays.default = final: prev: { 33 + imports = [ 34 + inputs.flake-parts.flakeModules.partitions 35 + ./docs/flake-part.nix 36 + ./flake-parts/cachix.nix 37 + ./flake-parts/ci.nix 38 + ./flake-parts/dev-shell.nix 39 + ./flake-parts/files.nix 40 + ./flake-parts/fmt.nix 41 + ./flake-parts/git-hooks.nix 42 + ./flake-parts/git-ignore.nix 43 + ./flake-parts/license.nix 44 + ./flake-parts/overlay.nix 45 + ./flake-parts/rust.nix 46 + ./flake-parts/statix.nix 47 + ./vim-plugin/flake-part.nix 48 + ]; 32 49 33 - statix = with final; 34 - let 35 - pname = "statix"; 36 - packageMeta = (lib.importTOML ./bin/Cargo.toml).package; 37 - rustPlatform = makeRustPlatform { 38 - inherit (rustChannel final) cargo rustc; 39 - }; 40 - clippy = (rustChannel final).clippy; 41 - in 42 - rustPlatform.buildRustPackage { 43 - inherit pname; 44 - inherit (packageMeta) version; 50 + partitionedAttrs = lib.genAttrs [ 51 + "checks" 52 + "apps" 53 + ] (_: "dev"); 45 54 46 - src = self; 47 - cargoLock.lockFile = ./Cargo.lock; 48 - 49 - buildFeatures = [ "json" ]; 50 - 51 - RUSTFLAGS = "--deny warnings"; 52 - 53 - meta = with lib; { 54 - description = "Lints and suggestions for the Nix programming language"; 55 - homepage = "https://git.peppe.rs/languages/statix/about"; 56 - license = licenses.mit; 57 - }; 58 - 59 - nativeCheckInputs = [ clippy ]; 60 - 61 - postCheck = '' 62 - echo "Starting postCheck" 63 - cargo clippy 64 - echo "Finished postCheck" 65 - ''; 66 - }; 67 - 68 - statix-vim = 69 - with final; vimUtils.buildVimPlugin { 70 - pname = "statix-vim"; 71 - version = "0.1.0"; 72 - src = ./vim-plugin; 73 - }; 74 - 75 - }; 76 - 77 - packages = forAllSystems (system: { 78 - inherit (nixpkgsFor."${system}") statix statix-vim; 79 - default = (nixpkgsFor."${system}").statix; 80 - }); 81 - 82 - devShells = forAllSystems (system: { 83 - default = let 84 - pkgs = nixpkgsFor."${system}"; 85 - toolchain = (rustChannel pkgs).withComponents [ 86 - "rustc" 87 - "cargo" 88 - "rust-std" 89 - "rustfmt" 90 - "clippy" 91 - "rust-src" 92 - ]; 93 - inherit (fenix.packages."${system}") rust-analyzer; 94 - in 95 - pkgs.mkShell { 96 - nativeBuildInputs = [ 97 - pkgs.bacon 98 - pkgs.cargo-insta 99 - rust-analyzer 100 - toolchain 101 - ]; 102 - RUST_LOG = "info"; 103 - RUST_BACKTRACE = 1; 104 - }; 105 - }); 106 - 107 - 108 - apps = forAllSystems 109 - (system: 110 - let 111 - pkgs = nixpkgsFor."${system}"; 112 - cachix-push-script = pkgs.writeScriptBin "cachix-push" '' 113 - ${pkgs.nix}/bin/nix build --json \ 114 - | ${pkgs.jq}/bin/jq -r '.[].outputs | to_entries[].value' \ 115 - | ${pkgs.cachix}/bin/cachix push statix 116 - ''; 117 - in 118 - { 119 - cachix-push = { 120 - type = "app"; 121 - program = "${cachix-push-script}/bin/cachix-push"; 122 - }; 123 - } 124 - ); 125 - 126 - }; 55 + partitions.dev.extraInputsFlake = ./dev-flake; 56 + } 57 + ); 127 58 }
+5 -6
lib/src/lints/bool_comparison.rs
··· 106 106 107 107 // not entirely accurate, underhanded nix programmers might write `true = false` 108 108 fn boolean_ident(node: &SyntaxNode) -> Option<NixBoolean> { 109 - Ident::cast(node.clone()) 110 - .and_then(|ident_expr| match ident_expr.as_str() { 111 - "true" => Some(NixBoolean::True), 112 - "false" => Some(NixBoolean::False), 113 - _ => None, 114 - }) 109 + Ident::cast(node.clone()).and_then(|ident_expr| match ident_expr.as_str() { 110 + "true" => Some(NixBoolean::True), 111 + "false" => Some(NixBoolean::False), 112 + _ => None, 113 + }) 115 114 }
+3 -3
lib/src/lints/eta_reduction.rs
··· 60 60 61 61 if let Some(lambda_node) = body.lambda(); 62 62 if !mentions_ident(&arg, &lambda_node); 63 - // lambda body should be no more than a single Ident to 64 - // retain code readability 65 - if let Some(_) = Ident::cast(lambda_node); 63 + // lambda body should be no more than a single Ident to 64 + // retain code readability 65 + if let Some(_) = Ident::cast(lambda_node); 66 66 67 67 then { 68 68 let at = node.text_range();
+20
vim-plugin/flake-part.nix
··· 1 + { lib, ... }: 2 + { 3 + perSystem = 4 + { pkgs, ... }: 5 + { 6 + packages.statix-vim = pkgs.vimUtils.buildVimPlugin { 7 + pname = "statix-vim"; 8 + version = "0.1.0"; 9 + src = lib.fileset.toSource { 10 + root = ./.; 11 + fileset = lib.fileset.union ./plugin/statix.vim ./ftplugin/nix.vim; 12 + }; 13 + }; 14 + }; 15 + 16 + partitions.dev.module.perSystem = psArgs: { 17 + treefmt.settings.global.excludes = [ "*.vim" ]; 18 + checks."packages/statix-vim" = psArgs.config.packages.statix-vim; 19 + }; 20 + }