albatros/flake.nix

116 lines
3.1 KiB
Nix
Raw Normal View History

2023-03-16 11:24:23 +00:00
{
description = "Albatros";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
2023-05-04 09:00:37 +00:00
flake-utils.url = "github:numtide/flake-utils";
2023-03-16 11:24:23 +00:00
};
2023-05-04 09:00:37 +00:00
outputs = { self, nixpkgs, flake-utils }:
with flake-utils.lib; let
archmap = {
aarch64-linux = {
GOOS = "linux";
GOARCH = "arm64";
};
x86_64-linux = {
GOOS = "linux";
GOARCH = "amd64";
};
i686-linux = {
GOOS = "linux";
GOARCH = "386";
};
armv6l-linux = {
GOOS = "linux";
GOARCH = "arm";
};
};
in eachSystem [
# supported systems
system.x86_64-linux
system.i686-linux
system.armv6l-linux
system.aarch64-linux
] (targetHost: let
2023-04-11 08:45:14 +00:00
2023-05-04 09:00:37 +00:00
# Should be configurable
buildSystem = system.x86_64-linux;
# generic config
albaVersion = "0.9";
# nix repository
2023-03-16 11:24:23 +00:00
pkgs = import nixpkgs {
2023-05-04 09:00:37 +00:00
system = buildSystem;
# we don't use nixos cross environment as it is slow and not required
#crossSystem = {
# config = targetHost;
#};
2023-04-11 08:45:14 +00:00
overlays = [ ]; # we dropped the overlay we had, keep it as "skeleton".
2023-05-04 09:00:37 +00:00
};
2023-04-11 08:45:14 +00:00
2023-05-04 09:00:37 +00:00
# declare the go module of this package
albatrosProject = (pkgs.buildGoModule rec {
2023-04-06 16:20:30 +00:00
pname = "albatros-go-module";
2023-05-04 09:00:37 +00:00
version = albaVersion;
2023-03-16 11:24:23 +00:00
src = ./.;
2023-03-16 11:33:39 +00:00
CGO_ENABLED = 0;
2023-05-04 09:00:37 +00:00
vendorSha256 = "sha256-KYjXb882jWLFO6zilQXlrZorL9tw/+6njQNkB6E9Er4=";
dontCheck=true;
2023-04-20 10:27:14 +00:00
buildPhase = ''
2023-05-04 09:00:37 +00:00
go build bin/ci.go
go build -tags containers_image_docker_daemon_stub,containers_image_storage_stub,containers_image_openpgp bin/alba.go
2023-04-20 10:27:14 +00:00
'';
installPhase = ''
2023-05-04 09:00:37 +00:00
mkdir -p $out
cp alba ci $out/
2023-04-20 10:27:14 +00:00
'';
2023-03-16 11:24:23 +00:00
meta = with pkgs.lib; {
2023-05-04 09:00:37 +00:00
description = "albatros is a collection of tools to build your software supply chain";
homepage = "https://git.deuxfleurs.fr/Deuxfleurs/albatros";
2023-03-16 11:24:23 +00:00
license = licenses.agpl3;
platforms = platforms.linux;
};
2023-05-04 09:00:37 +00:00
}).overrideAttrs (old: old // (builtins.getAttr targetHost archmap));
# get only a statically compiled ci
ci = pkgs.stdenv.mkDerivation {
pname = "albatros-ci";
version = albaVersion;
dontUnpack = true;
dontBuild = true;
installPhase = ''
cp ${albatrosProject}/ci $out
'';
};
# get only a statically compiled alba tool
alba = pkgs.stdenv.mkDerivation {
pname = "albatros-alba";
version = albaVersion;
dontUnpack = true;
dontBuild = true;
installPhase = ''
cp ${albatrosProject}/alba $out
'';
};
2023-04-11 08:45:14 +00:00
# logic to build docker containers
2023-05-04 09:00:37 +00:00
container = pkgs.dockerTools.buildImage {
name = "dxflrs/albatros-ci";
architecture = (builtins.getAttr targetHost archmap).GOARCH;
2023-03-16 11:24:23 +00:00
config = {
2023-05-04 09:00:37 +00:00
Cmd = [ "${ci}" ];
2023-03-16 11:24:23 +00:00
};
};
2023-04-06 16:20:30 +00:00
2023-05-04 09:00:37 +00:00
# Exposed content
in {
packages = {
inherit ci alba container;
default = ci;
2023-03-16 11:24:23 +00:00
};
2023-05-04 09:00:37 +00:00
});
2023-03-16 11:24:23 +00:00
}