Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions flake-parts/crate2nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ inputs, ... }:
{
perSystem = _: {
nixpkgs.overlays = [
(_: prev: {
crate2nixTools = prev.callPackage "${inputs.crate2nix}/tools.nix" { };
})
];
};
}
6 changes: 4 additions & 2 deletions flake-parts/rust.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
_: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review your changes as best as you can before expecting anyone else to review them. Such trivial mistakes can be avoided.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. I should have caught that before pushing. I'll be more careful.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unrelated and undesireable change is still present.

gitignore = [ "/target" ];
perSystem =
{ pkgs, ... }:
{
make-shells.default = {
inputsFrom = [ pkgs.statix ];
packages = [
pkgs.cargo
pkgs.rustc
Comment thread
mightyiam marked this conversation as resolved.
pkgs.clippy
pkgs.bacon
pkgs.cargo-insta
pkgs.rust-analyzer
Expand Down
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
nixConfig = {
abort-on-warn = true;
allow-import-from-derivation = false;
};

inputs = {
Expand All @@ -10,6 +9,10 @@
inputs.nixpkgs-lib.follows = "nixpkgs";
};

crate2nix = {
url = "github:nix-community/crate2nix";
flake = false;
};
import-tree = {
url = "github:denful/import-tree";
flake = false;
Expand Down
2 changes: 2 additions & 0 deletions overlay.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
final: prev: {
statix-cargo-nix = prev.callPackage ./packages/cargo-nix.nix { };
statix = prev.callPackage ./packages/statix.nix { };
statix-workspace = prev.callPackage ./packages/statix-workspace.nix { };
statix-vim = prev.callPackage ./packages/statix-vim.nix { };
Comment on lines +2 to 5

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does exposing these two new intermediate packages provide any value to developers or users? Should they exist as local binding in packages/statix.nix instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither of these has value outside of being inputs to building statix itself. So, I think they should exist as local binding in packages/statix.nix.
I agreed with you because, these are implementation details that shouldn't leak into the public overlay.

}
22 changes: 22 additions & 0 deletions packages/cargo-nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
lib,
crate2nixTools,
}:
crate2nixTools.generatedCargoNix {
name = "statix";
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.unions [
(lib.fileset.fileFilter (
file:
lib.any lib.id [
(file.name == "Cargo.toml")
(file.hasExt "rs")
(file.hasExt "snap")
]
) ../.)
../Cargo.lock
../insta.yaml
];
};
}
5 changes: 5 additions & 0 deletions packages/statix-workspace.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
callPackage,
statix-cargo-nix,
}:
callPackage statix-cargo-nix { }
49 changes: 15 additions & 34 deletions packages/statix.nix
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
{
rustPlatform,
lib,
clippy,
callPackage,
defaultCrateOverrides,
statix-cargo-nix,
}:
rustPlatform.buildRustPackage {
pname = "statix";
version = "0.6.0-git";
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.unions [
(lib.fileset.fileFilter (
file:
lib.any lib.id [
(file.name == "Cargo.toml")
(file.hasExt "rs")
(file.hasExt "snap")
]
) ../.)
../Cargo.lock
../insta.yaml
];
let
built = (callPackage statix-cargo-nix { }).workspaceMembers.statix.build.override {
runTests = true;
crateOverrides = defaultCrateOverrides // {
statix = _: {
useClippy = true;
RUSTFLAGS = "-D warnings";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be achieved using capLints instead?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not aware capLints as an idiomatic option. I will investigate and switch to it.

};
};
};
RUSTFLAGS = "-D warnings";
Comment thread
mightyiam marked this conversation as resolved.

nativeBuildInputs = [ clippy ];

checkPhase = ''
runHook preCheck

cargo clippy --all-targets --all-features
cargoCheckHook

runHook postCheck
'';

cargoLock.lockFile = ../Cargo.lock;
in
built.overrideAttrs (_: {
meta = {
mainProgram = "statix";
description = "Lints and suggestions for the Nix programming language";
homepage = "https://github.com/molybdenumsoftware/statix";
license = lib.licenses.mit;
};
}
})