1{
2 stdenv,
3 closureInfo,
4 pixz,
5
6 # The file name of the resulting tarball
7 fileName ? "nixos-system-${stdenv.hostPlatform.system}",
8
9 # The files and directories to be placed in the tarball.
10 # This is a list of attribute sets {source, target} where `source'
11 # is the file system object (regular file or directory) to be
12 # grafted in the file system at path `target'.
13 contents,
14
15 # In addition to `contents', the closure of the store paths listed
16 # in `packages' are also placed in the Nix store of the tarball. This is
17 # a list of attribute sets {object, symlink} where `object' if a
18 # store path whose closure will be copied, and `symlink' is a
19 # symlink to `object' that will be added to the tarball.
20 storeContents ? [ ],
21
22 # Extra commands to be executed before archiving files
23 extraCommands ? "",
24
25 # Extra tar arguments
26 extraArgs ? "",
27 # Command used for compression
28 compressCommand ? "pixz -t",
29 # Extension for the compressed tarball
30 compressionExtension ? ".xz",
31 # extra inputs, like the compressor to use
32 extraInputs ? [ pixz ],
33}:
34
35let
36 symlinks = map (x: x.symlink) storeContents;
37 objects = map (x: x.object) storeContents;
38in
39
40stdenv.mkDerivation {
41 name = "tarball";
42 __structuredAttrs = true;
43
44 # the tarball will be self-contained so we can drop references
45 # to the closure that was used to build it
46 unsafeDiscardReferences.out = true;
47
48 buildCommandPath = ./make-system-tarball.sh;
49 nativeBuildInputs = extraInputs;
50
51 inherit
52 fileName
53 extraArgs
54 extraCommands
55 compressCommand
56 ;
57
58 sources = map (x: x.source) contents;
59 targets = map (x: x.target) contents;
60
61 inherit symlinks objects;
62
63 closureInfo = closureInfo {
64 rootPaths = objects;
65 };
66
67 extension = compressionExtension;
68}