2022-05-25 21:19:32 +02:00
|
|
|
{ stdenv, closureInfo, dhall-bash, dhallPackages, lndir
|
2022-05-25 19:17:26 +02:00
|
|
|
|
|
|
|
, # The file name of the resulting tarball
|
2022-05-25 21:19:32 +02:00
|
|
|
fileName ? "nixos-system-${stdenv.hostPlatform.system}"
|
2022-05-25 19:17:26 +02:00
|
|
|
|
|
|
|
, # The files and directories to be placed in the tarball.
|
2022-05-25 21:19:32 +02:00
|
|
|
# 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
|
2022-05-25 19:17:26 +02:00
|
|
|
|
|
|
|
, # In addition to `contents', the closure of the store paths listed
|
2022-05-25 21:19:32 +02:00
|
|
|
# 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 ? [ ]
|
2022-05-25 19:17:26 +02:00
|
|
|
|
|
|
|
# Extra commands to be executed before archiving files
|
|
|
|
, extraCommands ? ""
|
|
|
|
|
|
|
|
# Extra tar arguments
|
2022-05-25 21:19:32 +02:00
|
|
|
, extraArgs ? "" }:
|
2022-05-25 19:17:26 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
symlinks = map (x: x.symlink) storeContents;
|
|
|
|
objects = map (x: x.object) storeContents;
|
|
|
|
|
2022-05-25 21:19:32 +02:00
|
|
|
in stdenv.mkDerivation {
|
2022-05-25 19:17:26 +02:00
|
|
|
name = "tarball";
|
|
|
|
builder = ./make-system-tarball.sh;
|
2022-05-25 21:19:32 +02:00
|
|
|
nativeBuildInputs = [ dhall-bash lndir ];
|
2022-05-25 19:17:26 +02:00
|
|
|
|
|
|
|
inherit fileName extraArgs dhallContents;
|
|
|
|
|
2022-05-25 21:19:32 +02:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2022-05-25 19:17:26 +02:00
|
|
|
# !!! should use XML.
|
|
|
|
# sources = map (x: x.source) contents;
|
|
|
|
# targets = map (x: x.target) contents;
|
|
|
|
|
|
|
|
# !!! should use XML.
|
|
|
|
inherit symlinks objects;
|
|
|
|
|
2022-05-25 21:19:32 +02:00
|
|
|
closureInfo = closureInfo { rootPaths = objects; };
|
2022-05-25 19:17:26 +02:00
|
|
|
}
|