From b6ab074a2bd762f3c18cddd7be14a2460d3780e3 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 14 Nov 2026 20:54:15 -0300 Subject: [PATCH 1/2] Add Nix flake for building necessist --- .gitignore | 1 + flake.lock | 48 +++++++++++++++++++++++++++++++ flake.nix | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 78a144f05..228b0b576 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ NECESSIST_LOCK necessist.db +result target diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..ab7230453 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1794552581, + "narHash": "sha256-qXFIqA6FCcx7XeDzw0ZNlkDT9UiCzrNDwK8RuU8RcHM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f1e5c356f35d07e7b71a6b5e6c9338e0b029e0c0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1794646145, + "narHash": "sha256-rpqDyUM/d5fACYB8W+wKxxO57ICWjjalzb2X25oFFkY=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "5b87ee0513c29127a01ad06e9cb362ea5ce91e78", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..f2196655b --- /dev/null +++ b/flake.nix @@ -0,0 +1,84 @@ +{ + description = "Necessist — find unnecessary code in tests"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + inputs.rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = + { + self, + nixpkgs, + rust-overlay, + }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + in + { + packages = forAllSystems ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default ]; + }; + # Locked dependencies require a newer Rust than nixpkgs 26.05 provides. + toolchain = pkgs.rust-bin.stable.latest.minimal; + rustPlatform = pkgs.makeRustPlatform { + cargo = toolchain; + rustc = toolchain; + }; + manifest = builtins.fromTOML (builtins.readFile ./necessist/Cargo.toml); + name = manifest.package.name; + in + { + necessist = rustPlatform.buildRustPackage { + pname = name; + version = manifest.package.version; + src = pkgs.lib.cleanSourceWith { + src = ./.; + filter = path: type: builtins.baseNameOf path != "target" && pkgs.lib.cleanSourceFilter path type; + }; + + cargoLock.lockFile = ./Cargo.lock; + cargoBuildFlags = [ + "--package" + name + ]; + + nativeBuildInputs = [ pkgs.pkg-config ]; + buildInputs = [ + pkgs.libgit2 + pkgs.openssl + pkgs.sqlite + ]; + + # Integration tests require network access and external test frameworks. + doCheck = false; + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck + "$out/bin/${name}" --version + runHook postInstallCheck + ''; + + meta = { + description = manifest.package.description; + homepage = manifest.package.repository; + license = pkgs.lib.meta.getLicenseFromSpdxId manifest.package.license; + mainProgram = name; + platforms = systems; + }; + }; + default = self.packages.${system}.necessist; + } + ); + }; +} From 1f5f2d6e0763bc2349263c29911f7de3355bd345 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Fri, 4 Dec 2026 01:17:18 -0300 Subject: [PATCH 2/2] Improve Nix packaging and expose a flake check --- flake.lock | 8 ++++---- flake.nix | 25 ++++++++++++++++--------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/flake.lock b/flake.lock index ab7230453..45fee2477 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1794552581, - "narHash": "sha256-qXFIqA6FCcx7XeDzw0ZNlkDT9UiCzrNDwK8RuU8RcHM=", + "lastModified": 1796288735, + "narHash": "sha256-T8KUB70oTLD9fjeCP0yS2gNVD4FiVTParnFUtZy42oI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f1e5c356f35d07e7b71a6b5e6c9338e0b029e0c0", + "rev": "dd3cfcafd3168dacca0c76edcb40f60247041ade", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-26.05", + "ref": "nixos-26.11", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index f2196655b..0d37f886d 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,7 @@ { description = "Necessist — find unnecessary code in tests"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.11"; inputs.rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; @@ -29,23 +29,23 @@ inherit system; overlays = [ rust-overlay.overlays.default ]; }; - # Locked dependencies require a newer Rust than nixpkgs 26.05 provides. toolchain = pkgs.rust-bin.stable.latest.minimal; rustPlatform = pkgs.makeRustPlatform { cargo = toolchain; rustc = toolchain; }; manifest = builtins.fromTOML (builtins.readFile ./necessist/Cargo.toml); + workspace = builtins.fromTOML (builtins.readFile ./Cargo.toml); + workspacePackage = workspace.workspace.package; name = manifest.package.name; in { necessist = rustPlatform.buildRustPackage { pname = name; - version = manifest.package.version; - src = pkgs.lib.cleanSourceWith { - src = ./.; - filter = path: type: builtins.baseNameOf path != "target" && pkgs.lib.cleanSourceFilter path type; - }; + version = workspacePackage.version; + src = pkgs.nix-gitignore.gitignoreFilterSourcePure pkgs.lib.cleanSourceFilter [ + ./.gitignore + ] ./.; cargoLock.lockFile = ./Cargo.lock; cargoBuildFlags = [ @@ -71,8 +71,12 @@ meta = { description = manifest.package.description; - homepage = manifest.package.repository; - license = pkgs.lib.meta.getLicenseFromSpdxId manifest.package.license; + homepage = workspacePackage.repository; + license = + if workspacePackage.license == "AGPL-3.0" then + pkgs.lib.licenses.agpl3Only + else + pkgs.lib.meta.getLicenseFromSpdxId workspacePackage.license; mainProgram = name; platforms = systems; }; @@ -80,5 +84,8 @@ default = self.packages.${system}.necessist; } ); + checks = forAllSystems (system: { + inherit (self.packages.${system}) necessist; + }); }; }