diff --git a/flake.nix b/flake.nix index be80cef..0eb8860 100644 --- a/flake.nix +++ b/flake.nix @@ -13,77 +13,12 @@ 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" ]; + forAllLocalSystems = f: + nixpkgs.lib.genAttrs localSystems (system: f system); + forAllCrossSystems = f: with builtins; let @@ -97,26 +32,102 @@ attrSet = listToAttrs list; in attrSet; - finalize = outputs: - with builtins; + 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 - outputs' = outputs // { - x86_64-linux = getAttr "x86_64-linux-x86_64-genode" outputs; + 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"; }; - systems = attrNames outputs'; - outputAttrs = attrNames (head (attrValues outputs')); + in pkgs.stdenv.mkDerivation { + name = "genode-fhs-shell"; + nativeBuildInputs = [ fhs ]; + shellHook = "exec genode-env"; + }); - list = map (attr: { - name = attr; - value = listToAttrs (map (system: { - name = system; - value = getAttr attr (getAttr system outputs'); - }) systems); - }) outputAttrs; + apps = forAllCrossSystems ({ system, localSystem, crossSystem }: + import ./apps { + self = self.apps.${system}; + nixpkgs = self.legacyPackages.${system}; + nixpkgsLocal = nixpkgsFor.${localSystem}; + packages = self.packages.${system}; + }); - in listToAttrs list; - - final = finalize (forAllCrossSystems mkOutput); - - in final; + 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}; + }); + }; } diff --git a/lib/default.nix b/lib/default.nix index 9fc69a3..725a58e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -22,7 +22,7 @@ in { ''; mergeManifests = inputs: - nixpkgs.legacyPackages.${localSystem}.writeTextFile { + nixpkgs.writeTextFile { name = "manifest.dhall"; text = with builtins; let diff --git a/overlay/default.nix b/overlay/default.nix new file mode 100644 index 0000000..633b687 --- /dev/null +++ b/overlay/default.nix @@ -0,0 +1,3 @@ +final: prev: { + +} diff --git a/packages/default.nix b/packages/default.nix index 1327e4e..6a3444a 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -33,9 +33,11 @@ let "echo REPOSITORIES += ${genodeWorld} >> build/etc/build.conf"; }); + genodeTupRules = ./Tuprules.tup; + in rec { inherit (legacyPackages) stdenv; - inherit (genodeLabs) genodeSources; + inherit (genodeLabs) genodeSources; # toolchain; base-hw-pc = buildUpstream { name = "base-hw-pc"; @@ -111,5 +113,4 @@ in rec { sotest-producer = callPackage' ./sotest-producer { }; stdcxx = callPackage' ./stdcxx { }; - } diff --git a/tests/driver-hw.nix b/tests/driver-hw.nix index dd298e7..182093d 100644 --- a/tests/driver-hw.nix +++ b/tests/driver-hw.nix @@ -46,7 +46,6 @@ let testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})"; testEnv' = { DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall"; - MANIFEST = manifest; XDG_CACHE_HOME = "/tmp"; } // testEnv; diff --git a/tests/driver-linux.nix b/tests/driver-linux.nix index 36228e1..6d7e4b3 100644 --- a/tests/driver-linux.nix +++ b/tests/driver-linux.nix @@ -43,7 +43,6 @@ let testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})"; env' = { DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall"; - MANIFEST = manifest; XDG_CACHE_HOME = "/tmp"; } // env; diff --git a/tests/driver-nova.nix b/tests/driver-nova.nix index 0aa3b9f..9662bd8 100644 --- a/tests/driver-nova.nix +++ b/tests/driver-nova.nix @@ -46,7 +46,6 @@ let testConfig' = "${./test-wrapper.dhall} ${testConfig} (toMap ${manifest})"; testEnv' = { DHALL_GENODE = "${testPkgs.dhallGenode}/source.dhall"; - MANIFEST = manifest; XDG_CACHE_HOME = "/tmp"; } // testEnv;