{ description = "Albatros"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; }; outputs = { self, nixpkgs }: let # @FIXME probably not a good idea to hardcode it... system = "x86_64-linux"; pkgs = import nixpkgs { inherit system; overlays = [ ]; # we dropped the overlay we had, keep it as "skeleton". }; # declare the go module of this package, allow for cross compilation gopkg = arch: (pkgs.buildGoModule rec { pname = "albatros-go-module"; version = "0.9"; src = ./.; CGO_ENABLED = 0; vendorSha256 = "sha256-Q7gImRoJqtcORpHLQoF3TRK2WJu3tKSjSE3Sno6lNNk="; checkPhase = "true"; meta = with pkgs.lib; { description = "albatros is a CI for Nomad"; homepage = "https://git.deuxfleurs.fr/quentin/albatros"; license = licenses.agpl3; platforms = platforms.linux; }; }).overrideAttrs (old: old // { GOOS = "linux"; GOARCH = arch; }); # logic to build static binaries albatrosStaticBin = arch: pkgs.stdenv.mkDerivation { pname = "albatros"; version = "0.9"; unpackPhase = "true"; installPhase = '' cp `find ${gopkg arch}/bin -name albatros` $out ''; }; # logic to build docker containers docker = staticBin: arch: pkgs.dockerTools.buildImage { name = "dxflrs/albatros"; architecture = arch; config = { Cmd = [ "${staticBin}" ]; }; }; # map nixos/llvm arch to golang arch archmap = { "aarch64-linux" = "arm64"; "x86_64-linux" = "amd64"; "i686-linux" = "386"; "armv6l-linux" = "arm"; }; # generate packages for each architecture packages = builtins.mapAttrs (name: value: rec { albatros = (albatrosStaticBin value); docker.albatros = (docker albatros value); default = albatros; }) archmap; in { inherit packages; }; }