cross compile and docker image

This commit is contained in:
Quentin 2023-04-06 18:20:30 +02:00
parent 9591374838
commit 0b3c704fab
Signed by: quentin
GPG key ID: E9602264D639FF68

View file

@ -16,8 +16,8 @@
inherit system;
overlays = [ nixuniverse ];
};
albatros = pkgs.buildGoModule rec {
pname = "albatros";
gopkg = arch: (pkgs.buildGoModule rec {
pname = "albatros-go-module";
version = "0.9";
src = ./.;
CGO_ENABLED = 0;
@ -29,17 +29,29 @@
license = licenses.agpl3;
platforms = platforms.linux;
};
}).overrideAttrs (old: old // { GOOS = "linux"; GOARCH = arch; });
albatros = arch: pkgs.stdenv.mkDerivation {
pname = "albatros";
version = "0.9";
unpackPhase = "true";
installPhase = ''
cp `find ${gopkg arch}/bin -name albatros` $out
'';
};
docker = pkgs.dockerTools.buildImage {
docker = staticBin: pkgs.dockerTools.buildImage {
name = "dxflrs/albatros";
config = {
Cmd = [ "${albatros}/bin/albatros" ];
Cmd = [ "${staticBin}" ];
};
};
in
{
packages.x86_64-linux.albatros = albatros;
packages.x86_64-linux.docker.albatros = docker;
packages.aarch64-linux.albatros = albatros "arm64" ;
packages.aarch64-linux.docker.albatros = docker self.packages.aarch64-linux.albatros;
packages.aarch64-linux.default = self.packages.aarch64-linux.albatros;
packages.x86_64-linux.albatros = albatros "amd64";
packages.x86_64-linux.docker.albatros = docker self.packages.x86_64-linux.albatros;
packages.x86_64-linux.default = self.packages.x86_64-linux.albatros;
devShell.x86_64-linux = pkgs.mkShell { buildInputs = [ pkgs.kaniko pkgs.manifest-tool ]; };