2
0
Fork 0
genodepkgs/flake.nix

97 lines
2.7 KiB
Nix

# SPDX-License-Identifier: CC0-1.0
{
edition = 201909;
description = "Genode packages";
inputs = {
genode-depot.uri = "git+https://git.sr.ht/~ehmry/genode-depot";
nixpkgs.uri = "github:ehmry/nixpkgs";
nixpkgsUpstream.uri = "github:NixOS/nixpkgs";
};
outputs = { self, genode-depot, nixpkgs, nixpkgsUpstream }:
let
mkOutput = { system, localSystem, crossSystem }:
let thisSystem = builtins.getAttr system;
in rec {
lib = (nixpkgs.lib) // (import ./lib {
inherit system localSystem crossSystem;
inherit apps nixpkgs genode-depot;
genodepkgs = self;
});
legacyPackages = thisSystem nixpkgs.legacyPackages;
# pass thru Nixpkgs
packages = import ./packages {
inherit system legacyPackages apps;
localPackages = nixpkgsUpstream.legacyPackages.${localSystem};
depot = thisSystem genode-depot.packages;
};
devShell = legacyPackages.mkShell {
nativeBuildInputs = [
nixpkgs.legacyPackages.${localSystem}.dhall
packages.dhallGenode
];
};
apps = import ./apps {
self = self.apps.${localSystem};
nixpkgs = legacyPackages;
nixpkgsLocal = nixpkgsUpstream.legacyPackages.${localSystem};
inherit packages;
};
checks = import ./tests {
inherit system localSystem crossSystem;
inherit self nixpkgs genode-depot;
inherit apps lib;
genodepkgs = thisSystem self.packages;
};
};
localSystems = [ "x86_64-linux" ];
crossSystems = [ "x86_64-genode" ];
forAllCrossSystems = f:
with builtins;
let
f' = localSystem: crossSystem:
let system = localSystem + "-" + crossSystem;
in {
name = system;
value = f { inherit system localSystem crossSystem; };
};
list = nixpkgs.lib.lists.crossLists f' [ localSystems crossSystems ];
attrSet = listToAttrs list;
in attrSet;
finalize = outputs:
with builtins;
let
outputs' = outputs // {
x86_64-linux = getAttr "x86_64-linux-x86_64-genode" outputs;
};
systems = attrNames outputs';
outputAttrs = attrNames (head (attrValues outputs'));
list = map (attr: {
name = attr;
value = listToAttrs (map (system: {
name = system;
value = getAttr attr (getAttr system outputs');
}) systems);
}) outputAttrs;
in listToAttrs list;
final = finalize (forAllCrossSystems mkOutput);
in final;
}