From 837ce3ab3ef789e9797f0f7c6c4f1d1d750fff7e Mon Sep 17 00:00:00 2001 From: uku Date: Fri, 9 May 2025 22:32:09 +0200 Subject: [PATCH] feat: switch to crane --- flake.lock | 16 ++++++++++++++++ flake.nix | 14 ++++++++++++-- package.nix | 12 +++++------- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 5b09f7e..8c45108 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,20 @@ { "nodes": { + "crane": { + "locked": { + "lastModified": 1746291859, + "narHash": "sha256-DdWJLA+D5tcmrRSg5Y7tp/qWaD05ATI4Z7h22gd1h7Q=", + "owner": "ipetkov", + "repo": "crane", + "rev": "dfd9a8dfd09db9aad544c4d3b6c47b12562544a5", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -38,6 +53,7 @@ }, "root": { "inputs": { + "crane": "crane", "flake-parts": "flake-parts", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index cc69ba0..aa23b95 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,8 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; + crane.url = "github:ipetkov/crane"; + flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; @@ -9,7 +11,12 @@ }; outputs = - { self, flake-parts, ... }@inputs: + { + self, + crane, + flake-parts, + ... + }@inputs: flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" @@ -22,7 +29,10 @@ { self', pkgs, ... }: { packages = { - tyrolienne = pkgs.callPackage ./package.nix { inherit self; }; + tyrolienne = pkgs.callPackage ./package.nix { + inherit self; + craneLib = crane.mkLib pkgs; + }; default = self'.packages.tyrolienne; }; diff --git a/package.nix b/package.nix index cc264ef..84cb79a 100644 --- a/package.nix +++ b/package.nix @@ -1,23 +1,21 @@ { - lib, - rustPlatform, - mold-wrapped, self, + lib, + craneLib, + mold-wrapped, }: let cargoToml = lib.importTOML ./Cargo.toml; rev = self.shortRev or self.dirtyShortRev or "dirty"; in -rustPlatform.buildRustPackage { +craneLib.buildPackage { pname = cargoToml.package.name; version = "${cargoToml.package.version}+git.${rev}"; - src = self; + src = craneLib.cleanCargoSource ./.; nativeBuildInputs = [ mold-wrapped ]; - cargoLock.lockFile = ./Cargo.lock; - RUSTFLAGS = "-C link-arg=-fuse-ld=mold"; doCheck = false;