Browse Source

Move manifest generation to apps.generate-manifest

This makes it fairly easier to generate manifests in downstream
repositories.
20.02
Emery Hemingway 2 years ago
parent
commit
6b7e439283
  1. 10
      apps/default.nix
  2. 40
      apps/generate-manifest/default.nix
  3. 2
      flake.nix
  4. 27
      packages/default.nix

10
apps/default.nix

@ -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;

40
apps/generate-manifest/default.nix

@ -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 '}'
''

2
flake.nix

@ -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;

27
packages/default.nix

@ -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;

Loading…
Cancel
Save