tricot/flake.nix
2024-11-08 22:14:18 +01:00

61 lines
2 KiB
Nix

{
description = "Tricot, a reverse proxy with consul integration";
# Nixpkgs 24.05 as of 2024-11-08, has rustc v1.77.2
inputs.nixpkgs.url =
"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 2024-11-08
inputs.rust-overlay.url =
"github:oxalica/rust-overlay/d52f2a4c103a0acf09ded857b9e2519ae2360e59";
inputs.nixpkgs.follows = "nixpkgs";
};
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";
compile = args: compileMode:
let
packageSet = pkgs.rustBuilder.makePackageSet ({
inherit packageFun rustVersion;
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 {
name = "tricot";
config = {
contents = [ pkgs.cacert ];
Cmd = [ "${self.packages.x86_64-linux.default}/bin/tricot" ];
};
};
};
}