Clean up unused stuff, add treefmt-nix

This commit is contained in:
Erwin Boskma 2024-12-02 12:53:16 +01:00
parent f5b39be7c1
commit f861550625
Signed by: erwin
SSH key fingerprint: SHA256:9LmFDe1C6jSrEyqxxvX8NtJBmcbB105XoqyUZF092bg
6 changed files with 89 additions and 69 deletions

View file

@ -1,10 +0,0 @@
(import
(
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
}
)
{
src = ./.;
}).defaultNix

View file

@ -1,12 +0,0 @@
{
"$schema": "https://dprint.dev/schemas/v0.json",
"incremental": true,
"markdown": {
},
"includes": ["**/*.{md,rs}"],
"excludes": [],
"plugins": [
"https://plugins.dprint.dev/markdown-0.9.2.wasm",
"https://plugins.dprint.dev/rustfmt-0.4.0.exe-plugin@c6bb223ef6e5e87580177f6461a0ab0554ac9ea6b54f78ea7ae8bf63b14f5bc2"
]
}

View file

@ -145,7 +145,8 @@
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks",
"rust-overlay": "rust-overlay"
"rust-overlay": "rust-overlay",
"treefmt-nix": "treefmt-nix"
}
},
"rust-overlay": {
@ -182,6 +183,26 @@
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1732894027,
"narHash": "sha256-2qbdorpq0TXHBWbVXaTqKoikN4bqAtAplTwGuII+oAc=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "6209c381904cab55796c5d7350e89681d3b2a8ef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",

View file

@ -7,33 +7,43 @@
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.flake-utils.follows = "flake-utils";
};
crane = {
url = "github:ipetkov/crane";
crane.url = "github:ipetkov/crane";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.rust-overlay.follows = "rust-overlay";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, pre-commit-hooks, crane }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
pre-commit-hooks,
crane,
treefmt-nix,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
rustToolchain =
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
crane-lib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
src = crane-lib.cleanCargoSource ./.;
buildInputs = with pkgs; [
] ++ lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
buildInputs =
with pkgs;
[
]
++ lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
nativeBuildInputs = with pkgs; [
pkgconf
];
@ -43,12 +53,17 @@
};
ha-now-playing = crane-lib.buildPackage {
inherit cargoArtifacts src buildInputs nativeBuildInputs;
inherit
cargoArtifacts
src
buildInputs
nativeBuildInputs
;
};
in
{
formatter = pkgs.nixpkgs-fmt;
formatter = self.checks.${system}.formatting.config.build.wrapper;
packages = {
inherit ha-now-playing;
@ -68,7 +83,12 @@
inherit ha-now-playing;
ha-now-playing-clippy = crane-lib.cargoClippy {
inherit cargoArtifacts src buildInputs nativeBuildInputs;
inherit
cargoArtifacts
src
buildInputs
nativeBuildInputs
;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
@ -76,11 +96,19 @@
inherit src;
};
formatting = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
deadnix.enable = true;
rustfmt.enable = true;
};
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
statix.enable = true;
nixfmt-rfc-style.enable = true;
deadnix.enable = true;
rust-overlay-clippy = {
enable = true;
@ -97,7 +125,9 @@
};
};
devShells.default = with pkgs; mkShell {
devShells.default =
with pkgs;
mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
name = "ha-now-playing";
@ -117,6 +147,7 @@
];
};
});
}
);
}

View file

@ -1,10 +0,0 @@
(import
(
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
}
)
{
src = ./.;
}).shellNix

View file

@ -56,7 +56,7 @@ impl WaybarBuilder {
tooltip: self.tooltip,
class: self.class,
percentage: self.percentage,
muted: self.muted
muted: self.muted,
}
}
}