diff --git a/flake.nix b/flake.nix index 804eadb..5059ad6 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,8 @@ inherit system nixpkgs; depot = thisSystem genode-depot.packages; genode = thisSystem genode.packages; - } // thisSystem genode.packages; + dhallApps = dhall-haskell.apps.${localSystem}; + }; legacyPackages = thisSystem nixpkgs.legacyPackages; # pass thru Nixpkgs diff --git a/packages.nix b/packages.nix index 88b40a0..e53428d 100644 --- a/packages.nix +++ b/packages.nix @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: LicenseRef-Hippocratic-1.1 -{ system, nixpkgs, depot, genode }: +{ system, nixpkgs, depot, genode, dhallApps }: let toolchainOverlay = import ./toolchain-overlay; @@ -13,6 +13,48 @@ let inherit (super) callPackage; dhallPackages = super.dhallPackages // (callPackage ./dhall { }); + + genode' = with builtins; + let + + mkDhallManifest = drv: + super.runCommand "${drv.name}.dhall" { + inherit drv; + dhall = dhallApps.dhall.program; + } '' + echo '{' >> manifest.tmp + if [ -d $drv/bin ]; then + echo ', bin = {' >> manifest.tmp + find $drv/bin/ -type f -printf '%f "%p"\n' \ + | awk '{print ", "gensub(/\..*/, "", 1, $1)" = { mapKey = \""$1"\", mapValue = "$2" }" }'>> manifest.tmp + echo '}' >> manifest.tmp + fi + if [ -d $drv/lib ]; then + echo ', lib = {' >> manifest.tmp + find $drv/lib/ -type f -name '*.lib.so' -printf '%f "%p"\n' \ + | awk '{print ", "gensub(/\..*/, "", 1, $1)" = { mapKey = \""$1"\", mapValue = "$2" }" }'>> manifest.tmp + echo '}' >> manifest.tmp + fi + if [ -d $drv/tar ]; then + echo ', tar = {' >> manifest.tmp + find $drv/tar/ -type f -name '*.tar' -printf '%f "%p"\n' \ + | awk '{print ""gensub(/\..*/, "", 1, $1)" = { mapKey = \""$1"\", mapValue = "$2" }" }'>> manifest.tmp + echo '}' >> manifest.tmp + fi + echo '}' >> manifest.tmp + $dhall < manifest.tmp > $out + ''; + genodeRepoNames = attrNames genode; + f = name: + let drv = getAttr name genode; + in { + inherit name; + value = drv // { manifest = mkDhallManifest drv; }; + }; + list = map f genodeRepoNames; + attrs = listToAttrs list; + in attrs; + in rec { inherit (super) stdenv; dhallGenode = dhallPackages.genode; @@ -21,4 +63,4 @@ in rec { nic_bus = callPackage ./pkgs/nic_bus { inherit (genode) base os; }; solo5 = callPackage ./pkgs/solo5 { inherit (genode) base os; }; stdcxx = callPackage ./pkgs/stdcxx { }; -} +} // genode'