albatros/flake.nix

68 lines
1.9 KiB
Nix

{
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
albatrosStaticBin = arch: (pkgs.buildGoModule rec {
pname = "albatros-go-module";
version = "0.9";
src = ./.;
CGO_ENABLED = 0;
vendorSha256 = "sha256-jzRYYsopJDYsar0nSYkTAOCGf4z20sgpDQ/eFmwYzM8=";
checkPhase = ''
true
'';
buildPhase = ''
go build bin/albatros.go
'';
installPhase = ''
cp albatros $out
'';
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 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;
};
}