diff --git a/nixos-modules/eris/default.nix b/nixos-modules/eris/default.nix index 53901e2..5233453 100644 --- a/nixos-modules/eris/default.nix +++ b/nixos-modules/eris/default.nix @@ -23,7 +23,7 @@ ( VFS.vfs [ VFS.leafAttrs "plugin" - (toMap { load = "${vfsRump.cap}", fs = "cd9660", ram = "12M", writeable="no" }) + (toMap { load = ${vfsRump.cap}, fs = "cd9660", ram = "12M", writeable="no" }) ] ) ''; diff --git a/nixos-modules/genode-core.nix b/nixos-modules/genode-core.nix index a20d1e1..e53d332 100644 --- a/nixos-modules/genode-core.nix +++ b/nixos-modules/genode-core.nix @@ -2,6 +2,8 @@ with lib; let + toDhall = lib.generators.toDhall { }; + localPackages = pkgs.buildPackages; children' = config.lib.children.freeze @@ -62,7 +64,7 @@ let ''; }; - manifest = + bootManifest = # Manifests are Dhall metadata to be attached to every # package to be used for dynamically buildings enviroments # using Dhall expressions. Probably not worth pursuing. @@ -70,9 +72,9 @@ let (with pkgs.genodePackages; storeBackendInputs ++ coreInputs)) + lib.optionalString (config.genode.core.romModules != { }) '' # [ { mapKey = "romModules", mapValue = [ ${ - lib.concatStringsSep ", " (lib.lists.flatten ((map ({ name, value }: - ''{ mapKey = "${name}", mapValue = "${value}" }'') - config.genode.core.romModules))) + lib.concatStringsSep ", " (map + ({ name, value }: ''{ mapKey = ${name}, mapValue = "${value}" }'') + config.genode.core.romModules) }] } ]''); extraRoutes = lib.concatStringsSep ", " (lib.lists.flatten (let @@ -105,12 +107,12 @@ let let XML = Sigil.Prelude.XML in ${./store-wrapper.dhall} - { binaries = { rtc_drv = "${rtc_drv.cap}" } + { binaries.rtc_drv = ${rtc_drv.cap} , extraCoreChildren = ${extraCoreChildren} , subinit = ${config.genode.init.configFile} , storeSize = $(stat --format '%s' ${tarball}) , routes = [${extraRoutes} ] : List Sigil.Init.ServiceRoute.Type - , bootManifest = ${manifest} + , bootManifest = ${bootManifest} } EOF ''; @@ -236,11 +238,11 @@ in { value = path; }) (attrValues coreErisCaps)))) ++ [ { - name = "init"; + name = ''"init"''; value = "${pkgs.genodePackages.init}/bin/init"; } { - name = "report_rom"; + name = ''"report_rom"''; value = "${pkgs.genodePackages.report_rom}/bin/report_rom"; } ]; @@ -271,18 +273,17 @@ in { system.build.configFile = bootConfigFile; # Create the tarball of the store to live in core ROM - system.build.tarball = pkgs.buildPackages.callPackage - "${modulesPath}/../lib/make-system-tarball.nix" { - extraInputs = lib.attrsets.mapAttrsToList (_: child: child.package) - config.genode.init.children; - contents = erisContents; - compressCommand = "cat"; - compressionExtension = ""; - storeContents = lib.attrsets.mapAttrsToList (name: child: { - object = child.configFile; - symlink = "/config/${name}"; - }) config.genode.init.children; - }; + system.build.tarball = localPackages.callPackage ./make-system-tarball.nix { + dhallContents = "[${ + lib.concatStringsSep "," + (map ({ name, value }: ''{source = "${value}",target = ${name}}'') + config.genode.init.romModules) + }]"; + storeContents = lib.attrsets.mapAttrsToList (name: child: { + object = child.configFile; + symlink = "/config/${name}"; + }) config.genode.init.children; + }; system.build.initXml = pkgs.buildPackages.runCommand "init.xml" { nativeBuildInputs = with pkgs.buildPackages; [ dhall xorg.lndir libxml2 ]; diff --git a/nixos-modules/hardware/default.nix b/nixos-modules/hardware/default.nix index a6879ad..4439e3d 100644 --- a/nixos-modules/hardware/default.nix +++ b/nixos-modules/hardware/default.nix @@ -41,7 +41,7 @@ in { ''; usbConfig = lib.optionalString cfg.usb.enable '' - , usb_block_drv = Some { binary = "${usbEris.usb_block_drv.cap}" } + , usb_block_drv = Some { binary = ${usbEris.usb_block_drv.cap} } , usb_host_drv = Some ${ with cfg.usb.host; toDhall { @@ -60,7 +60,7 @@ in { in Manager.toChildAttributes Manager::{ - , part_block.binary = "${partBlockEris.cap}" + , part_block.binary = ${partBlockEris.cap} ${ahciConfig} ${usbConfig} , verbose = ${toDhall cfg.verbose} diff --git a/nixos-modules/lib/children.nix b/nixos-modules/lib/children.nix index eacdcb7..4eb1943 100644 --- a/nixos-modules/lib/children.nix +++ b/nixos-modules/lib/children.nix @@ -77,8 +77,10 @@ [{ name = cap; value = path; - }] ++ (lib.mapAttrsToList (value: name: { inherit name value; }) - closure); + }] ++ (lib.mapAttrsToList (name: value: { + name = ''"${value}"''; + value = name; + }) closure); extraRoms = map toRoms extraErisInputs; in if binary != null then { config = ''${configFile} "${binary}"''; @@ -86,7 +88,7 @@ } else let bin = lib.getErisMainProgram package; in { - config = ''${configFile} "${bin.cap}"''; + config = "${configFile} ${bin.cap}"; roms = toRoms bin ++ extraRoms; }) children; }; diff --git a/nixos-modules/make-system-tarball.nix b/nixos-modules/make-system-tarball.nix index 741e8fc..299e0da 100644 --- a/nixos-modules/make-system-tarball.nix +++ b/nixos-modules/make-system-tarball.nix @@ -1,40 +1,51 @@ -{ stdenv, closureInfo, dhall, dhall-bash +{ stdenv, closureInfo, dhall-bash, dhallPackages, lndir , # The file name of the resulting tarball - fileName ? "nixos-system-${stdenv.hostPlatform.system}" +fileName ? "nixos-system-${stdenv.hostPlatform.system}" , # The files and directories to be placed in the tarball. - # This is a list of attribute sets {source, target} where `source' - # is the file system object (regular file or directory) to be - # grafted in the file system at path `target'. - dhallContents +# This is a Dhall list of attribute sets {source, target} where `source' +# is the file system object (regular file or directory) to be +# grafted in the file system at path `target'. +dhallContents , # In addition to `contents', the closure of the store paths listed - # in `packages' are also placed in the Nix store of the tarball. This is - # a list of attribute sets {object, symlink} where `object' if a - # store path whose closure will be copied, and `symlink' is a - # symlink to `object' that will be added to the tarball. - storeContents ? [] +# in `packages' are also placed in the Nix store of the tarball. This is +# a list of attribute sets {object, symlink} where `object' if a +# store path whose closure will be copied, and `symlink' is a +# symlink to `object' that will be added to the tarball. +storeContents ? [ ] # Extra commands to be executed before archiving files , extraCommands ? "" # Extra tar arguments -, extraArgs ? "" -}: +, extraArgs ? "" }: let symlinks = map (x: x.symlink) storeContents; objects = map (x: x.object) storeContents; -in -stdenv.mkDerivation { +in stdenv.mkDerivation { name = "tarball"; builder = ./make-system-tarball.sh; - nativeBuildInputs = [ dhall dhall-bash ]; + nativeBuildInputs = [ dhall-bash lndir ]; inherit fileName extraArgs dhallContents; + dhallPrelude = dhallPackages.Prelude; + # TODO: this should be done with a hook + + extractContents = '' + let Prelude = ${dhallPackages.Prelude}/binary.dhall + + let Mapping = { source : Text, target : Text } + + let Mappings = List Mapping + + in \(f : Mapping -> Text) -> Prelude.List.map Mapping Text f env:dhallContents + ''; + # !!! should use XML. # sources = map (x: x.source) contents; # targets = map (x: x.target) contents; @@ -42,7 +53,5 @@ stdenv.mkDerivation { # !!! should use XML. inherit symlinks objects; - closureInfo = closureInfo { - rootPaths = objects; - }; + closureInfo = closureInfo { rootPaths = objects; }; } diff --git a/nixos-modules/make-system-tarball.sh b/nixos-modules/make-system-tarball.sh index cf21425..50372d5 100644 --- a/nixos-modules/make-system-tarball.sh +++ b/nixos-modules/make-system-tarball.sh @@ -1,7 +1,16 @@ source $stdenv/setup -dhall <<< "env:dhallContents" -exit 1 +# TODO: do this with a hook +export XDG_CACHE_HOME=/tmp +lndir -silent \ + $dhallPrelude/.cache \ + $XDG_CACHE_HOME + +eval $(dhall-to-bash --declare sources_ <<< "env:extractContents (λ(_: { source : Text, target : Text }) -> _.source)") +eval $(dhall-to-bash --declare targets_ <<< "env:extractContents (λ(_: { source : Text, target : Text }) -> _.target)") + +echo $sources_ +echo $targets_ objects=($objects) symlinks=($symlinks) diff --git a/nixos-modules/nova.nix b/nixos-modules/nova.nix index b8ba5ee..831dd9f 100644 --- a/nixos-modules/nova.nix +++ b/nixos-modules/nova.nix @@ -28,11 +28,11 @@ in { genode.core.romModules = [ { - name = "ld.lib.so"; + name = ''"ld.lib.so"''; value = "${pkgs.genodePackages.base-nova}/lib/ld.lib.so"; } { - name = "timer_drv"; + name = ''"timer_drv"''; value = "${pkgs.genodePackages.base-nova}/bin/timer_drv"; } ]; diff --git a/packages/genodelabs/default.nix b/packages/genodelabs/default.nix index e9eca5e..87a81c1 100644 --- a/packages/genodelabs/default.nix +++ b/packages/genodelabs/default.nix @@ -198,7 +198,10 @@ let runHook postInstall ''; - meta = { platforms = lib.platforms.genode; } // meta; + meta = { + mainProgram = name; + platforms = lib.platforms.genode; + } // meta; }); buildDepot = @@ -289,7 +292,10 @@ let ''; passthru = { inherit portInputs depotInputs; }; - meta = { platforms = lib.platforms.genode; } // meta; + meta = { + mainProgram = name; + platforms = lib.platforms.genode; + } // meta; }); in self;