diff options
Diffstat (limited to 'nix/deployment/static.nix')
| -rw-r--r-- | nix/deployment/static.nix | 50 |
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 + ); + }; +} |
