Compare commits

..

No commits in common. "main" and "armael-patch-1" have entirely different histories.

6 changed files with 4219 additions and 122 deletions

View file

@ -17,9 +17,10 @@ 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 .#packages.x86_64-linux.debug - nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#debug.x86_64-linux.tricot
- 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 .#packages.x86_64-linux.test - nix build --extra-experimental-features nix-command --extra-experimental-features flakes .#test.x86_64-linux.tricot
- ./result-bin/bin/tricot-*

13
Cargo.lock generated
View file

@ -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 = 4 version = 3
[[package]] [[package]]
name = "accept-encoding-fork" name = "accept-encoding-fork"
@ -1126,15 +1126,6 @@ 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"
@ -1143,7 +1134,6 @@ checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741"
dependencies = [ dependencies = [
"cc", "cc",
"libc", "libc",
"openssl-src",
"pkg-config", "pkg-config",
"vcpkg", "vcpkg",
] ]
@ -2264,7 +2254,6 @@ dependencies = [
"http", "http",
"hyper", "hyper",
"hyper-rustls", "hyper-rustls",
"openssl",
"opentelemetry", "opentelemetry",
"opentelemetry-prometheus", "opentelemetry-prometheus",
"prometheus", "prometheus",

4119
Cargo.nix Normal file

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,6 @@ 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
View file

@ -1,30 +1,52 @@
{ {
"nodes": { "nodes": {
"crane": { "cargo2nix": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": { "locked": {
"lastModified": 1739638817, "lastModified": 1713199118,
"narHash": "sha256-pPiI27T416xAAUETorkLAgHQMiLT92moOrf0ItHhtPA=", "narHash": "sha256-MlLdAvk+zXCFUy280sY6LqtykqWXIkKVXo72J7a6HlU=",
"owner": "ipetkov", "owner": "cargo2nix",
"repo": "crane", "repo": "cargo2nix",
"rev": "bef2b45cd1273a9e621fb5292de89f4ed59ad812", "rev": "1efb03f2f794ad5eed17e807e858c4da001dbc3e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "ipetkov", "owner": "cargo2nix",
"repo": "crane", "repo": "cargo2nix",
"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": 1731533236, "lastModified": 1659877975,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -35,61 +57,45 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1736692550, "lastModified": 1731094700,
"narHash": "sha256-7tk8xH+g0sJkKLTJFOxphJxxOjMDFMWv24nXslaU2ro=", "narHash": "sha256-lSiVjHP7sgnCt2hZabnq+tCLmBerDKmAdd2CS6BrBjw=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "7c4869c47090dd7f9f1bdfb49a22aea026996815", "rev": "551ba0fa7653afb9d590db225c3bcbccf68931c0",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "7c4869c47090dd7f9f1bdfb49a22aea026996815", "rev": "551ba0fa7653afb9d590db225c3bcbccf68931c0",
"type": "github" "type": "github"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"crane": "crane", "cargo2nix": "cargo2nix",
"flake-utils": "flake-utils", "nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"cargo2nix",
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1738549608, "lastModified": 1731032894,
"narHash": "sha256-GdyT9QEUSx5k/n8kILuNy83vxxdyUfJ8jL5mMpQZWfw=", "narHash": "sha256-dQSyYPmrQiPr+PGEd+K8038rubFGz7G/dNXVeaGWE0w=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "35c6f8c4352f995ecd53896200769f80a3e8f22d", "rev": "d52f2a4c103a0acf09ded857b9e2519ae2360e59",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "35c6f8c4352f995ecd53896200769f80a3e8f22d", "rev": "d52f2a4c103a0acf09ded857b9e2519ae2360e59",
"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"
} }
} }

115
flake.nix
View file

@ -1,78 +1,61 @@
{ {
description = "Tricot, a reverse proxy with consul integration"; description = "Tricot, a reverse proxy with consul integration";
# Nixpkgs 24.11 as of 2025-01-12 # Nixpkgs 24.05 as of 2024-11-08, has rustc v1.77.2
inputs.nixpkgs.url = inputs.nixpkgs.url =
"github:NixOS/nixpkgs/7c4869c47090dd7f9f1bdfb49a22aea026996815"; "github:NixOS/nixpkgs/551ba0fa7653afb9d590db225c3bcbccf68931c0";
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 2025-02-03 # Rust overlay as of 2024-11-08
inputs.rust-overlay.url = inputs.rust-overlay.url =
"github:oxalica/rust-overlay/35c6f8c4352f995ecd53896200769f80a3e8f22d"; "github:oxalica/rust-overlay/d52f2a4c103a0acf09ded857b9e2519ae2360e59";
inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
inputs.crane.url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs";
};
inputs.flake-utils.url = "github:numtide/flake-utils"; outputs = { self, nixpkgs, cargo2nix }:
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";
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }: compile = args: compileMode:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (localSystem:
let let
crossSystem = "x86_64-unknown-linux-musl"; packageSet = pkgs.rustBuilder.makePackageSet ({
rustVersion = "1.84.0"; inherit packageFun rustVersion;
target = targetHost;
pkgs = import nixpkgs { } // args);
# we need a full musl toolchain because we're depending on openssl (a
# C library), which we thus need to compile for musl
inherit localSystem;
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 in
{ packageSet.workspace.tricot {
packages = rec { inherit compileMode;
default = craneLib.buildPackage releaseArgs; };
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;
debug = craneLib.buildPackage (devArgs // { docker = pkgs.dockerTools.buildImage {
cargoArtifacts = tricot-deps-dev; name = "tricot";
}); config = {
contents = [ pkgs.cacert ];
test = craneLib.cargoTest (devArgs // { Cmd = [ "${self.packages.x86_64-linux.default}/bin/tricot" ];
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" ];
};
};
};
}
);
} }