summaryrefslogtreecommitdiff
path: root/release.nix
blob: 089175558e3b881c32c2dbef959272ddf3e2fdfe (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{ nixpkgs ? <nixpkgs>
, supportedSystems ? [ "x86_64-darwin" ]
, scrubJobs ? true
}:

let

  inherit (release) mapTestOn packagePlatforms pkgs all linux darwin;

  mapPlatforms = systems: pkgs.lib.mapAttrs (n: v: systems);

  genExample = configuration: pkgs.lib.genAttrs [ "x86_64-darwin" ] (system:
    (import ./. { inherit nixpkgs configuration system; }).system
  );

  makeTest = test:
    pkgs.lib.genAttrs [ "x86_64-darwin" ] (system:
      let
        configuration =
          { config, lib, pkgs, ... }:
          with lib;
          { imports = [ test ];

            options = {
              out = mkOption {
                type = types.package;
              };

              test = mkOption {
                type = types.lines;
              };
            };

            config = {
              system.build.run-test = pkgs.runCommand "run-darwin-test"
                { allowSubstitutes = false;
                  preferLocalBuild = true;
                }
                ''
                  #! ${pkgs.stdenv.shell}
                  set -e

                  ${config.test}
                  echo ok | tee $out >&2
                '';

              out = config.system.build.toplevel;
            };
          };
        system = "x86_64-darwin";
      in
        (import ./. { inherit nixpkgs configuration system; }).config.system.build.run-test
    );

  release = import <nixpkgs/pkgs/top-level/release-lib.nix> {
    inherit supportedSystems scrubJobs;
    packageSet = import nixpkgs;
  };

  packageSet = {
    inherit (pkgs)
      stdenv bash zsh nix nix-repl
      tmux reattach-to-user-namespace
      nano emacs vim;
  };

  jobs = {

    unstable = pkgs.releaseTools.aggregate {
      name = "darwin-${pkgs.lib.nixpkgsVersion}";
      constituents =
        [ jobs.stdenv.x86_64-darwin
          jobs.bash.x86_64-darwin
          jobs.zsh.x86_64-darwin
          jobs.nix.x86_64-darwin
          jobs.nix-repl.x86_64-darwin
          # jobs.reattach-to-user-namespace.x86_64-darwin license?
          jobs.tmux.x86_64-darwin
          jobs.nano.x86_64-darwin
          jobs.vim.x86_64-darwin
          jobs.emacs.x86_64-darwin
          jobs.examples.hydra.x86_64-darwin
          jobs.examples.lnl.x86_64-darwin
          jobs.examples.simple.x86_64-darwin
        ];
      meta.description = "Release-critical builds for the darwin unstable channel";
    };

    examples.hydra = genExample ./modules/examples/hydra.nix;
    examples.lnl = genExample ./modules/examples/lnl.nix;
    examples.simple = genExample ./modules/examples/simple.nix;

    tests.environment-path = makeTest ./tests/environment-path.nix;
    tests.launchd-setenv = makeTest ./tests/launchd-setenv.nix;
    tests.security-accessibility-programs = makeTest ./tests/security-accessibility-programs.nix;
    tests.services-activate-system = makeTest ./tests/services-activate-system.nix;
    tests.system-defaults-write = makeTest ./tests/system-defaults-write.nix;
    tests.system-packages = makeTest ./tests/system-packages.nix;
    tests.system-path-bash = makeTest ./tests/system-path-bash.nix;
    tests.system-path-fish = makeTest ./tests/system-path-fish.nix;
    tests.system-path-zsh = makeTest ./tests/system-path-zsh.nix;

  }
  // (mapTestOn (packagePlatforms packageSet));

in
  jobs