From 95cfb31b9a5b4c865d422afd483a68e52c24feea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Fri, 16 May 2025 18:24:16 +0200 Subject: [PATCH] feat: use rust-overlay to get the rust binaries This should ensure I use my own rust version instead of the one in nixpkgs. --- flake-modules/package.nix | 24 +++++++++++++++++++----- flake.lock | 21 +++++++++++++++++++++ flake.nix | 11 ++++++++--- 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/flake-modules/package.nix b/flake-modules/package.nix index 740d0bb..1d488d0 100644 --- a/flake-modules/package.nix +++ b/flake-modules/package.nix @@ -1,16 +1,24 @@ { inputs, ... }: +let + inherit (inputs) crane; +in { flake.overlays.default = final: prev: { webnsupdate = prev.callPackage ../default.nix { - inherit (inputs) crane; + inherit crane; pkgSrc = inputs.self; }; }; perSystem = - { pkgs, lib, ... }: + { + system, + pkgs, + lib, + ... + }: let - craneLib = inputs.crane.mkLib pkgs; + craneLib = (crane.mkLib pkgs).overrideToolchain (pkgs: pkgs.rust-bin.stable.latest.default); src = craneLib.cleanCargoSource inputs.self; commonArgs = { @@ -36,11 +44,17 @@ { inherit cargoArtifacts; } ]; webnsupdate = pkgs.callPackage ../default.nix { - inherit (inputs) crane; - pkgSrc = inputs.self; + inherit crane; + pkgSrc = src; }; in { + # Consume the rust-rust-overlay + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ inputs.rust-overlay.overlays.default ]; + }; + checks = { nextest = craneLib.cargoNextest withArtifacts; clippy = craneLib.cargoClippy ( diff --git a/flake.lock b/flake.lock index 222ce24..788983f 100644 --- a/flake.lock +++ b/flake.lock @@ -53,10 +53,31 @@ "crane": "crane", "flake-parts": "flake-parts", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "systems": "systems", "treefmt-nix": "treefmt-nix" } }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1747363019, + "narHash": "sha256-N4dwkRBmpOosa4gfFkFf/LTD8oOcNkAyvZ07JvRDEf0=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "0e624f2b1972a34be1a9b35290ed18ea4b419b6f", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index 347a1d6..b4e835d 100644 --- a/flake.nix +++ b/flake.nix @@ -1,17 +1,22 @@ { description = "An http server that calls nsupdate internally"; inputs = { - crane.url = "github:ipetkov/crane"; + nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; - nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; - systems.url = "github:nix-systems/default"; treefmt-nix = { url = "github:numtide/treefmt-nix"; inputs.nixpkgs.follows = "nixpkgs"; }; + + crane.url = "github:ipetkov/crane"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + systems.url = "github:nix-systems/default"; }; outputs =