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; inherit system;
overlays = [ nixuniverse ]; overlays = [ nixuniverse ];
}; };
albatros = pkgs.buildGoModule rec { gopkg = arch: (pkgs.buildGoModule rec {
pname = "albatros"; pname = "albatros-go-module";
version = "0.9"; version = "0.9";
src = ./.; src = ./.;
CGO_ENABLED = 0; CGO_ENABLED = 0;
@ -29,17 +29,29 @@
license = licenses.agpl3; license = licenses.agpl3;
platforms = platforms.linux; 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"; name = "dxflrs/albatros";
config = { config = {
Cmd = [ "${albatros}/bin/albatros" ]; Cmd = [ "${staticBin}" ];
}; };
}; };
in in
{ {
packages.x86_64-linux.albatros = albatros; packages.aarch64-linux.albatros = albatros "arm64" ;
packages.x86_64-linux.docker.albatros = docker; 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; packages.x86_64-linux.default = self.packages.x86_64-linux.albatros;
devShell.x86_64-linux = pkgs.mkShell { buildInputs = [ pkgs.kaniko pkgs.manifest-tool ]; }; devShell.x86_64-linux = pkgs.mkShell { buildInputs = [ pkgs.kaniko pkgs.manifest-tool ]; };