2023-03-16 11:24:23 +00:00
|
|
|
{
|
|
|
|
description = "Albatros";
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = { self, nixpkgs }:
|
|
|
|
let
|
2023-04-11 08:45:14 +00:00
|
|
|
# @FIXME probably not a good idea to hardcode it...
|
2023-03-16 11:24:23 +00:00
|
|
|
system = "x86_64-linux";
|
2023-04-11 08:45:14 +00:00
|
|
|
|
2023-03-16 11:24:23 +00:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2023-04-11 08:45:14 +00:00
|
|
|
overlays = [ ]; # we dropped the overlay we had, keep it as "skeleton".
|
2023-03-16 11:24:23 +00:00
|
|
|
};
|
2023-04-11 08:45:14 +00:00
|
|
|
|
|
|
|
# declare the go module of this package, allow for cross compilation
|
2023-04-20 10:27:14 +00:00
|
|
|
albatrosStaticBin = arch: (pkgs.buildGoModule rec {
|
2023-04-06 16:20:30 +00:00
|
|
|
pname = "albatros-go-module";
|
2023-03-16 11:24:23 +00:00
|
|
|
version = "0.9";
|
|
|
|
src = ./.;
|
2023-03-16 11:33:39 +00:00
|
|
|
CGO_ENABLED = 0;
|
2023-04-20 10:27:14 +00:00
|
|
|
vendorSha256 = "sha256-jzRYYsopJDYsar0nSYkTAOCGf4z20sgpDQ/eFmwYzM8=";
|
|
|
|
checkPhase = ''
|
|
|
|
true
|
|
|
|
'';
|
|
|
|
buildPhase = ''
|
|
|
|
go build bin/albatros.go
|
|
|
|
'';
|
|
|
|
installPhase = ''
|
|
|
|
cp albatros $out
|
|
|
|
'';
|
2023-03-16 11:24:23 +00:00
|
|
|
meta = with pkgs.lib; {
|
|
|
|
description = "albatros is a CI for Nomad";
|
|
|
|
homepage = "https://git.deuxfleurs.fr/quentin/albatros";
|
|
|
|
license = licenses.agpl3;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
2023-04-06 16:20:30 +00:00
|
|
|
}).overrideAttrs (old: old // { GOOS = "linux"; GOARCH = arch; });
|
2023-04-11 08:45:14 +00:00
|
|
|
|
|
|
|
# logic to build docker containers
|
2023-04-06 16:35:13 +00:00
|
|
|
docker = staticBin: arch: pkgs.dockerTools.buildImage {
|
2023-03-16 11:24:23 +00:00
|
|
|
name = "dxflrs/albatros";
|
2023-04-06 16:35:13 +00:00
|
|
|
architecture = arch;
|
2023-03-16 11:24:23 +00:00
|
|
|
config = {
|
2023-04-06 16:20:30 +00:00
|
|
|
Cmd = [ "${staticBin}" ];
|
2023-03-16 11:24:23 +00:00
|
|
|
};
|
|
|
|
};
|
2023-04-06 16:20:30 +00:00
|
|
|
|
2023-04-11 08:45:14 +00:00
|
|
|
# map nixos/llvm arch to golang arch
|
|
|
|
archmap = {
|
|
|
|
"aarch64-linux" = "arm64";
|
|
|
|
"x86_64-linux" = "amd64";
|
|
|
|
"i686-linux" = "386";
|
|
|
|
"armv6l-linux" = "arm";
|
|
|
|
};
|
2023-03-16 11:24:23 +00:00
|
|
|
|
2023-04-11 08:45:14 +00:00
|
|
|
# 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;
|
2023-03-16 11:24:23 +00:00
|
|
|
};
|
|
|
|
}
|