# SPDX-License-Identifier: CC0-1.0 { edition = 201909; description = "Genode packages"; inputs = { dhall-haskell.uri = "git+https://github.com/dhall-lang/dhall-haskell?ref=flake"; genode-depot.uri = "git+https://git.sr.ht/~ehmry/genode-depot"; nixpkgs.uri = "github:ehmry/nixpkgs"; }; outputs = { self, dhall-haskell, genode-depot, nixpkgs }: let mkOutput = { system, localSystem, crossSystem }: let thisSystem = builtins.getAttr system; in rec { lib = (nixpkgs.lib) // (import ./lib { inherit system localSystem crossSystem; inherit nixpkgs dhall-haskell genode-depot; genodepkgs = self; }); legacyPackages = thisSystem nixpkgs.legacyPackages; # pass thru Nixpkgs packages = import ./packages { inherit system legacyPackages; depot = thisSystem genode-depot.packages; apps = self.apps.${localSystem}; }; defaultPackage = packages.genode.base-linux; 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; apps = dhall-haskell.apps.${localSystem} // apps; inherit self nixpkgs genode-depot; inherit lib; genodepkgs = thisSystem self.packages; }) // { 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; }; 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; }