aboutsummaryrefslogtreecommitdiff
path: root/default.nix
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2026-12-03 08:11:11 +0100
committerMartin Fischer <martin@push-f.com>2026-12-04 09:11:05 +0100
commita7c41f1de23ba951da838ca24009a8399a1e1c46 (patch)
tree64c8ff38ce80317d762e4239533c2283015bac48 /default.nix
initial commitHEADmaster
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix78
1 files changed, 78 insertions, 0 deletions
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..0e7f9f8
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,78 @@
+{
+ sources ? import ./npins,
+ pkgs ? import sources.nixpkgs { },
+}:
+
+let
+ package = pkgs.rustPlatform.buildRustPackage {
+ pname = "treeimp";
+ version = "0-git";
+ src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
+ cargoLock.lockFile = ./Cargo.lock;
+ nativeBuildInputs = [
+ pkgs.installShellFiles
+ ];
+ nativeCheckInputs = [
+ pkgs.gitMinimal
+ pkgs.nix
+ ];
+ postInstall = ''
+ installShellCompletion --cmd treeimp \
+ --bash <($out/bin/treeimp completions bash) \
+ --fish <($out/bin/treeimp completions fish) \
+ --zsh <($out/bin/treeimp completions zsh)
+ '';
+ };
+in
+{
+ packages.default = package;
+
+ checks = {
+ cargo-fmt =
+ pkgs.runCommand "cargo-fmt-check"
+ {
+ nativeBuildInputs = [
+ pkgs.cargo
+ pkgs.rustfmt
+ ];
+ }
+ ''
+ cd ${./.}
+ cargo fmt --check --all
+ touch $out
+ '';
+
+ cargo-clippy =
+ pkgs.runCommandCC "cargo-clippy-check"
+ {
+ nativeBuildInputs = [
+ pkgs.cargo
+ pkgs.clippy
+ pkgs.rustPlatform.cargoSetupHook
+ ];
+ cargoDeps = package.cargoDeps;
+ }
+ ''
+ cp -R ${./.} source
+ chmod -R u+w source
+ cd source
+ cargoSetupPostUnpackHook
+ cargoSetupPostPatchHook
+ export CARGO_TARGET_DIR=$TMPDIR/target
+ export HOME=$TMPDIR
+ cargo clippy --all-targets --all-features -- -D warnings
+ touch $out
+ '';
+ };
+
+ devShells.default = pkgs.mkShell {
+ packages = [
+ pkgs.cargo
+ pkgs.rustc
+ pkgs.rustfmt
+ pkgs.clippy
+ pkgs.nix
+ pkgs.gitMinimal
+ ];
+ };
+}