2
0
Fork 0
genodepkgs/flake.nix

123 lines
3.6 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 = {
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";
nixpkgsUpstream.uri = "github:NixOS/nixpkgs";
2019-10-28 20:19:52 +01:00
};
outputs = { self, genode-depot, nixpkgs, nixpkgsUpstream }:
2019-11-05 17:38:47 +01:00
let
mkOutput = { system, localSystem, crossSystem }:
2020-02-05 12:03:09 +01:00
let thisSystem = builtins.getAttr system;
in rec {
2020-01-17 19:27:04 +01:00
lib = (nixpkgs.lib) // (import ./lib {
inherit system localSystem crossSystem;
inherit apps nixpkgs genode-depot;
2020-01-17 19:27:04 +01:00
genodepkgs = self;
});
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 {
inherit system legacyPackages apps;
localPackages = nixpkgsUpstream.legacyPackages.${localSystem};
depot = thisSystem genode-depot.packages;
};
devShell = let
pkgs = nixpkgsUpstream.legacyPackages.x86_64-linux;
fhs = pkgs.buildFHSUserEnv {
name = "genode-env";
targetPkgs = pkgs:
(with pkgs; [
binutils
bison
expect
flex
git
glibc.dev
gnumake
libxml2
qemu
tcl
which
xorriso
]);
runScript = "bash";
extraBuildCommands = let
toolchain = pkgs.fetchzip {
url = "file:///" + packages.genodeSources.toolchain.src;
hash = "sha256-26rPvLUPEJm40zLSqTquwuFTJ1idTB0T4VXgaHRN+4o=";
};
in "ln -s ${toolchain}/local usr/local";
};
in pkgs.stdenv.mkDerivation {
name = "genode-fhs-shell";
nativeBuildInputs = [ fhs ];
shellHook = "exec genode-env";
2020-01-17 19:27:04 +01:00
};
apps = import ./apps {
self = self.apps.${localSystem};
nixpkgs = legacyPackages;
nixpkgsLocal = nixpkgsUpstream.legacyPackages.${localSystem};
inherit packages;
};
checks = import ./tests {
inherit system localSystem crossSystem;
2020-01-17 19:27:04 +01:00
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;
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
}