~ehmry/sigil

a61c3532e832a6e27ada1b1f35cd8744b088b293 — Emery Hemingway 4 years ago ee580c3 20.02 20.02
Build more packages using upstream build system

- Implement support for "ports"
- Update Nixpkgs to use Genode 20.02
- Remove packaging of forked Genode
M apps/linux-image/default.nix => apps/linux-image/default.nix +2 -2
@@ 7,8 7,8 @@ nixpkgs.writeScriptBin "linux-image" (with nixpkgs.buildPackages; ''
  set -eu
  export DHALL_PRELUDE=''${DHALL_PRELUDE:-${packages.dhallPrelude}/package.dhall}
  export DHALL_GENODE=''${DHALL_GENODE:-${packages.dhallGenode}/package.dhall}
  export BASE_LINUX_MANIFEST=''${BASE_LINUX_MANIFEST:-${packages.genode.base-linux.manifest}}
  export OS_MANIFEST=''${OS_MANIFEST:-${packages.genode.os.manifest}}
  export BASE_LINUX_MANIFEST=''${BASE_LINUX_MANIFEST:-${packages.base-linux.manifest}}
  export OS_MANIFEST=''${OS_MANIFEST:-${packages.os.manifest}}
  ${dhallApps.dhall.program} text <<< "${./script.dhall} ($@)" > boot.sh
  source boot.sh
  rm boot.sh

M flake.lock => flake.lock +103 -37
@@ 1,43 1,109 @@
{
    "inputs": {
        "dhall-haskell": {
            "inputs": {
                "nixpkgs": {
                    "inputs": {},
                    "narHash": "sha256-wJg4DA700SoQbEz61448sR6BgxRa1R92K3vvCV1g+HY=",
                    "originalUrl": "git+https://github.com/nixos/nixpkgs.git?ref=18.09-beta&rev=1d4de0d552ae9aa66a5b8dee5fb0650a4372d148",
                    "url": "git+https://github.com/nixos/nixpkgs.git?ref=18.09-beta&rev=1d4de0d552ae9aa66a5b8dee5fb0650a4372d148"
                },
                "nixpkgsStaticLinux": {
                    "inputs": {},
                    "narHash": "sha256-famU3pJZ4vkElV9qc71HmyRVSvcrAhfMZ0UJKpmmKP8=",
                    "originalUrl": "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working",
                    "url": "git+https://github.com/nh2/nixpkgs.git?ref=static-haskell-nix-stack-dhall-working&rev=925aac04f4ca58aceb83beef18cb7dae0715421b"
                }
            },
            "narHash": "sha256-KJl9ZLcMcEsLSPcwcWoc0Ac74/6HKC9LkVMeLwhyhlg=",
            "originalUrl": "git+https://github.com/dhall-lang/dhall-haskell?ref=flake",
            "url": "git+https://github.com/dhall-lang/dhall-haskell?ref=flake&rev=aea28adf3d10ff1982aa4ddd176d1476251b932f"
        },
        "genode-depot": {
            "inputs": {
                "nixpkgs": {
                    "inputs": {},
                    "narHash": "sha256-OnpEWzNxF/AU4KlqBXM2s5PWvfI5/BS6xQrPvkF5tO8=",
                    "originalUrl": "nixpkgs",
                    "url": "github:edolstra/nixpkgs/7f8d4b088e2df7fdb6b513bc2d6941f1d422a013"
                }
            },
            "narHash": "sha256-7eL2MfGgeEaIwJXPc4LQ7pBa4JeGicm9th7onjKgzsE=",
            "originalUrl": "git+https://git.sr.ht/~ehmry/genode-depot",
            "url": "git+https://git.sr.ht/~ehmry/genode-depot?ref=master&rev=8c2aafed45b4075e37f1cd93de0ebf93f38c83c3"
  "inputs": {
    "dhall-haskell": {
      "info": {
        "narHash": "sha256-KJl9ZLcMcEsLSPcwcWoc0Ac74/6HKC9LkVMeLwhyhlg="
      },
      "inputs": {
        "nixpkgs": {
          "info": {
            "narHash": "sha256-wJg4DA700SoQbEz61448sR6BgxRa1R92K3vvCV1g+HY="
          },
          "inputs": {},
          "locked": {
            "ref": "18.09-beta",
            "rev": "1d4de0d552ae9aa66a5b8dee5fb0650a4372d148",
            "type": "git",
            "url": "https://github.com/nixos/nixpkgs.git"
          },
          "original": {
            "ref": "18.09-beta",
            "rev": "1d4de0d552ae9aa66a5b8dee5fb0650a4372d148",
            "type": "git",
            "url": "https://github.com/nixos/nixpkgs.git"
          }
        },
        "nixpkgsStaticLinux": {
          "info": {
            "narHash": "sha256-famU3pJZ4vkElV9qc71HmyRVSvcrAhfMZ0UJKpmmKP8="
          },
          "inputs": {},
          "locked": {
            "ref": "static-haskell-nix-stack-dhall-working",
            "rev": "925aac04f4ca58aceb83beef18cb7dae0715421b",
            "type": "git",
            "url": "https://github.com/nh2/nixpkgs.git"
          },
          "original": {
            "ref": "static-haskell-nix-stack-dhall-working",
            "type": "git",
            "url": "https://github.com/nh2/nixpkgs.git"
          }
        }
      },
      "locked": {
        "ref": "flake",
        "rev": "aea28adf3d10ff1982aa4ddd176d1476251b932f",
        "type": "git",
        "url": "https://github.com/dhall-lang/dhall-haskell"
      },
      "original": {
        "ref": "flake",
        "type": "git",
        "url": "https://github.com/dhall-lang/dhall-haskell"
      }
    },
    "genode-depot": {
      "info": {
        "narHash": "sha256-7eL2MfGgeEaIwJXPc4LQ7pBa4JeGicm9th7onjKgzsE="
      },
      "inputs": {
        "nixpkgs": {
            "inputs": {},
            "narHash": "sha256-H97qzDLWl646rcgEPMA0oQDt817kGcpCiROdi1j2N0I=",
            "originalUrl": "github:ehmry/nixpkgs",
            "url": "github:ehmry/nixpkgs/c73578fb214872baf2261f52eccbcbfdf6d54f32"
          "info": {
            "narHash": "sha256-OnpEWzNxF/AU4KlqBXM2s5PWvfI5/BS6xQrPvkF5tO8="
          },
          "inputs": {},
          "locked": {
            "owner": "edolstra",
            "repo": "nixpkgs",
            "rev": "7f8d4b088e2df7fdb6b513bc2d6941f1d422a013",
            "type": "github"
          },
          "original": {
            "id": "nixpkgs",
            "type": "indirect"
          }
        }
      },
      "locked": {
        "ref": "master",
        "rev": "8c2aafed45b4075e37f1cd93de0ebf93f38c83c3",
        "type": "git",
        "url": "https://git.sr.ht/~ehmry/genode-depot"
      },
      "original": {
        "type": "git",
        "url": "https://git.sr.ht/~ehmry/genode-depot"
      }
    },
    "version": 3
    "nixpkgs": {
      "info": {
        "lastModified": 1583160598,
        "narHash": "sha256-jiBSr7JK/xy7pIXFVhjdxpWy0pudDDRDW5XjzmDXPjA="
      },
      "inputs": {},
      "locked": {
        "owner": "ehmry",
        "repo": "nixpkgs",
        "rev": "37cf068dcf79503fa6f399dcb44bc15c5d2f33f0",
        "type": "github"
      },
      "original": {
        "owner": "ehmry",
        "repo": "nixpkgs",
        "type": "github"
      }
    }
  },
  "version": 4
}

M flake.nix => flake.nix +9 -12
@@ 34,24 34,21 @@
            dhallApps = dhall-haskell.apps.${localSystem};
          };

          defaultPackage = packages.genode.base-linux;
          defaultPackage = with packages;
            lib.mergeManifests [
              base-hw-pc
              base-nova
              base-linux
              os
              sotest-producer
            ];

          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 MANIFEST="${
                with packages;
                lib.mergeManifests [
                  base-hw-pc
                  base-nova
                  genode.base
                  genode.base-linux
                  genode.os
                  sotest-producer
                ]
              }"
              export MANIFEST="${defaultPackage}"
            '';
          };


M packages/default.nix => packages/default.nix +87 -31
@@ 17,10 17,11 @@ let
  callPackage' = path: attrs:
    addManifest (legacyPackages.callPackages path attrs);

  buildUpstream = import ./genodelabs {
    nixpkgs = legacyPackages;
    inherit apps;
  };
  buildUpstream = let
    f = import ./genodelabs {
      nixpkgs = legacyPackages;
    };
  in args: addManifest (f args);

in rec {



@@ 28,35 29,102 @@ in rec {

  base-hw-pc = buildUpstream {
    name = "base-hw-pc";
    arch = "x86_64";
    kernel = "hw";
    board = "pc";
    targets = [ "bootstrap" "core" "timer" "lib/ld"  ];
    KERNEL = "hw";
    BOARD = "pc";
    targets = [ "bootstrap" "core" "timer" "lib/ld" ];
    postInstall = ''
      mkdir -p $out/lib
      mv $out/bin/*.o $out/lib/
      mv $out/bin/ld-hw.lib.so $out/lib/ld.lib.so
      mv $out/lib/ld-hw.lib.so $out/lib/ld.lib.so
    '';
  };

  base-linux = buildUpstream {
    name = "base-linux";
    KERNEL = "linux";
    targets = [ "core" "timer" "lib/ld" ];
    postInstall = ''
      mkdir -p $out/lib
      mv $out/lib/ld-linux.lib.so $out/lib/ld.lib.so
    '';
    HOST_INC_DIR = legacyPackages.buildPackages.glibc.dev + "/include";
  };

  base-nova = buildUpstream {
    name = "base-nova";
    arch = "x86_64";
    kernel = "nova";
    KERNEL = "nova";
    targets = [ "core" "timer" "lib/ld" ];
    postInstall = ''
      mkdir -p $out/lib
      mv $out/bin/*.o $out/lib/
      mv $out/bin/ld-nova.lib.so $out/lib/ld.lib.so
      mv $out/lib/ld-nova.lib.so $out/lib/ld.lib.so
    '';
  };

  driversPc = let
    directoryBlacklist = [
      "repos/dde_zircon"
    ];
  in buildUpstream {
    name = "drivers";
    BOARD = "pc";
    targets = [ "drivers" ];
    ports = [ "dde_bsd" "dde_ipxe" "dde_linux" "libc" "openssl" "x86emu" ];
    preBuild = "find ${toString directoryBlacklist} -name target.mk -delete";
  };

  noux = buildUpstream {
    name = "noux";
    targets = [ "noux" "lib/libc_noux" ];
    ports = [ "libc" ];
  };

  driver_manager = buildUpstream {
    name = "driver_manager";
    arch = "x86_64";
    targets = [ "app/driver_manager" ];
  os = let
    directoryBlacklist = [
      "repos/dde_bsd"
      "repos/dde_ipxe"
      "repos/dde_linux"
      "repos/dde_rump"
      "repos/gems/src/app/mixer_gui_qt"
      "repos/gems/src/server/http_block"
      "repos/gems/src/server/terminal_mux"
      "repos/libports"
      "repos/ports"
    ];
  in buildUpstream {
    name = "os";
    patches = [ ./genodelabs/capslock.patch ];
    targets = [ "app" "init" "lib/vfs" "server" ];
    ports = [ "jitterentropy" "libc" "libpng" "libssh" "openssl" "stb" "zlib" ];
    preBuild = "find ${toString directoryBlacklist} -name target.mk -delete";
    nativeBuildInputs = with legacyPackages.buildPackages; [ bison flex ];
  };

  vfs_lwip = buildUpstream {
    name = "lwip";
    targets = [ "lib/vfs/lwip" ];
    ports = [ "lwip" ];
  };

  vfs_rump = buildUpstream {
    name = "vfs_rump";
    targets = [ "lib/vfs/rump" ];
    ports = [ "dde_rump" ];
    buildInputs = [ legacyPackages.buildPackages.zlib ];
  };

  vfs_ttf = buildUpstream {
    name = "vfs_ttf";
    targets = [ "lib/vfs/ttf" ];
    ports = [ "libc" "stb" ];
  };

  virtualbox5 = buildUpstream {
    name = "virtualbox5";
    targets = [ "virtualbox5" ];
    ports = [ "libc" "libiconv" "qemu-usb" "stdcxx" "virtualbox5" ];
    nativeBuildInputs = with legacyPackages.buildPackages; [ iasl yasm ];
    KERNEL = "nova";
  };

  genodeTests = let


@@ 64,8 132,6 @@ in rec {
      "repos/base-*"
      "repos/base/src/test/sanitizer"
      "repos/base/src/test/xml_generator"
      "repos/dde_bsd"
      "repos/dde_linux"
      "repos/gems/src/test/aes_cbc_4k"
      "repos/gems/src/test/decorator_stress"
      "repos/gems/src/test/text_painter"


@@ 76,9 142,9 @@ in rec {
    ];
  in buildUpstream {
    name = "genode-tests";
    arch = "x86_64";
    preBuild = "find ${toString directoryBlacklist} -name target.mk -delete";
    targets = [ "test" ];
    ports = [ "libc" ];
  };

  bender = legacyPackages.buildPackages.callPackage ./bender { };


@@ 87,24 153,14 @@ in rec {

  dhallPrelude = dhallPackages.prelude;

  genode = import ./genode {
    nixpkgs = legacyPackages;
    inherit mkDhallManifest;
  };

  NOVA = legacyPackages.callPackage ./NOVA { };

  libc = callPackage' ./libc { inherit depot; };

  nic_bus = callPackage ./nic_bus { inherit (genode) base os; };

  solo5 = let drv = callPackage' ./solo5 { inherit genode; };
  solo5 = let drv = callPackage' ./solo5 { };
  in drv // { tests = addManifest drv.tests // { pname = "solo5-tests"; }; };

  sotest-producer = callPackage' ./sotest-producer {
    stdenv = genode.stdenvGcc;
    inherit genode;
  };
  sotest-producer = callPackage' ./sotest-producer { };

  stdcxx = callPackage' ./stdcxx { };


D packages/genode/default.nix => packages/genode/default.nix +0 -274
@@ 1,274 0,0 @@
# SPDX-License-Identifier: CC0-1.0

{ nixpkgs, mkDhallManifest }:

let

  src = nixpkgs.fetchgit {
    url = "https://git.sr.ht/~ehmry/genode";
    rev = "11ff9a1dc524dadd3252777d9be529910e375e66";
    sha256 = "1238ashnx40fmc715w1mqiachdw7bkd04zy6d6l1hmn7f0ld535n";
  };

  inherit (nixpkgs) buildPackages llvmPackages;

  sourceForgeToolchain = nixpkgs.buildPackages.callPackage ./toolchain.nix { };

  stdenvLlvm = let inherit (nixpkgs) stdenv;
  in assert stdenv.cc.isClang; stdenv;

  stdenvGcc = let
    env = nixpkgs.stdenvAdapters.overrideCC nixpkgs.stdenv sourceForgeToolchain;
  in assert env.cc.isGNU; env;

  inherit (stdenvLlvm) lib targetPlatform;
  specs = with targetPlatform;
    [ ]

    ++ lib.optional is32bit "32bit"

    ++ lib.optional is64bit "64bit"

    ++ lib.optional isAarch32 "arm"

    ++ lib.optional isAarch64 "arm_64"

    ++ lib.optional isRiscV "riscv"

    ++ lib.optional isx86 "x86"

    ++ lib.optional isx86_32 "x86_32"

    ++ lib.optional isx86_64 "x86_64";

  toTupConfig = env: attrs:
    let
      tupArch = with env.targetPlatform;

        if isAarch32 then
          "arm"
        else

        if isAarch64 then
          "arm64"
        else

        if isx86_32 then
          "i386"
        else

        if isx86_64 then
          "x86_64"
        else

          abort "unhandled targetPlatform";

      attrs' = with env; { TUP_ARCH = tupArch; } // attrs;

    in with builtins;
    env.mkDerivation {
      name = "tup.config";
      nativeBuildInputs = with nixpkgs.buildPackages; [
        binutils
        pkgconfig
        which
      ];
      text = let
        op = config: name: ''
          ${config}CONFIG_${name}=${getAttr name attrs}
        '';
      in foldl' op "" (attrNames attrs);
      passAsFile = [ "text" ];
      preferLocalBuild = true;
      buildCommand = let
        subst = let
          vars = [ "AR" "NM" ];
          f = other: var:
            other + ''
              echo CONFIG_${var}=`which ''$${var}` >> $out
            '';
        in foldl' f "" vars;
        utils = let
          vars = [ "pkg-config" "objcopy" ];
          f = other: var:
            other + ''
              echo CONFIG_${var}=`which ${var}` >> $out
            '';
        in foldl' f "" vars;
      in ''
        cp $textPath $out
        ${subst}
        ${utils}
      '';
    };

  tupConfigGcc = let
    f = env:
      let prefix = bin: env.cc.targetPrefix + bin;
      in {
        CC = prefix "gcc";
        CXX = prefix "g++";
        LD = prefix "ld";
        OBJCOPY = prefix "objcopy";
        RANLIB = prefix "ranlib";
        READELF = prefix "readelf";
        STRIP = prefix "strip";
        PKGCONFIG = "${nixpkgs.buildPackages.pkgconfig}/bin/pkg-config";

        IS_GCC = "";
        LINUX_HEADERS = buildPackages.glibc.dev;
      };
  in toTupConfig stdenvGcc (f stdenvGcc);

  tupConfigLlvm = let
    f = env:
      let prefix = bin: "${env.cc}/bin/${env.cc.targetPrefix}${bin}";
      in {
        CC = prefix "cc";
        CXX = prefix "c++";
        LD = prefix "ld";
        OBJCOPY = "llvm-objcopy";
        OBJDUMP = "llvm-objdump";
        RANLIB = "llvm-ranlib";
        READELF = "llvm-readelf";
        STRIP = "llvm-strip";
        PKGCONFIG = "${nixpkgs.buildPackages.pkgconfig}/bin/pkg-config";

        IS_LLVM = "";
        LIBCXXABI = llvmPackages.libcxxabi;
        LIBCXX = llvmPackages.libcxx;
        LIBUNWIND_BAREMETAL =
          llvmPackages.libunwind.override { isBaremetal = true; };
        LIBUNWIND = llvmPackages.libunwind;
        LINUX_HEADERS = buildPackages.glibc.dev;
      };
  in toTupConfig stdenvLlvm (f stdenvLlvm);

  buildRepo = { env, repo, repoInputs }:
    env.mkDerivation {
      pname = repo;
      version = "19.11";
      inherit repo specs src;

      nativeBuildInputs = repoInputs;
      # This is wrong, why does pkg-config not collect buildInputs?

      propagatedNativeBuildInputs = repoInputs;

      depsBuildBuild = with buildPackages; [ llvm pkgconfig tup ];

      tupConfig = if env.cc.isGNU then
        tupConfigGcc
      else if env.cc.isClang then
        tupConfigLlvm
      else
        throw "no Tup config for this stdenv";

      configurePhase = ''
        # Configure Tup
        set -v
        install -m666 $tupConfig tup.config
        echo CONFIG_NIX_OUTPUTS_OUT=$out >> tup.config
        echo CONFIG_NIX_OUTPUTS_DEV=$out >> tup.config

        # Disable other repos
        for R in repos/*; do
          [ "$R" != "repos/$repo" ] && find $R -name Tupfile -delete
        done

        # Scan repository and generate script
        tup init
        tup generate buildPhase.sh

        # Redirect artifacts to Nix store
        mkdir -p $out/lib $out/include
        ln -s $out out
        ln -s $out dev
      '';

      buildPhase = ''
        test -d repos/$repo/src/ld && cp -rv repos/$repo/src/ld $out/
        pushd .
        set -v
        source buildPhase.sh
        set +v
        popd
      '';

      installPhase = ''
        # Populate the "dev" headers
        if [ -d "repos/$repo/include" ]; then
          for DIR in repos/$repo/include; do
            for SPEC in $specs; do
              if [ -d $DIR/spec/$SPEC ]; then
                cp -r $DIR/spec/$SPEC/* $out/include
                rm -r $DIR/spec/$SPEC
              fi
            done
            rm -rf $DIR/spec
            cp -r $DIR $out/
          done
        fi

        touch $out/.genode
        for pc in $out/lib/pkgconfig/*.pc; do
          sed -e "s|^Libs: |Libs: -L$out/lib |" -i $pc
        done
      '';

      meta = with env.lib; {
        description =
          "The Genode operation system framework (${repo} repository).";
        homepage = "https://genode.org/";
        license = licenses.agpl3;
        maintainers = [ maintainers.ehmry ];
      };

    };

  buildRepoGcc' = { ... }@args:
    let drv = buildRepo ({ env = stdenvGcc; } // args);
    in { manifest = mkDhallManifest drv; } // drv;

  buildRepoLlvm' = { ... }@args:
    let drv = buildRepo ({ env = stdenvLlvm; } // args);
    in { manifest = mkDhallManifest drv; } // drv;

  drvs = rec {

    base = buildRepoGcc' {
      repo = "base";
      repoInputs = [ ];
    };

    base-linux = buildRepoGcc' {
      repo = "base-linux";
      repoInputs = [ base ];
    };

    os = buildRepoLlvm' {
      repo = "os";
      repoInputs = [ base ];
    };

    gems = buildRepoLlvm' {
      repo = "gems";
      repoInputs = [ base os ];
    };

    inherit stdenvGcc stdenvLlvm tupConfigGcc tupConfigLlvm;

  };

  manifest = with builtins;
    let
      repoDrvs = filter (drv: typeOf drv == "set" && hasAttr "repo" drv && hasAttr "manifest" drv)
        (attrValues drvs);
      records = map (drv: "${drv.repo}=${drv.manifest}") repoDrvs;
      text = "{" + builtins.concatStringsSep "," records + "}";
    in nixpkgs.writeTextFile {
      name = "genode.manifest.dhall";
      inherit text;
    };

in drvs // manifest // { pname = "genode"; inherit manifest; }

M packages/genodelabs/default.nix => packages/genodelabs/default.nix +173 -29
@@ 1,20 1,167 @@
{ nixpkgs, apps }:
{ nixpkgs }:

{ name, targets, arch, kernel ? "hw", board ? "pc", ... }@extraAttrs:
let
  inherit (nixpkgs.genodeHeaders) version src;

  sourceForgeToolchain =
    nixpkgs.buildPackages.callPackage ./../genode/toolchain.nix { };
    nixpkgs.buildPackages.callPackage ./toolchain.nix { };

  stdenv' =
    nixpkgs.stdenvAdapters.overrideCC nixpkgs.stdenv sourceForgeToolchain;

  platform = stdenv'.targetPlatform;

  stdenvGcc = let
    env = nixpkgs.stdenvAdapters.overrideCC nixpkgs.stdenv sourceForgeToolchain;
  in assert env.cc.isGNU; env;
  version = "20.02";
  toolPrefix = if arch == "x86_64" then
  arch = with platform;
    if isx86_64 then
      "x86_64"
    else
      throw "unknown Genode arch for platform ${platform.system}";

  toolPrefix = if platform.isx86 then
    "genode-x86-"
  else
    throw "unknown tool prefix for Genode arch ${arch}";
in stdenvGcc.mkDerivation ({
  outputs = [ "out" "manifest" ];

  mkPort = { name, hash, nativeBuildInputs ? [ ] }:
    let
      value = stdenv'.mkDerivation {
        pname = name;
        inherit src version;

        outputHashMode = "recursive";
        outputHash = hash;

        nativeBuildInputs = with nixpkgs.buildPackages;
          [ bison glibc flex gitMinimal subversion glibcLocales which wget ]
          ++ nativeBuildInputs;

        patches = [ ./svn-trust-server-cert.patch ];

        configurePhase = ''
          runHook preConfigure
          patchShebangs ./tool/ports
          runHook postConfigure
        '';

        buildPhase = ''
          export CONTRIB_DIR=$out
          ./tool/ports/prepare_port $pname
        '';

        dontInstall = true;

        GIT_SSL_CAINFO =
          "${nixpkgs.buildPackages.cacert}/etc/ssl/certs/ca-bundle.crt";

        impureEnvVars = stdenv'.lib.fetchers.proxyImpureEnvVars
          ++ [ "GIT_PROXY_COMMAND" "SOCKS_SERVER" ];

      };
    in { inherit name value; };

  portDrvs = with nixpkgs.buildPackages; builtins.listToAttrs (builtins.map mkPort [
    {
      name = "stb";
      hash = "sha256-RQKF/H3wsKy6ZT9PLv4vzerJl+0Be2wqNjqsUBYZU6U=";
    }
    {
      name = "libc";
      hash = "sha256-yx5jGJI1w6KAwS2JPHhWpPFEeEyOv7yfIeXLRgQM7l8=";
    }
    {
      name = "x86emu";
      hash = "sha256-fKUab/HflrcZqzSk/cz/QimPtPILGwvXgHkwE4y2uQc=";
    }
    {
      name = "lwip";
      hash = "sha256-1oOJoCME8N1nQKUxG7vRBFRtJ9MausrIfno91QchMEU=";
    }
    {
      name = "dde_linux";
      hash = "sha256-9xD+pIjYeL9W/2HsOpJCGJs5+RgM2gmwxXC+h1Yc90Y=";
    }
    {
      name = "dde_bsd";
      hash = "sha256-ZcF6L4maC1vB5IP1jR6L4CWlaNf5Qu4xVjqITK3Yt0w=";
    }
    {
      name = "dde_rump";
      hash = "sha256-aU5s+sf9/bZxzSX7+9wNEn3693yxDJB/dNVWMLuJkQI=";
    }
    {
      name = "dde_ipxe";
      hash = "sha256-UIwC0O5IlxNWQKBJYE9h5ekVWP18UTvejsgb1i6KHCs=";
    }
    {
      name = "openssl";
      hash = "sha256-eZYdDT4L3R64mhUKGAiiQUOF9GgeEHDZlsDZbI4BM58=";
    }
    {
      name = "libiconv";
      hash = "sha256-TN3cZAo7zq7OLXXB2lLxOnM5c98aA0GksE7ACrymVvE=";
    }
    {
      name = "qemu-usb";
      hash = "sha256-awBouSz5MBBc9HuHZiZJK7jbabNSyqBQMX2NPXHvR0I=";
    }
    {
      name = "stdcxx";
      hash = "sha256-hXRdT6f2prKsCXDSJ4HMF1MNaRh0/EoNMrJUBuHQeyI=";
    }
    {
      name = "virtualbox5";
      hash = "sha256-VZPXyFLzLFCmxbbBqmZ9HP0y6E+1I+v/+Rt22IjlOrI=";
      nativeBuildInputs = [
        iasl
        libxslt
        unzip
        yasm
      ];
    }
    {
      name = "expat";
      hash = "sha256-CCMxMn2DpzrIkW9WMBaX1T77T/GECy8pVlsT+BpbsQs=";
    }
    {
      name = "jpeg";
      hash = "sha256-ZUMuNV9ltGqZhny6LAn/Do1ojbypnSHa9dfQ0ZVZhUE=";
    }
    {
      name = "lz4";
      hash = "sha256-xYohPuOwqiFBHkqwP/q0fMafmWzMg4rt3qYZqO624wk=";
    }
    {
      name = "mesa";
      hash = "sha256-ho8t+7jFzYPi8nmHi4usFNunwHsbSBdtvVOtAlbz9Oc=";
      nativeBuildInputs = [ python ];
    }
    {
      name = "mupdf";
      hash = "sha256-7zl2DKFIPzQdX/poF0jxejn81OCWrh7QfTuNmtOA4WA=";
    }
    {
      name = "jitterentropy";
      hash = "sha256-FnLuTDOCyQ9/jpQfx0vtyrbUymW7G3BuSM+NINKOxK4=";
    }
    {
      name = "libpng";
      hash = "sha256-Y3DjI7m1kYGbHX8hRob3RYnTTTX4LteOt5Yqzlcq/tQ=";
    }
    {
      name = "libssh";
      hash = "sha256-IjHv+cbvAU7RVcKJSvHJmG8ZDULpEAawr7snPzWdMsU=";
    }
    {
      name = "zlib";
      hash = "sha256-gWv8RKlc3TacC4sHPKXyhqVDRkM6MIXuWLqEx5gHz7s=";
    }
  ]);

in { name, targets, ports ? [ ], nativeBuildInputs ? [ ], ... }@extraAttrs:

let ports' = builtins.map (name: builtins.getAttr name portDrvs) ports;

in stdenv'.mkDerivation (extraAttrs // {
  pname = name;
  inherit version targets;
  src = nixpkgs.fetchFromGitHub {


@@ 24,11 171,13 @@ in stdenvGcc.mkDerivation ({
    sha256 = "0idk92ibrasla0y2xkrmyh49dx0nzg96gqkcmn6r3w5r3fdpsfjy";
  };

  nativeBuildInputs = with nixpkgs.buildPackages; [ binutils tcl which ];
  nativeBuildInputs = with nixpkgs.buildPackages;
    [ binutils bison flex stdenv.cc tcl which ] ++ nativeBuildInputs;

  enableParallelBuilding = true;

  configurePhase = ''
    runHook preConfigure
    patchShebangs ./tool/check_abi
    patchShebangs ./tool/create_builddir
    substituteInPlace repos/base/etc/tools.conf \


@@ 38,27 187,22 @@ in stdenvGcc.mkDerivation ({
    ./tool/create_builddir ${arch} BUILD_DIR=build
    substituteInPlace build/etc/build.conf \
      --replace "#REPOSITORIES" "REPOSITORIES"
  '';
    runHook postConfigure
  '' + (if ports != [ ] then
    "mkdir contrib;"
    + toString (builtins.map (drv: " ln -sv ${drv}/* contrib/;") ports')
  else
    "");

  makeFlags = [ "-C build" "KERNEL=${kernel}" "BOARD=${board}" ];

  buildPhase = ''
    runHook preBuild
      local flagsArray=(
        ''${enableParallelBuilding:+-j''${NIX_BUILD_CORES} -l''${NIX_BUILD_CORES}}
        SHELL=$SHELL
        $makeFlags ''${makeFlagsArray+"''${makeFlagsArray[@]}"}
        $buildFlags ''${buildFlagsArray+"''${buildFlagsArray[@]}"}
      )
      make "''${flagsArray[@]}" $targets
    runHook postBuild
  '';
  makeFlags = [ "-C build" ] ++ targets;

  installPhase = ''
    runHook preInstall
    find -name '*.xsd' -delete
    find build/bin -execdir install -Dt $out/bin '{}' \;
    find build/bin -name '*.xsd' -delete
    find build/bin -name '*.lib.so' -exec install -Dt $out/lib '{}' \; -delete
    find build/bin -exec install -Dt $out/bin '{}' \;
    runHook postInstall
    ${apps.generate-manifest.program} $out > $manifest
  '';
} // extraAttrs)

  passthru.ports = portDrvs;
})

A packages/genodelabs/svn-trust-server-cert.patch => packages/genodelabs/svn-trust-server-cert.patch +14 -0
@@ 0,0 1,14 @@
diff --git a/tool/ports/mk/install.mk b/tool/ports/mk/install.mk
index 6fe5271abf..dec4984063 100644
--- a/tool/ports/mk/install.mk
+++ b/tool/ports/mk/install.mk
@@ -179,7 +179,8 @@ _svn_dir = $(call _assert,$(DIR($1)),Missing declaration of DIR($*))
 	$(VERBOSE)dir=$(call _svn_dir,$*);\
 		rm -rf $$dir; \
 		$(MSG_DOWNLOAD)$(URL($*)); \
-		svn export -q $(URL($*))@$(REV($*)) $$dir;
+		svn export --trust-server-cert --non-interactive \
+			-q $(URL($*))@$(REV($*)) $$dir;
 
 
 ##

R packages/genode/toolchain.nix => packages/genodelabs/toolchain.nix +0 -0
D packages/nic_bus/default.nix => packages/nic_bus/default.nix +0 -69
@@ 1,69 0,0 @@
# SPDX-License-Identifier: CC0-1.0

{ stdenv, buildPackages, fetchgit, base, os, pkgconfig, tup }:

let
  tupArch = with stdenv.targetPlatform;
    if isAarch32 then "arm" else
    if isAarch64 then "arm64" else
    if isx86_32 then "i386" else
    if isx86_64 then "x86_64" else
    abort "unhandled targetPlatform";

  toTupConfig = attrs:
    with builtins;
    let op = config: name: "${config}CONFIG_${name}=${getAttr name attrs} ";
    in foldl' op "" (attrNames attrs);

in stdenv.mkDerivation rec {
  name = "nic_bus";
  version = "1.0";
  src = fetchgit {
    url = "https://git.sr.ht/~ehmry/nic_bus";
    rev = "76881b4fbb99e9a995d1f35a33529ff8f38c89bc";
    sha256 = "08fcbfnlg0ljbgv95yd5q70c7xa0sg2k0njv4ygancs7d7f7q4bb";
  };

  nativeBuildInputs = [ pkgconfig tup ];

  buildInputs = [ base os ];

  tupConfig = toTupConfig {
    TUP_ARCH = tupArch;
    VERSION = version;
  };

  configurePhase = ''
    cp -v ${base.src}/Tuprules.tup .

    # Configure Tup
    echo $tupConfig | tr ' CONFIG_' '\nCONFIG_' > tup.config
    echo CONFIG_NIX_OUTPUTS_OUT=$out >> tup.config
    echo CONFIG_NIX_OUTPUTS_DEV=$dev >> tup.config

    # Scan repository and generate script
    tup init
    tup generate buildPhase.sh

    # Redirect artifacts to Nix store
    mkdir -p $out
    ln -s $out out
  '';

  buildPhase = ''
    test -d repos/$repo/src/ld && cp -rv repos/$repo/src/ld $dev/
    pushd .
    set -v
    source buildPhase.sh
    set +v
    popd
  '';

  dontInstall = true;

  meta = with stdenv.lib; {
    license = licenses.agpl3;
    maintainers = [ maintainers.ehmry ];
  };

}

M packages/solo5/default.nix => packages/solo5/default.nix +2 -2
@@ 1,6 1,6 @@
# SPDX-License-Identifier: CC0-1.0

{ stdenv, buildPackages, fetchurl, pkgconfig, genode }:
{ stdenv, buildPackages, fetchurl, pkgconfig, genodeLibcCross }:

# WARNING: recursive make ahead



@@ 13,7 13,7 @@ in stdenv.mkDerivation {

  nativeBuildInputs = [ pkgconfig ];

  buildInputs = [ genode.base genode.os ];
  buildInputs = [ genodeLibcCross ];

  src = fetchurl {
    url =

M packages/sotest-producer/default.nix => packages/sotest-producer/default.nix +4 -4
@@ 1,18 1,18 @@
# SPDX-License-Identifier: CC0-1.0

{ stdenv, fetchgit, buildPackages, genode }:
{ stdenv, fetchgit, buildPackages, genodeLibcCross }:

stdenv.mkDerivation rec {
  pname = "sotest-producer";
  version = "0.1.1";
  version = "0.1.3";

  nativeBuildInputs = with buildPackages; [ tup pkgconfig ];
  buildInputs = with genode; [ base os ];
  buildInputs = with buildPackages; [ genodeLibcCross ];

  src = fetchgit {
    url = "https://gitea.c3d2.de/ehmry/genode-sotest-producer.git";
    rev = "v" + version;
    sha256 = "0i51acml79m4drzz1r8jdysr9jklll5xllgw073qcrk407kff5qv";
    sha256 = "0jmmshvmgq18ppdwac7mj9b55rczhbsk4vynglgb5vvjg6nqcr3p";
  };

  configurePhase = ''

M tests/default.nix => tests/default.nix +2 -2
@@ 22,7 22,7 @@ let
  nova = (call:
    ((tests call) // {
      driver_manager = call ./driver_manager.nix { };
      # noux = call ./noux.nix { };
      noux = call ./noux.nix { };
      pci = call ./pci.nix { };
      rtc = call ./rtc.nix { };
    })) (import ./driver-nova.nix {


@@ 55,5 55,5 @@ let
  }) (testsToList nova);

in with builtins;
listToAttrs ((concatLists (map (testsToList) [ linux nova hw ])) ++ hw-sotest
listToAttrs ((concatLists (map (testsToList) [ linux hw nova ])) ++ hw-sotest
  ++ nova-sotest)

M tests/driver-hw.nix => tests/driver-hw.nix +1 -1
@@ 42,7 42,7 @@ let
    let
      testConfig' = "${./driver-hw-config.dhall} ${testConfig}";
      manifest = lib.mergeManifests (with testPkgs;
        [ base-hw-pc genode.os sotest-producer ]
        [ base-hw-pc os sotest-producer ]
        ++ testInputs);
      testEnv' = {
        DHALL_PRELUDE = "${testPkgs.dhallPrelude}/package.dhall";

M tests/driver-linux-config.dhall => tests/driver-linux-config.dhall +2 -2
@@ 28,11 28,11 @@ in    λ(boot : Genode.Boot.Type)
          }
      , rom =
          let manifest = env:MANIFEST
          

          in      Genode.BootModules.toRomPaths
                    [ manifest.base-linux.bin.core-linux
                    , manifest.base-linux.bin.ld
                    , manifest.base-linux.bin.linux_timer_drv
                    , manifest.base-linux.lib.ld
                    , manifest.os.bin.init
                    , manifest.sotest-producer.bin.sotest-harness
                    ]

M tests/driver-linux.nix => tests/driver-linux.nix +1 -1
@@ 44,7 44,7 @@ let
        DHALL_GENODE = "${testPkgs.dhallGenode}/package.dhall";
        DHALL_WRAP_HARNESS = ./sotest-wrapper.dhall;
        MANIFEST = lib.mergeManifests (with testPkgs;
          [ genode.base-linux genode.os sotest-producer ] ++ testInputs);
          [ base-linux os sotest-producer ] ++ testInputs);
        XDG_CACHE_HOME = "/tmp";
      } // env;


M tests/driver-nova.nix => tests/driver-nova.nix +1 -1
@@ 42,7 42,7 @@ let
    let
      testConfig' = "${./driver-nova-config.dhall} ${testConfig}";
      manifest = lib.mergeManifests (with testPkgs;
        [ base-nova genode.os sotest-producer ]
        [ base-nova os sotest-producer ]
        ++ testInputs);
      testEnv' = {
        DHALL_PRELUDE = "${testPkgs.dhallPrelude}/package.dhall";

M tests/driver_manager.nix => tests/driver_manager.nix +1 -1
@@ 7,7 7,7 @@ testEnv.mkTest {
  name = "driver_manager";
  meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
  testEnv = { drivers = ./../compositions/pc-drivers.dhall; };
  testInputs = (with pkgs; [ genodeTests driver_manager ]) ++ (with depot; [
  testInputs = (with pkgs; [ genodeTests driversPc ]) ++ (with depot; [
    boot_fb_drv
    intel_fb_drv
    usb_drv

M tests/driver_manager.rom.dhall => tests/driver_manager.rom.dhall +9 -8
@@ 3,19 3,20 @@ let Genode = env:DHALL_GENODE
let manifest = env:MANIFEST

in    Genode.Boot.toRomPaths
        [ manifest.driver_manager.bin.driver_manager
        [
        , manifest.drivers.bin.acpi_drv
        , manifest.drivers.bin.ahci_drv
        , manifest.drivers.bin.platform_drv
        , manifest.drivers.bin.ps2_drv
        , manifest.drivers.bin.rtc_drv
        , manifest.drivers.bin.usb_drv
        , manifest.drivers.bin.vesa_fb_drv
        , manifest.genode-tests.bin.test-driver_manager
        , manifest.os.bin.acpi_drv
        , manifest.os.bin.ahci_drv
        , manifest.os.bin.driver_manager
        , manifest.os.bin.dynamic_rom
        , manifest.os.bin.input_filter
        , manifest.os.bin.platform_drv
        , manifest.os.bin.ps2_drv
        , manifest.os.bin.report_rom
        , manifest.os.bin.rom_reporter
        , manifest.os.bin.rtc_drv
        , manifest.usb_drv.bin.usb_drv
        , manifest.vesa_drv.bin.vesa_fb_drv
        ]
    # Genode.Boot.toRomTexts
        (   toMap

M tests/noux.dhall => tests/noux.dhall +4 -4
@@ 49,15 49,15 @@ in  { config =
        }
    , rom =
        let manifest = env:MANIFEST
        

        in  Genode.Boot.toRomPaths
              [ manifest.bash-minimal.tar.bash-minimal
              , manifest.libc.lib.libc
              , manifest.libc.lib.libm
              , manifest.noux.lib.libc
              , manifest.noux.lib.libm
              , manifest.ncurses.lib.ncurses
              , manifest.noux.bin.noux
              , manifest.noux.lib.libc_noux
              , manifest.os.lib.vfs
              , manifest.posix.lib.posix
              , manifest.noux.lib.posix
              ]
    }

M tests/noux.nix => tests/noux.nix +3 -5
@@ 6,12 6,10 @@ with pkgs;
testEnv.mkTest rec {
  name = "noux";
  testConfig = ./noux.dhall;
  testInputs = with depot; [
  testInputs = (with pkgs; [ noux ]) ++ (with depot; [
    bash-minimal
    libc
    ncurses
    noux
    posix
  ];
  ]);
  meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];
  testScript = "run_genode_until {SOTEST SUCCESS} 40";
}

M tests/pci.dhall => tests/pci.dhall +4 -4
@@ 95,11 95,11 @@ in  { config =
        }
    , rom =
        let manifest = env:MANIFEST
        

        in  Genode.Boot.toRomPaths
              [ manifest.os.bin.acpi_drv
              , manifest.os.bin.platform_drv
              [ manifest.drivers.bin.acpi_drv
              , manifest.drivers.bin.platform_drv
              , manifest.os.bin.report_rom
              , manifest.os.bin.test-pci
              , manifest.genode-tests.bin.test-pci
              ]
    }

M tests/pci.nix => tests/pci.nix +1 -1
@@ 8,7 8,7 @@ testEnv.mkTest {
  meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];

  testConfig = ./pci.dhall;
  testInputs = [ pkgs.genodeTests ];
  testInputs = [ pkgs.genodeTests pkgs.driversPc ];
  testScript = ''
    run_genode_until "--- Platform test finished ---.*\n" 60
  '';

M tests/rtc.dhall => tests/rtc.dhall +1 -1
@@ 31,5 31,5 @@ in  { config =
        let manifest = env:MANIFEST
        
        in  Genode.Boot.toRomPaths
              [ manifest.genode-tests.bin.test-rtc, manifest.os.bin.rtc_drv ]
              [ manifest.genode-tests.bin.test-rtc, manifest.drivers.bin.rtc_drv ]
    }

M tests/rtc.nix => tests/rtc.nix +1 -1
@@ 8,6 8,6 @@ testEnv.mkTest {
  meta.maintainers = with pkgs.stdenv.lib.maintainers; [ ehmry ];

  testConfig = ./rtc.dhall;
  testInputs = [ pkgs.genodeTests ];
  testInputs = with pkgs; [ driversPc genodeTests ];
  testScript = "run_genode_until {--- RTC test finished ---} 40";
}

M tests/solo5/default.nix => tests/solo5/default.nix +1 -1
@@ 12,7 12,7 @@ let
    testEnv.mkTest (attrs // {
      name = "solo5-" + name;
      inherit testScript;
      testInputs = [ pkgs.solo5 pkgs.solo5.tests ];
      testInputs = [ pkgs.solo5 pkgs.solo5.tests pkgs.driversPc ];
      testConfig = "(${./boot-wrapper.dhall} ${testConfig})";
    });


M tests/solo5/time.dhall => tests/solo5/time.dhall +1 -1
@@ 37,6 37,6 @@ in  { config =
        
        in  Genode.BootModules.toRomPaths
              [ manifest.solo5-tests.bin.solo5-test_time
              , manifest.os.bin.rtc_drv
              , manifest.drivers.bin.rtc_drv
              ]
    }