2
0
Fork 0
genodepkgs/flake.nix

114 lines
3.5 KiB
Nix
Raw Normal View History

2020-01-17 01:24:34 +01:00
# SPDX-License-Identifier: CC0-1.0
2019-10-28 20:19:52 +01:00
{
edition = 201909;
2019-11-05 17:38:47 +01:00
description = "Genode packages";
2019-10-28 20:19:52 +01:00
inputs = {
2019-11-05 16:00:56 +01:00
dhall-haskell.uri =
"git+https://github.com/dhall-lang/dhall-haskell?ref=flake";
2020-02-04 15:56:16 +01:00
genode-depot.uri = "git+https://git.sr.ht/~ehmry/genode-depot";
2020-01-14 12:16:02 +01:00
nixpkgs.uri = "github:ehmry/nixpkgs";
2019-10-28 20:19:52 +01:00
};
outputs = { self, dhall-haskell, genode-depot, nixpkgs }:
2019-11-05 17:38:47 +01:00
let
mkOutput = { system, localSystem, crossSystem }:
2020-01-17 19:27:04 +01:00
let
thisSystem = builtins.getAttr system;
lib = (nixpkgs.lib) // (import ./lib {
inherit system localSystem crossSystem;
inherit nixpkgs dhall-haskell genode-depot;
genodepkgs = self;
});
in rec {
2019-10-28 20:19:52 +01:00
2020-01-17 19:27:04 +01:00
legacyPackages = thisSystem nixpkgs.legacyPackages;
# pass thru Nixpkgs
2020-01-16 17:19:42 +01:00
packages = import ./packages {
2020-01-17 19:27:04 +01:00
inherit system legacyPackages;
depot = thisSystem genode-depot.packages;
apps = self.apps.${localSystem};
};
defaultPackage = packages.genode.base-linux;
2019-10-28 20:19:52 +01:00
2020-01-17 19:27:04 +01:00
devShell = legacyPackages.mkShell {
nativeBuildInputs = [ dhall-haskell.packages.${localSystem}.dhall ];
shellHook = ''
export DHALL_PRELUDE="${packages.dhallPrelude}/package.dhall"
export DHALL_GENODE="${packages.dhallGenode}/package.dhall"
export BASE_MANIFEST="${packages.genode.base.manifest}"
export BASE_LINUX_MANIFEST="${packages.genode.base-linux.manifest}"
export BASE_NOVA_MANIFEST="${packages.genode.base-nova.manifest}"
export OS_MANIFEST="${packages.genode.os.manifest}"
'';
};
apps = import ./apps {
nixpkgs = legacyPackages;
dhallApps = dhall-haskell.apps.${localSystem};
inherit packages;
};
nixosModule = ./nixos;
checks = (import ./tests {
inherit system localSystem crossSystem;
2020-01-17 19:27:04 +01:00
apps = dhall-haskell.apps.${localSystem} // apps;
inherit self nixpkgs genode-depot;
inherit lib;
genodepkgs = thisSystem self.packages;
2019-12-02 16:39:52 +01:00
}) // {
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;
2019-12-02 16:39:52 +01:00
};
systems = attrNames outputs';
outputAttrs = attrNames (head (attrValues outputs'));
2019-12-14 11:58:56 +01:00
list = map (attr: {
name = attr;
value = listToAttrs (map (system: {
name = system;
value = getAttr attr (getAttr system outputs');
}) systems);
}) outputAttrs;
2019-12-14 11:58:56 +01:00
in listToAttrs list;
2019-12-14 11:58:56 +01:00
final = finalize (forAllCrossSystems mkOutput);
in final;
2019-10-28 20:19:52 +01:00
}