# 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 = 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"; }; 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; }