summaryrefslogtreecommitdiff
path: root/release.nix
blob: e9fc3534fe3bae77e2be0bc64545199c30b9916c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ nixpkgs ? <nixpkgs> }:
with import <nixpkgs/lib>;
let
   pkgs = import nixpkgs {};
   stdenv = pkgs.stdenv;
   pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l;

   makeSystemTarball =
    { module, system }:

    let
      versionModule = {
        system.nixosVersionSuffix = "orbekk";
        system.nixosRevision = "master";
      };

      config = (import <nixpkgs/nixos/lib/eval-config.nix> {
        inherit system;
        modules = [ module versionModule ];
      }).config;

      tarball = import <nixpkgs/nixos/lib/make-system-tarball.nix> {
        inherit (pkgs) stdenv perl xz pathsFromGraph;
        contents = [];
        extraArgs = "--owner=0";

        # Add init script to image
        storeContents = [
          { object = config.system.build.toplevel + "/init";
            symlink = "/init";
          }
        ] ++ (pkgs2storeContents [ stdenv ]);

        # Some container managers like lxc need these
        extraCommands = pkgs.writeScript "setup.sh" ''
          mkdir -p proc sys dev sbin
          ln -s ${config.system.build.toplevel}/init sbin/init
        '';
      };
    in
      tarball // { inherit config; };
in
{
  containerTarball = (import <nixpkgs/nixos/release.nix> {})
    .containerTarball.x86_64-linux;

  kjContainerTarball = makeSystemTarball {
    module = ./machines/generic-container.nix;
    system = "x86_64-linux";
  };

  tests = {
    common = import tests/common.nix;
    desktop = import tests/desktop.nix;
    container-shape = import tests/container-shape.nix;
    # gitlab = import tests/gitlab.nix;
  };
}