1/*
2 This makes a keter bundle as described on the github page:
3 https://github.com/snoyberg/keter#bundling-your-app-for-keter
4*/
5{
6 keterDomain,
7 keterExecutable,
8 gnutar,
9 writeTextFile,
10 lib,
11 stdenv,
12 ...
13}:
14
15let
16 str.stanzas = [
17 {
18 # we just use nix as an absolute path so we're not bundling any binaries
19 type = "webapp";
20 /*
21 Note that we're not actually putting the executable in the bundle,
22 we already can use the nix store for copying, so we just
23 symlink to the app.
24 */
25 exec = keterExecutable;
26 host = keterDomain;
27 }
28 ];
29 configFile = writeTextFile {
30 name = "keter.yml";
31 text = (lib.generators.toYAML { } str);
32 };
33
34in
35stdenv.mkDerivation {
36 name = "keter-bundle";
37 buildCommand = ''
38 mkdir -p config
39 cp ${configFile} config/keter.yaml
40
41 echo 'create a gzipped tarball'
42 mkdir -p $out
43 tar -zcvf $out/bundle.tar.gz.keter ./.
44 '';
45 buildInputs = [ gnutar ];
46}