From 0ff35842087b3b16e7e41caa6f794151b47f304a Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 8 Nov 2024 20:47:25 -0500 Subject: Clean up Nix Flake and packaging (#24) * refactor(nix): split package.nix from flake.nix * chore(nix): split checks; add more * ci: run all nix checks * ci: build in debug mode * chore(nix): use versionCheckHook this makes sure the version test is always run, and on the right package * chore(nix): nix-filter -> lib.fileset * feat(nix): support stable nix * ci: fix clippy check --- nix/package.nix | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 nix/package.nix (limited to 'nix') diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..cc60573 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,64 @@ +{ + lib, + installShellFiles, + makeBinaryWrapper, + nix, + rustPlatform, + versionCheckHook, +}: + +let + fs = lib.fileset; +in +rustPlatform.buildRustPackage rec { + pname = "nix-forecast"; + inherit (passthru.cargoTOML.package) version; + + src = fs.toSource { + root = ../.; + fileset = fs.intersection (fs.gitTracked ../.) ( + fs.unions [ + ../Cargo.lock + ../Cargo.toml + ../build.rs + ../src + ] + ); + }; + + cargoLock.lockFile = ../Cargo.lock; + + nativeBuildInputs = [ + installShellFiles + makeBinaryWrapper + ]; + + doInstallCheck = true; + nativeInstallCheckInputs = [ versionCheckHook ]; + + postInstall = '' + wrapProgram $out/bin/nix-forecast --suffix PATH : ${lib.makeBinPath [ nix ]} + + installShellCompletion --cmd nix-forecast \ + --bash completions/nix-forecast.bash \ + --fish completions/nix-forecast.fish \ + --zsh completions/_nix-forecast + ''; + + env = { + COMPLETION_DIR = "completions"; + }; + + passthru = { + cargoTOML = lib.importTOML ../Cargo.toml; + }; + + meta = { + description = "Check the forecast for today's Nix builds"; + homepage = "https://github.com/getchoo/nix-forecast"; + changelog = "https://github.com/getchoo/nix-forecast/releases/tag/${version}"; + license = lib.licenses.mpl20; + maintainers = with lib.maintainers; [ getchoo ]; + mainProgram = "nix-forecast"; + }; +} -- cgit v1.2.3