summaryrefslogtreecommitdiff
path: root/nix/deployment/static.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2024-03-20 08:12:19 -0400
committerseth <[email protected]>2024-03-20 08:12:19 -0400
commitd48ab1b30a4b6c093c2d7ff27dfb0b6d7a2bafdd (patch)
tree0ab828f6c6738ec495aafbdf29c46c3cc3a5cbfe /nix/deployment/static.nix
parent0f280dd61c1c138e4c41b715e27fc292f24bbac9 (diff)
nix: naersk -> rustPlatform
Diffstat (limited to 'nix/deployment/static.nix')
-rw-r--r--nix/deployment/static.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/nix/deployment/static.nix b/nix/deployment/static.nix
new file mode 100644
index 0000000..dcdf0f3
--- /dev/null
+++ b/nix/deployment/static.nix
@@ -0,0 +1,50 @@
+{
+ perSystem = {
+ lib,
+ pkgs,
+ inputs',
+ self',
+ ...
+ }: let
+ targets = with pkgs.pkgsCross; {
+ x86_64 = musl64.pkgsStatic;
+ aarch64 = aarch64-multiplatform.pkgsStatic;
+ };
+
+ toolchain = let
+ fenix = inputs'.fenix.packages;
+ in
+ with fenix;
+ combine (
+ [minimal.cargo minimal.rustc]
+ ++ map (
+ pkgs:
+ fenix.targets.${pkgs.stdenv.hostPlatform.config}.latest.rust-std
+ ) (lib.attrValues targets)
+ );
+
+ rustPlatforms =
+ lib.mapAttrs (
+ lib.const (pkgs:
+ pkgs.makeRustPlatform (
+ lib.genAttrs ["cargo" "rustc"] (lib.const toolchain)
+ ))
+ )
+ targets;
+
+ buildTeawieWith = rustPlatform:
+ self'.packages.teawiebot.override {
+ inherit rustPlatform;
+ lto = true;
+ optimizeSize = true;
+ };
+ in {
+ packages = lib.optionalAttrs pkgs.stdenv.isLinux (
+ lib.mapAttrs' (
+ target: rustPlatform:
+ lib.nameValuePair "teawiebot-static-${target}" (buildTeawieWith rustPlatform)
+ )
+ rustPlatforms
+ );
+ };
+}