2020-04-22 15:12:09 +00:00
|
|
|
let
|
2020-04-11 14:45:25 +00:00
|
|
|
# copied from <nixpkgs/lib>
|
|
|
|
genAttrs = names: f:
|
|
|
|
builtins.listToAttrs (map (n: { name = n; value = f n; }) names);
|
|
|
|
|
2020-04-22 15:12:09 +00:00
|
|
|
mapAttrsToList = f: attrs:
|
|
|
|
map (name: f name attrs.${name}) (builtins.attrNames attrs);
|
|
|
|
|
2020-04-11 14:45:25 +00:00
|
|
|
# The list of systems supported by nixpkgs and hydra
|
2020-04-22 15:12:09 +00:00
|
|
|
defaultSystems = [
|
2020-04-11 14:45:25 +00:00
|
|
|
"aarch64-linux"
|
|
|
|
"i686-linux"
|
|
|
|
"x86_64-darwin"
|
|
|
|
"x86_64-linux"
|
|
|
|
];
|
|
|
|
|
2020-04-22 15:12:09 +00:00
|
|
|
# eachSystem using defaultSystems
|
|
|
|
eachDefaultSystem = eachSystem defaultSystems;
|
|
|
|
|
|
|
|
# Builds a map from <attr>=value to <system>.<attr>=value for each system.
|
2020-04-11 14:45:25 +00:00
|
|
|
#
|
|
|
|
#
|
2020-04-22 15:12:09 +00:00
|
|
|
eachSystem = systems: f:
|
|
|
|
let
|
|
|
|
op = attrs: system:
|
|
|
|
let
|
|
|
|
ret = f system;
|
2020-04-22 15:17:40 +00:00
|
|
|
op = attrs: key:
|
2020-04-22 15:12:09 +00:00
|
|
|
attrs //
|
|
|
|
{
|
2020-05-02 20:51:26 +00:00
|
|
|
${key} = (attrs.${key} or { }) // { ${system} = ret.${key}; };
|
2020-04-22 15:12:09 +00:00
|
|
|
}
|
2020-05-02 20:51:26 +00:00
|
|
|
;
|
2020-04-22 15:12:09 +00:00
|
|
|
in
|
|
|
|
builtins.foldl' op attrs (builtins.attrNames ret);
|
|
|
|
in
|
2020-05-02 20:51:26 +00:00
|
|
|
builtins.foldl' op { } systems
|
|
|
|
;
|
2020-04-11 17:29:17 +00:00
|
|
|
|
|
|
|
# Returns the structure used by `nix app`
|
|
|
|
mkApp =
|
|
|
|
{ drv
|
|
|
|
, name ? drv.pname or drv.name
|
|
|
|
, exePath ? drv.passthru.exePath or "/bin/${name}"
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
type = "app";
|
|
|
|
program = "${drv}${exePath}";
|
|
|
|
};
|
2020-04-22 15:12:09 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
inherit
|
|
|
|
defaultSystems
|
|
|
|
eachDefaultSystem
|
|
|
|
eachSystem
|
|
|
|
mkApp
|
|
|
|
;
|
2020-04-11 14:45:25 +00:00
|
|
|
}
|