# 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 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 nixpkgsUpstream { inherit system; overlays = [ self.overlay ]; } else import nixpkgs { inherit localSystem crossSystem; 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 = nixpkgsUpstream.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 = forAllCrossSystems ({ system, localSystem, crossSystem }: import ./apps { self = self.apps.${system}; nixpkgs = self.legacyPackages.${system}; nixpkgsLocal = nixpkgsFor.${localSystem}; packages = self.packages.${system}; }); 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}; }); }; }