summaryrefslogtreecommitdiff
path: root/parts/packages.nix
blob: f44ac507f2a5804a6e0bd307ac675ab848011669 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{self, ...}: {
  perSystem = {
    craneLib,
    pkgs,
    system,
    ...
  }: let
    inherit (pkgs.lib) licenses maintainers platforms;
    inherit (craneLib) buildPackage;
  in {
    packages = {
      cargoArtifacts = craneLib.buildDepsOnly {src = self;};

      teawiebot = buildPackage {
        src = self;
        inherit (self.packages.${system}) cargoArtifacts;

        meta = {
          description = "funni bot";
          homepage = "https://github.com/getchoo/teawiebot";
          license = licenses.mit;
          platforms = platforms.unix;
          maintainers = with maintainers; [getchoo];
        };
      };

      teawiebot-smol =
        self.packages.${system}.teawiebot.overrideAttrs (_: {
            # statically link musl, optimize for size
            CARGO_BUILD_TARGET = "x86_64-unknown-linux-musl";

            CARGO_BUILD_RUSTFLAGS = "-C lto=fat -C embed-bitcode=yes \
									-C target-feature=+crt-static -C opt-level=z -C strip=symbols -C codegen-units=1";

            CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER = let
              inherit (pkgs.pkgsStatic.stdenv) cc;
            in "${cc}/bin/${cc.targetPrefix}cc";
          });

      default = self.packages.${system}.teawiebot;
    };
  };
}