summaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
authorseth <[email protected]>2024-11-08 20:47:25 -0500
committerGitHub <[email protected]>2024-11-08 20:47:25 -0500
commit0ff35842087b3b16e7e41caa6f794151b47f304a (patch)
tree1fd0158e5833690bfc178b08ad51cfeb7a0f7d43 /nix
parent1ec360f351022851e1a3bbe2b588c5c224b33331 (diff)
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
Diffstat (limited to 'nix')
-rw-r--r--nix/package.nix64
1 files changed, 64 insertions, 0 deletions
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";
+ };
+}