feat: switch to crane
Should provide better caching of the intermediate build artifacts.
This commit is contained in:
parent
8dd8b9e3aa
commit
d44d2aa1a7
5 changed files with 83 additions and 64 deletions
|
@ -1,2 +1,2 @@
|
||||||
[build]
|
[build]
|
||||||
rustflags = ["-Clink-arg=-fuse-ld=mold", "-Zthreads=16"]
|
rustflags = ["-Clink-arg=-fuse-ld=mold"]
|
||||||
|
|
43
default.nix
43
default.nix
|
@ -1,43 +0,0 @@
|
||||||
{ lib, rustPlatform }:
|
|
||||||
let
|
|
||||||
readToml = path: builtins.fromTOML (builtins.readFile path);
|
|
||||||
cargoToml = readToml ./Cargo.toml;
|
|
||||||
pname = cargoToml.package.name;
|
|
||||||
inherit (cargoToml.package) version description;
|
|
||||||
src = lib.cleanSourceWith {
|
|
||||||
src = ./.;
|
|
||||||
name = "${pname}-source";
|
|
||||||
# Adapted from <https://github.com/ipetkov/crane/blob/master/lib/filterCargoSources.nix>
|
|
||||||
# no need to pull in crane for just this
|
|
||||||
filter =
|
|
||||||
orig_path: type:
|
|
||||||
let
|
|
||||||
path = toString orig_path;
|
|
||||||
base = baseNameOf path;
|
|
||||||
matchesSuffix = lib.any (suffix: lib.hasSuffix suffix base) [
|
|
||||||
# Rust sources
|
|
||||||
".rs"
|
|
||||||
# TOML files are often used to configure cargo based tools (e.g. .cargo/config.toml)
|
|
||||||
".toml"
|
|
||||||
# Snapshot tests
|
|
||||||
".snap"
|
|
||||||
];
|
|
||||||
isCargoLock = base == "Cargo.lock";
|
|
||||||
in
|
|
||||||
type == "directory" || matchesSuffix || isCargoLock;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
rustPlatform.buildRustPackage {
|
|
||||||
inherit pname version src;
|
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
|
||||||
useNextest = true;
|
|
||||||
NEXTEST_HIDE_PROGRESS_BAR = 1;
|
|
||||||
NEXTEST_FAILURE_OUTPUT = "immediate-final";
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
inherit description;
|
|
||||||
license = lib.licenses.mit;
|
|
||||||
homepage = "https://github.com/jalil-salame/webnsupdate";
|
|
||||||
mainProgram = "webnsupdate";
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,12 +1,57 @@
|
||||||
|
{ inputs, lib, ... }:
|
||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
|
||||||
packages =
|
|
||||||
let
|
let
|
||||||
webnsupdate = pkgs.callPackage ../default.nix { };
|
craneLib = inputs.crane.mkLib pkgs;
|
||||||
|
src = craneLib.cleanCargoSource inputs.self;
|
||||||
|
|
||||||
|
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 = [ pkgs.mold ];
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
license = lib.licenses.mit;
|
||||||
|
homepage = "https://github.com/jalil-salame/webnsupdate";
|
||||||
|
mainProgram = "webnsupdate";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||||
|
webnsupdate = craneLib.buildPackage (
|
||||||
|
lib.mergeAttrsList [
|
||||||
|
commonArgs
|
||||||
|
{ inherit cargoArtifacts; }
|
||||||
|
]
|
||||||
|
);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
checks = {
|
||||||
|
clippy = craneLib.cargoClippy (
|
||||||
|
lib.mergeAttrsList [
|
||||||
|
commonArgs
|
||||||
|
{
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||||
|
}
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
nextest = craneLib.cargoNextest (
|
||||||
|
lib.mergeAttrsList [
|
||||||
|
commonArgs
|
||||||
|
{ inherit cargoArtifacts; }
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = {
|
||||||
inherit webnsupdate;
|
inherit webnsupdate;
|
||||||
default = webnsupdate;
|
default = webnsupdate;
|
||||||
cargo-update = pkgs.writeShellApplication {
|
cargo-update = pkgs.writeShellApplication {
|
||||||
|
|
16
flake.lock
16
flake.lock
|
@ -1,5 +1,20 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"crane": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1730060262,
|
||||||
|
"narHash": "sha256-RMgSVkZ9H03sxC+Vh4jxtLTCzSjPq18UWpiM0gq6shQ=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "498d9f122c413ee1154e8131ace5a35a80d8fa76",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-parts": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs-lib": [
|
"nixpkgs-lib": [
|
||||||
|
@ -37,6 +52,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"systems": "systems",
|
"systems": "systems",
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{
|
{
|
||||||
description = "An http server that calls nsupdate internally";
|
description = "An http server that calls nsupdate internally";
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
crane.url = "github:ipetkov/crane";
|
||||||
systems.url = "github:nix-systems/default";
|
|
||||||
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";
|
||||||
};
|
};
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
|
systems.url = "github:nix-systems/default";
|
||||||
treefmt-nix = {
|
treefmt-nix = {
|
||||||
url = "github:numtide/treefmt-nix";
|
url = "github:numtide/treefmt-nix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
Loading…
Reference in a new issue