ofborg/release.nix

84 lines
1.9 KiB
Nix
Raw Normal View History

2017-11-30 13:05:26 +00:00
{ nixpkgs ? ./nix
2021-11-11 21:33:14 +00:00
, supportedSystems ? [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]
2017-11-30 13:05:26 +00:00
}:
let
2020-05-20 03:07:27 +00:00
pkgs = import nixpkgs {
overlays = [ (import ./nix/overlay.nix) ];
};
2017-11-30 13:05:26 +00:00
inherit (pkgs) lib;
2017-12-09 01:59:04 +00:00
# An attrset of borgpkgs per supportedSystem:
#
# {
# "x86_64-linux" = ...
# "x86_64-darwin" = ...
# }
borgpkgs-per-arch = builtins.foldl'
(collector: system:
collector // {
"${system}" = import ./. {
pkgs = import nixpkgs {
inherit system;
overlays = [
(import ./nix/overlay.nix)
];
};
2017-12-09 01:59:04 +00:00
};
}
)
2021-11-11 21:33:14 +00:00
{ }
supportedSystems;
2017-12-09 01:59:04 +00:00
attrForSystem = system: attrpath:
if borgpkgs-per-arch ? "${system}"
2021-11-11 21:33:14 +00:00
then
(
let
borgpkgs = borgpkgs-per-arch."${system}";
in
if lib.hasAttrByPath attrpath borgpkgs
then
lib.setAttrByPath
(attrpath ++ [ system ])
(lib.attrByPath attrpath "bogus" borgpkgs)
2017-12-09 01:59:04 +00:00
else throw "Failed to find ${toString attrpath} for ${system} in borgpkgs"
2021-11-11 21:33:14 +00:00
)
2017-12-09 01:59:04 +00:00
else throw "No such system ${system}";
attrsForAllSystems = path:
builtins.foldl'
(collector: system:
lib.recursiveUpdate collector (attrForSystem system path)
)
2021-11-11 21:33:14 +00:00
{ }
2017-12-09 01:59:04 +00:00
supportedSystems;
merge = attrsets:
builtins.foldl'
(collector: set: lib.recursiveUpdate set collector)
2021-11-11 21:33:14 +00:00
{ }
2017-12-09 01:59:04 +00:00
attrsets;
x8664LinuxOnly = path:
2021-11-11 21:33:14 +00:00
(attrForSystem "x86_64-linux" path);
2017-12-09 01:59:04 +00:00
2017-12-09 02:10:28 +00:00
jobs = merge [
(attrsForAllSystems [ "ofborg" "rs" ])
2017-12-09 01:59:04 +00:00
2017-12-09 02:10:28 +00:00
(x8664LinuxOnly [ "ofborg" "php" ])
];
2021-11-11 21:33:14 +00:00
in
jobs // {
2017-12-09 02:10:28 +00:00
release = pkgs.releaseTools.aggregate {
name = "release";
meta.description = "Release-critical builds for OfBorg infrastructure";
constituents = [
jobs.ofborg.rs.x86_64-linux
jobs.ofborg.rs.x86_64-darwin
2021-11-11 21:33:14 +00:00
jobs.ofborg.rs.aarch64-darwin
jobs.ofborg.rs.aarch64-linux
2017-12-09 02:10:28 +00:00
jobs.ofborg.php.x86_64-linux
];
};
}