2
0
Fork 0
genodepkgs/flake.nix

147 lines
4.4 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 = {
type = "github";
owner = "ehmry";
repo = "nixpkgs";
ref = "tier7";
};
};
outputs = { self, genode-depot, nixpkgs }:
let
localSystems = [ "x86_64-linux" ];
crossSystems = [ "x86_64-genode" ];
forAllLocalSystems = f:
nixpkgs.lib.genAttrs localSystems (system: f system);
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;
forAllSystems = f:
(forAllCrossSystems f) // (forAllLocalSystems (system:
f {
inherit system;
localSystem = system;
crossSystem = system;
}));
nixpkgsFor = forAllSystems ({ system, localSystem, crossSystem }:
if localSystem == crossSystem then
import nixpkgs {
inherit system;
overlays = [ self.overlay ];
}
else
import nixpkgs {
inherit localSystem;
crossSystem = {
system = crossSystem;
useLLVM = true;
};
config.allowUnsupportedSystem = true;
overlays = [ self.overlay ];
});
in rec {
overlay = import ./overlay;
lib = forAllCrossSystems ({ system, localSystem, crossSystem }:
(nixpkgs.lib) // (import ./lib {
inherit system localSystem crossSystem;
apps = self.apps.${system};
nixpkgs = nixpkgsFor.${system};
genode-depot = genode-depot.packages.${system};
genodepkgs = self;
}));
legacyPackages = forAllSystems
({ system, localSystem, crossSystem }: nixpkgsFor.${system});
# pass thru Nixpkgs
packages = forAllCrossSystems ({ system, localSystem, crossSystem }:
import ./packages {
inherit system;
legacyPackages = self.legacyPackages.${system};
apps = self.apps.${system};
localPackages = nixpkgs.legacyPackages.${localSystem};
depot = genode-depot.packages.${system};
});
devShell = forAllLocalSystems (system:
let
pkgs = nixpkgsFor.${system};
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.x86_64-linux-x86_64-genode.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";
});
apps = let
apps' = forAllCrossSystems ({ system, localSystem, crossSystem }:
import ./apps {
self = self.apps.${system};
nixpkgs = self.legacyPackages.${system};
nixpkgsLocal = nixpkgsFor.${localSystem};
packages = self.packages.${system};
});
in apps' // { x86_64-linux = apps'.x86_64-linux-x86_64-genode; };
checks = let
checks' = forAllCrossSystems ({ system, localSystem, crossSystem }:
import ./tests {
inherit system localSystem crossSystem;
inherit self nixpkgs genode-depot;
apps = self.apps.${system};
lib = self.lib.${system};
genodepkgs = self.packages.${system};
});
in checks' // { x86_64-linux = checks'.x86_64-linux-x86_64-genode; };
};
}