diff options
Diffstat (limited to 'nix')
| -rw-r--r-- | nix/deployment.nix | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/nix/deployment.nix b/nix/deployment.nix index 080cac9..88a9f51 100644 --- a/nix/deployment.nix +++ b/nix/deployment.nix @@ -16,26 +16,27 @@ inputs', ... }: let - containerFor = arch: let - crossPkgs = { - "x86_64-linux" = { - "x86_64" = pkgs.pkgsStatic; - "aarch64" = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic; - }; - - "aarch64-linux" = { - "x86_64" = pkgs.pkgsCross.musl64; - "aarch64" = pkgs.pkgsStatic; - }; + crossPkgs = { + "x86_64-linux" = { + "x86_64" = pkgs.pkgsStatic; + "aarch64" = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic; + }; - "x86_64-darwin" = { - "x86_64" = pkgs.pkgsCross.musl64; - "aarch64" = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic; - }; + "aarch64-linux" = { + "x86_64" = pkgs.pkgsCross.musl64; + "aarch64" = pkgs.pkgsStatic; + }; - "aarch64-darwin" = crossPkgs."x86_64-darwin"; + "x86_64-darwin" = { + "x86_64" = pkgs.pkgsCross.musl64; + "aarch64" = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic; }; - inherit (crossPkgs.${system}.${arch}.stdenv) cc; + + "aarch64-darwin" = crossPkgs."x86_64-darwin"; + }; + + teawieFor = arch: let + inherit (crossPkgs.${system}.${arch}.llvmPackages.stdenv) cc; target = "${arch}-unknown-linux-musl"; target' = builtins.replaceStrings ["-"] ["_"] target; @@ -52,28 +53,35 @@ cargo = toolchain; rustc = toolchain; }; - - teawiebot = - (config.packages.teawiebot.override { - inherit naersk; - optimizeSize = true; - }) - .overrideAttrs (new: - lib.const { - CARGO_BUILD_TARGET = target; - "CC_${target'}" = "${cc}/bin/${cc.targetPrefix}cc"; - "CARGO_TARGET_${targetUpper}_RUSTFLAGS" = "-C target-feature=+crt-static"; - "CARGO_TARGET_${targetUpper}_LINKER" = new."CC_${target'}"; - }); in + (config.packages.teawiebot.override { + inherit naersk; + lto = true; + optimizeSize = true; + }) + .overrideAttrs (new: + lib.const { + CARGO_BUILD_TARGET = target; + "CC_${target'}" = "${cc}/bin/${cc.targetPrefix}cc"; + "CARGO_TARGET_${targetUpper}_RUSTFLAGS" = "-C target-feature=+crt-static"; + "CARGO_TARGET_${targetUpper}_LINKER" = new."CC_${target'}"; + }); + + containerFor = arch: pkgs.dockerTools.buildLayeredImage { name = "teawiebot"; tag = "latest-${arch}"; contents = [pkgs.dockerTools.caCertificates]; - config.Cmd = [(lib.getExe teawiebot)]; + config.Cmd = [ + (lib.getExe (teawieFor arch)) + ]; + + architecture = crossPkgs.${system}.${arch}.go.GOARCH; }; in { packages = { + teawiebot-static-x86_64 = teawieFor "x86_64"; + teawiebot-static-aarch64 = teawieFor "aarch64"; container-x86_64 = containerFor "x86_64"; container-aarch64 = containerFor "aarch64"; }; |
