feat: switch to crane

This commit is contained in:
uku 2025-05-09 22:32:09 +02:00
parent ed69a54524
commit 837ce3ab3e
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
3 changed files with 33 additions and 9 deletions

16
flake.lock generated
View file

@ -1,5 +1,20 @@
{ {
"nodes": { "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": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@ -38,6 +53,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"crane": "crane",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }

View file

@ -2,6 +2,8 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
crane.url = "github:ipetkov/crane";
flake-parts = { flake-parts = {
url = "github:hercules-ci/flake-parts"; url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs"; inputs.nixpkgs-lib.follows = "nixpkgs";
@ -9,7 +11,12 @@
}; };
outputs = outputs =
{ self, flake-parts, ... }@inputs: {
self,
crane,
flake-parts,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } { flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ systems = [
"x86_64-linux" "x86_64-linux"
@ -22,7 +29,10 @@
{ self', pkgs, ... }: { self', pkgs, ... }:
{ {
packages = { packages = {
tyrolienne = pkgs.callPackage ./package.nix { inherit self; }; tyrolienne = pkgs.callPackage ./package.nix {
inherit self;
craneLib = crane.mkLib pkgs;
};
default = self'.packages.tyrolienne; default = self'.packages.tyrolienne;
}; };

View file

@ -1,23 +1,21 @@
{ {
lib,
rustPlatform,
mold-wrapped,
self, self,
lib,
craneLib,
mold-wrapped,
}: }:
let let
cargoToml = lib.importTOML ./Cargo.toml; cargoToml = lib.importTOML ./Cargo.toml;
rev = self.shortRev or self.dirtyShortRev or "dirty"; rev = self.shortRev or self.dirtyShortRev or "dirty";
in in
rustPlatform.buildRustPackage { craneLib.buildPackage {
pname = cargoToml.package.name; pname = cargoToml.package.name;
version = "${cargoToml.package.version}+git.${rev}"; version = "${cargoToml.package.version}+git.${rev}";
src = self; src = craneLib.cleanCargoSource ./.;
nativeBuildInputs = [ mold-wrapped ]; nativeBuildInputs = [ mold-wrapped ];
cargoLock.lockFile = ./Cargo.lock;
RUSTFLAGS = "-C link-arg=-fuse-ld=mold"; RUSTFLAGS = "-C link-arg=-fuse-ld=mold";
doCheck = false; doCheck = false;