From 7634f2fc08d9779b6a1ed53040e3079d0e6f6630 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 20 Dec 2019 07:38:34 +0000 Subject: [PATCH] Expose x86_64-linux-x86_64-genode as x86_64-linux These packages will execute with the Linux kernel, so pass them thru as a convience. --- flake.nix | 105 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 39 deletions(-) diff --git a/flake.nix b/flake.nix index e137e9f..6a2b3c4 100644 --- a/flake.nix +++ b/flake.nix @@ -13,56 +13,83 @@ outputs = { self, dhall-haskell, genode-depot, genode, nixpkgs }: let - systems = [ "x86_64-genode" ]; + mkOutput = { system, localSystem, crossSystem }: + let thisSystem = builtins.getAttr system; + in rec { - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); - - in { - - lib = nixpkgs.lib.forAllCrossSystems - ({ system, localSystem, crossSystem }: - nixpkgs.lib // (import ./lib { - inherit system localSystem crossSystem nixpkgs dhall-haskell - genode-depot; - genodepkgs = self; - })); - - packages = nixpkgs.lib.forAllCrossSystems - ({ system, localSystem, crossSystem }: - let thisSystem = builtins.getAttr system; - in import ./packages.nix { + packages = import ./packages.nix { inherit system nixpkgs; depot = thisSystem genode-depot.packages; genode = thisSystem genode.packages; - } // thisSystem genode.packages) // - { x86_64-linux = self.packages.x86_64-linux-x86_64-genode; }; + } // thisSystem genode.packages; - defaultPackage.x86_64-linux = - self.packages.x86_64-linux-x86_64-genode.base-linux; + legacyPackages = thisSystem nixpkgs.legacyPackages; + # pass thru Nixpkgs - checks = nixpkgs.lib.forAllCrossSystems - ({ system, localSystem, crossSystem }: - let thisSystem = builtins.getAttr system; - in import ./tests { - inherit self system localSystem crossSystem nixpkgs dhall-haskell - genode-depot; - genodepkgs = thisSystem self.packages; + defaultPackage = packages.base-linux; + + devShell = packages.stdenv; + + lib = (nixpkgs.lib) // (import ./lib { + inherit system localSystem crossSystem; + inherit nixpkgs dhall-haskell genode-depot; + genodepkgs = self; + }); + + nixosModule = ./nixos; + + checks = (import ./tests { + inherit system localSystem crossSystem; + inherit self nixpkgs dhall-haskell genode-depot; lib = thisSystem self.lib; + genodepkgs = thisSystem self.packages; }) // { - x86_64-linux.nixos = - let pkgs' = nixpkgs.legacyPackages.x86_64-linux // { }; - in import ./nixos/test.nix { - system = "x86_64-linux"; - depot = genode-depot; - genodepkgs = self; - inherit nixpkgs; - }; + nixos = import ./nixos/test.nix { + system = localSystem; + depot = genode-depot; + genodepkgs = self; + inherit nixpkgs; + }; }; - nixosModule = import ./nixos; + }; - devShell.x86_64-linux = self.packages.x86_64-linux-x86_64-genode.stdenv; + 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; }