From 8bf62f3ce22153c9e105b497f70656fc40cb77e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Fri, 10 Jan 2025 23:39:46 +0100 Subject: [PATCH] fix(flake): switch overlay to callPackage This ensures it can be built for any architecture (supported by Rust). --- default.nix | 37 ++++++++++++++++++++++++++ flake-modules/package.nix | 55 +++++++++++++-------------------------- 2 files changed, 55 insertions(+), 37 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..28e3808 --- /dev/null +++ b/default.nix @@ -0,0 +1,37 @@ +{ + pkgs ? + (builtins.getFlake (builtins.toString ./.)).inputs.nixpkgs.legacyPackages.${builtins.currentSystem}, + lib ? pkgs.lib, + crane ? (builtins.getFlake (builtins.toString ./.)).inputs.crane, + pkgSrc ? ./., + mold ? pkgs.mold, +}: +let + craneLib = crane.mkLib pkgs; + src = craneLib.cleanCargoSource pkgSrc; + + commonArgs = { + inherit src; + strictDeps = true; + + doCheck = false; # tests will be run in the `checks` derivation + NEXTEST_HIDE_PROGRESS_BAR = 1; + NEXTEST_FAILURE_OUTPUT = "immediate-final"; + + nativeBuildInputs = [ mold ]; + + meta = { + license = lib.licenses.mit; + homepage = "https://github.com/jalil-salame/webnsupdate"; + mainProgram = "webnsupdate"; + }; + }; + + cargoArtifacts = craneLib.buildDepsOnly commonArgs; +in +craneLib.buildPackage ( + lib.mergeAttrsList [ + commonArgs + { inherit cargoArtifacts; } + ] +) diff --git a/flake-modules/package.nix b/flake-modules/package.nix index 7e8bd52..740d0bb 100644 --- a/flake-modules/package.nix +++ b/flake-modules/package.nix @@ -1,13 +1,11 @@ -{ withSystem, inputs, ... }: +{ inputs, ... }: { - flake.overlays.default = - final: prev: - withSystem prev.stdenv.hostPlatform.system ( - { self', ... }: - { - inherit (self'.packages) webnsupdate; - } - ); + flake.overlays.default = final: prev: { + webnsupdate = prev.callPackage ../default.nix { + inherit (inputs) crane; + pkgSrc = inputs.self; + }; + }; perSystem = { pkgs, lib, ... }: @@ -33,29 +31,22 @@ }; cargoArtifacts = craneLib.buildDepsOnly commonArgs; - webnsupdate = craneLib.buildPackage ( - lib.mergeAttrsList [ - commonArgs - { inherit cargoArtifacts; } - ] - ); + withArtifacts = lib.mergeAttrsList [ + commonArgs + { inherit cargoArtifacts; } + ]; + webnsupdate = pkgs.callPackage ../default.nix { + inherit (inputs) crane; + pkgSrc = inputs.self; + }; in { checks = { + nextest = craneLib.cargoNextest withArtifacts; clippy = craneLib.cargoClippy ( lib.mergeAttrsList [ - commonArgs - { - inherit cargoArtifacts; - cargoClippyExtraArgs = "--all-targets -- --deny warnings"; - } - ] - ); - - nextest = craneLib.cargoNextest ( - lib.mergeAttrsList [ - commonArgs - { inherit cargoArtifacts; } + withArtifacts + { cargoClippyExtraArgs = "--all-targets -- --deny warnings"; } ] ); }; @@ -64,16 +55,6 @@ inherit webnsupdate; inherit (pkgs) git-cliff; default = webnsupdate; - cargo-update = pkgs.writeShellApplication { - name = "cargo-update-lockfile"; - runtimeInputs = with pkgs; [ - cargo - gnused - ]; - text = '' - CARGO_TERM_COLOR=never cargo update 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log - ''; - }; }; }; }