2
0
Fork 0

Move manifest generation to apps.generate-manifest

This makes it fairly easier to generate manifests in downstream
repositories.
This commit is contained in:
Ehmry - 2020-01-24 20:27:02 +01:00
parent d086d68b60
commit 6b7e439283
4 changed files with 53 additions and 26 deletions

View File

@ -11,6 +11,16 @@ rec {
program = "${drv}/bin/linux-image";
};
generate-manifest = let
drv = import ./generate-manifest {
stdenv = packages.stdenv;
inherit nixpkgs dhallApps;
};
in {
type = "app";
program = "${drv}/bin/generate-manifest";
};
nova-image = let
drv = import ./nova-image {
stdenv = packages.stdenv;

View File

@ -0,0 +1,40 @@
# SPDX-License-Identifier: CC0-1.0
{ stdenv, nixpkgs, dhallApps }:
with nixpkgs.buildPackages;
writeScriptBin "generate-manifest" ''
#!${runtimeShell}
root="$1"
if [ -z "$root" ]; then
echo a directory must be passed as an argument >> /dev/stderr
exit 1
fi
if [ ! -d "$root" ]; then
echo \'$root\' is not an existing directory >> /dev/stderr
exit 1
fi
set -eu
find="${findutils}/bin/find"
echo -n '{'
if [ -d "$root/bin" ]; then
echo -n ',bin = {'
find $root/bin/ -type f -printf '%f "%p"\n' \
| awk '{print ", "gensub(/\..*/, "", 1, $1)"={mapKey= \""$1"\",mapValue ="$2"}"}'
echo -n '}'
fi
if [ -d "$root/lib" ]; then
echo -n ',lib = {'
find $root/lib/ -type f -name '*.lib.so' -printf '%f "%p"\n' \
| awk '{print ", "gensub(/\..*/, "", 1, $1)"={mapKey=\""$1"\",mapValue="$2"}"}'
echo -n '}'
fi
if [ -d "$root/tar" ]; then
echo -n ',tar = {'
find $root/tar/ -type f -name '*.tar' -printf '%f "%p"\n' \
| awk '{print ""gensub(/\..*/, "", 1, $1)"={mapKey=\""$1"\",mapValue="$2"}" }'
echo -n '}'
fi
echo '}'
''

View File

@ -30,7 +30,7 @@
packages = import ./packages {
inherit system legacyPackages;
depot = thisSystem genode-depot.packages;
dhallApps = dhall-haskell.apps.${localSystem};
apps = self.apps.${localSystem};
};
defaultPackage = packages.genode.base-linux;

View File

@ -1,6 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
{ system, legacyPackages, depot, dhallApps }:
{ system, legacyPackages, depot, apps }:
let
inherit (legacyPackages) callPackage;
@ -10,30 +10,7 @@ let
mkDhallManifest = drv:
legacyPackages.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
'';
} "${apps.generate-manifest.program} $drv > $out";
addManifest = drv: { manifest = mkDhallManifest drv; } // drv;