2
0
Fork 0
genodepkgs/flake.nix

96 lines
2.8 KiB
Nix

{
edition = 201909;
description = "Genode packages";
inputs = {
dhall-haskell.uri =
"git+https://github.com/dhall-lang/dhall-haskell?ref=flake";
genode-depot.uri = "git+https://gitea.c3d2.de/ehmry/genode-depot.git";
genode.uri = "git+https://gitea.c3d2.de/ehmry/genode.git";
nixpkgs.uri = "github:ehmry/nixpkgs";
};
outputs = { self, dhall-haskell, genode-depot, genode, nixpkgs }:
let
mkOutput = { system, localSystem, crossSystem }:
let thisSystem = builtins.getAttr system;
in rec {
packages = import ./packages.nix {
inherit system nixpkgs;
depot = thisSystem genode-depot.packages;
genode = thisSystem genode.packages;
} // thisSystem genode.packages;
legacyPackages = thisSystem nixpkgs.legacyPackages;
# pass thru Nixpkgs
defaultPackage = packages.base-linux;
devShell = packages.stdenv;
lib = (nixpkgs.lib) // (import ./lib {
inherit system localSystem crossSystem;
inherit nixpkgs dhall-haskell genode-depot;
genodepkgs = self;
});
nixosModule = ./nixos;
checks = (import ./tests {
inherit system localSystem crossSystem;
inherit self nixpkgs dhall-haskell genode-depot;
lib = thisSystem self.lib;
genodepkgs = thisSystem self.packages;
}) // {
nixos = import ./nixos/test.nix {
system = localSystem;
depot = genode-depot;
genodepkgs = self;
inherit nixpkgs;
};
};
};
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;
}