diff options
| author | seth <[email protected]> | 2024-03-20 02:28:43 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-03-20 06:34:42 +0000 |
| commit | faa038757ced955bb5c0a98dae7be6e7185af677 (patch) | |
| tree | 319cbd2e11cf74e2a464dbaf42370ec1f8eb57de /nix/deployment.nix | |
| parent | 362b80924010d0e425dc41885c8ee148f6d9ca36 (diff) | |
nix: cleanup derivation + static package
Diffstat (limited to 'nix/deployment.nix')
| -rw-r--r-- | nix/deployment.nix | 61 |
1 files changed, 12 insertions, 49 deletions
diff --git a/nix/deployment.nix b/nix/deployment.nix index 88a9f51..514b307 100644 --- a/nix/deployment.nix +++ b/nix/deployment.nix @@ -14,58 +14,21 @@ system, config, inputs', + self', ... }: 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; - }; - - "x86_64-darwin" = { - "x86_64" = pkgs.pkgsCross.musl64; - "aarch64" = pkgs.pkgsCross.aarch64-multiplatform.pkgsStatic; - }; - - "aarch64-darwin" = crossPkgs."x86_64-darwin"; + crossPkgs = with pkgs.pkgsCross; { + x86_64 = musl64; + aarch64 = aarch64-multiplatform.pkgsStatic; }; - teawieFor = arch: let - inherit (crossPkgs.${system}.${arch}.llvmPackages.stdenv) cc; - - target = "${arch}-unknown-linux-musl"; - target' = builtins.replaceStrings ["-"] ["_"] target; - targetUpper = lib.toUpper target'; - - toolchain = with inputs'.fenix.packages; - combine [ - minimal.cargo - minimal.rustc - targets.${target}.latest.rust-std - ]; - - naersk = inputs.naersk.lib.${system}.override { - cargo = toolchain; - rustc = toolchain; + teawieFor = arch: + pkgs.callPackage ./static.nix { + inherit (self'.packages) teawiebot; + pkgsStatic = crossPkgs.${arch}; + fenix = inputs'.fenix.packages; + naersk = inputs.naersk.lib.${system}; }; - 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 { @@ -73,10 +36,10 @@ tag = "latest-${arch}"; contents = [pkgs.dockerTools.caCertificates]; config.Cmd = [ - (lib.getExe (teawieFor arch)) + (lib.getExe self'.packages."teawiebot-static-${arch}") ]; - architecture = crossPkgs.${system}.${arch}.go.GOARCH; + architecture = crossPkgs.${arch}.go.GOARCH; }; in { packages = { |
