forked from Deuxfleurs/tricot
flake.nix: switch to crane
This commit is contained in:
parent
2a679f97b6
commit
888f499b97
6 changed files with 123 additions and 4220 deletions
|
@ -17,10 +17,9 @@ steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: nixpkgs/nix:nixos-22.05
|
image: nixpkgs/nix:nixos-22.05
|
||||||
commands:
|
commands:
|
||||||
- nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#debug.x86_64-linux.tricot
|
- nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#packages.x86_64-linux.debug
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
image: nixpkgs/nix:nixos-22.05
|
image: nixpkgs/nix:nixos-22.05
|
||||||
commands:
|
commands:
|
||||||
- nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#test.x86_64-linux.tricot
|
- nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#packages.x86_64-linux.test
|
||||||
- ./result-bin/bin/tricot-*
|
|
||||||
|
|
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -1,6 +1,6 @@
|
||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "accept-encoding-fork"
|
name = "accept-encoding-fork"
|
||||||
|
@ -1126,6 +1126,15 @@ version = "0.1.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "openssl-src"
|
||||||
|
version = "300.2.3+3.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5cff92b6f71555b61bb9315f7c64da3ca43d87531622120fea0195fc761b4843"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.104"
|
version = "0.9.104"
|
||||||
|
@ -1134,6 +1143,7 @@ checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
|
"openssl-src",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
"vcpkg",
|
"vcpkg",
|
||||||
]
|
]
|
||||||
|
@ -2254,6 +2264,7 @@ dependencies = [
|
||||||
"http",
|
"http",
|
||||||
"hyper",
|
"hyper",
|
||||||
"hyper-rustls",
|
"hyper-rustls",
|
||||||
|
"openssl",
|
||||||
"opentelemetry",
|
"opentelemetry",
|
||||||
"opentelemetry-prometheus",
|
"opentelemetry-prometheus",
|
||||||
"prometheus",
|
"prometheus",
|
||||||
|
|
|
@ -26,6 +26,7 @@ hyper = { version = "0.14", features = [ "full" ] }
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
tokio-rustls = "0.24"
|
tokio-rustls = "0.24"
|
||||||
hyper-rustls = "0.24"
|
hyper-rustls = "0.24"
|
||||||
|
openssl = { version = "*", features = [ "vendored" ] }
|
||||||
http = "0.2"
|
http = "0.2"
|
||||||
structopt = "0.3"
|
structopt = "0.3"
|
||||||
glob = "0.3"
|
glob = "0.3"
|
||||||
|
|
88
flake.lock
generated
88
flake.lock
generated
|
@ -1,52 +1,30 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"cargo2nix": {
|
"crane": {
|
||||||
"inputs": {
|
|
||||||
"flake-compat": "flake-compat",
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
],
|
|
||||||
"rust-overlay": "rust-overlay"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1713199118,
|
"lastModified": 1739638817,
|
||||||
"narHash": "sha256-MlLdAvk+zXCFUy280sY6LqtykqWXIkKVXo72J7a6HlU=",
|
"narHash": "sha256-pPiI27T416xAAUETorkLAgHQMiLT92moOrf0ItHhtPA=",
|
||||||
"owner": "cargo2nix",
|
"owner": "ipetkov",
|
||||||
"repo": "cargo2nix",
|
"repo": "crane",
|
||||||
"rev": "1efb03f2f794ad5eed17e807e858c4da001dbc3e",
|
"rev": "bef2b45cd1273a9e621fb5292de89f4ed59ad812",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "cargo2nix",
|
"owner": "ipetkov",
|
||||||
"repo": "cargo2nix",
|
"repo": "crane",
|
||||||
"rev": "1efb03f2f794ad5eed17e807e858c4da001dbc3e",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"flake-compat": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1650374568,
|
|
||||||
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
|
||||||
"owner": "edolstra",
|
|
||||||
"repo": "flake-compat",
|
|
||||||
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "edolstra",
|
|
||||||
"repo": "flake-compat",
|
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils": {
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1659877975,
|
"lastModified": 1731533236,
|
||||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -57,45 +35,61 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1731094700,
|
"lastModified": 1736692550,
|
||||||
"narHash": "sha256-lSiVjHP7sgnCt2hZabnq+tCLmBerDKmAdd2CS6BrBjw=",
|
"narHash": "sha256-7tk8xH+g0sJkKLTJFOxphJxxOjMDFMWv24nXslaU2ro=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "551ba0fa7653afb9d590db225c3bcbccf68931c0",
|
"rev": "7c4869c47090dd7f9f1bdfb49a22aea026996815",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "551ba0fa7653afb9d590db225c3bcbccf68931c0",
|
"rev": "7c4869c47090dd7f9f1bdfb49a22aea026996815",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"cargo2nix": "cargo2nix",
|
"crane": "crane",
|
||||||
"nixpkgs": "nixpkgs"
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"cargo2nix",
|
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1731032894,
|
"lastModified": 1738549608,
|
||||||
"narHash": "sha256-dQSyYPmrQiPr+PGEd+K8038rubFGz7G/dNXVeaGWE0w=",
|
"narHash": "sha256-GdyT9QEUSx5k/n8kILuNy83vxxdyUfJ8jL5mMpQZWfw=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "d52f2a4c103a0acf09ded857b9e2519ae2360e59",
|
"rev": "35c6f8c4352f995ecd53896200769f80a3e8f22d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "d52f2a4c103a0acf09ded857b9e2519ae2360e59",
|
"rev": "35c6f8c4352f995ecd53896200769f80a3e8f22d",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
117
flake.nix
117
flake.nix
|
@ -1,61 +1,78 @@
|
||||||
{
|
{
|
||||||
description = "Tricot, a reverse proxy with consul integration";
|
description = "Tricot, a reverse proxy with consul integration";
|
||||||
|
|
||||||
# Nixpkgs 24.05 as of 2024-11-08, has rustc v1.77.2
|
# Nixpkgs 24.11 as of 2025-01-12
|
||||||
inputs.nixpkgs.url =
|
inputs.nixpkgs.url =
|
||||||
"github:NixOS/nixpkgs/551ba0fa7653afb9d590db225c3bcbccf68931c0";
|
"github:NixOS/nixpkgs/7c4869c47090dd7f9f1bdfb49a22aea026996815";
|
||||||
inputs.cargo2nix = {
|
|
||||||
# cargo2nix as of 2024-04-25
|
|
||||||
# NB: upgrading to a more recent commit of cargo2nix will not work (as of 2024-11-08),
|
|
||||||
# because the patch making openssl-sys cross-compilation work has been reverted.
|
|
||||||
# (patch: https://github.com/cargo2nix/cargo2nix/pull/237,
|
|
||||||
# revert: https://github.com/cargo2nix/cargo2nix/commit/cfd086deb565314f3a11b5bb25807a3ce17315d4)
|
|
||||||
url = "github:cargo2nix/cargo2nix/1efb03f2f794ad5eed17e807e858c4da001dbc3e";
|
|
||||||
|
|
||||||
# Rust overlay as of 2024-11-08
|
# Rust overlay as of 2025-02-03
|
||||||
inputs.rust-overlay.url =
|
inputs.rust-overlay.url =
|
||||||
"github:oxalica/rust-overlay/d52f2a4c103a0acf09ded857b9e2519ae2360e59";
|
"github:oxalica/rust-overlay/35c6f8c4352f995ecd53896200769f80a3e8f22d";
|
||||||
|
inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.crane.url = "github:ipetkov/crane";
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, cargo2nix }:
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
let
|
|
||||||
targetHost = "x86_64-unknown-linux-musl";
|
|
||||||
pkgs = import nixpkgs {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
crossSystem = {
|
|
||||||
config = targetHost;
|
|
||||||
isStatic = true;
|
|
||||||
};
|
|
||||||
overlays = [ cargo2nix.overlays.default ];
|
|
||||||
};
|
|
||||||
packageFun = import ./Cargo.nix;
|
|
||||||
rustVersion = "1.77.2";
|
|
||||||
|
|
||||||
compile = args: compileMode:
|
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
|
||||||
|
flake-utils.lib.eachSystem [ "x86_64-linux" ] (localSystem:
|
||||||
let
|
let
|
||||||
packageSet = pkgs.rustBuilder.makePackageSet ({
|
crossSystem = "x86_64-unknown-linux-musl";
|
||||||
inherit packageFun rustVersion;
|
rustVersion = "1.84.0";
|
||||||
target = targetHost;
|
|
||||||
} // args);
|
|
||||||
in
|
|
||||||
packageSet.workspace.tricot {
|
|
||||||
inherit compileMode;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
test.x86_64-linux.tricot = compile { release = false; } "test";
|
|
||||||
debug.x86_64-linux.tricot = compile { release = false; } "build";
|
|
||||||
packages.x86_64-linux.tricot = compile { release = true; } "build";
|
|
||||||
packages.x86_64-linux.default = self.packages.x86_64-linux.tricot;
|
|
||||||
|
|
||||||
docker = pkgs.dockerTools.buildImage {
|
pkgs = import nixpkgs {
|
||||||
name = "tricot";
|
# we need a full musl toolchain because we're depending on openssl (a
|
||||||
config = {
|
# C library), which we thus need to compile for musl
|
||||||
contents = [ pkgs.cacert ];
|
inherit localSystem;
|
||||||
Cmd = [ "${self.packages.x86_64-linux.default}/bin/tricot" ];
|
crossSystem = { config = crossSystem; };
|
||||||
};
|
overlays = [ (import rust-overlay) ];
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
craneLib = (crane.mkLib pkgs).overrideToolchain
|
||||||
|
(p: p.rust-bin.stable.${rustVersion}.default);
|
||||||
|
|
||||||
|
commonArgs = {
|
||||||
|
src = craneLib.cleanCargoSource ./.;
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
|
# required for building openssl
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkgs.perl
|
||||||
|
];
|
||||||
|
OPENSSL_STATIC = "yes";
|
||||||
|
|
||||||
|
CARGO_BUILD_TARGET = crossSystem;
|
||||||
|
CARGO_BUILD_RUSTFLAGS = "-C target-feature=+crt-static";
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
devArgs = (commonArgs // { CARGO_PROFILE = "dev"; });
|
||||||
|
releaseArgs = (commonArgs // { CARGO_PROFILE = "release"; });
|
||||||
|
|
||||||
|
tricot-deps-dev = craneLib.buildDepsOnly devArgs;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = rec {
|
||||||
|
default = craneLib.buildPackage releaseArgs;
|
||||||
|
|
||||||
|
debug = craneLib.buildPackage (devArgs // {
|
||||||
|
cargoArtifacts = tricot-deps-dev;
|
||||||
|
});
|
||||||
|
|
||||||
|
test = craneLib.cargoTest (devArgs // {
|
||||||
|
cargoArtifacts = tricot-deps-dev;
|
||||||
|
doCheck = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
docker = pkgs.dockerTools.buildImage {
|
||||||
|
name = "tricot";
|
||||||
|
config = {
|
||||||
|
contents = [ pkgs.cacert ];
|
||||||
|
Cmd = [ "${self.packages.x86_64-linux.default}/bin/tricot" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue