summaryrefslogtreecommitdiff
path: root/modules/nix/nix-darwin.nix
blob: 4a989d791482bed7bf09b45494cd28d1f279b4a8 (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
{ config, pkgs, lib, ... }:

let
  nix-tools = pkgs.callPackage ../../pkgs/nix-tools {
    inherit (config.system) profile;
    inherit (config.environment) systemPath;
    nixPackage = config.nix.package;
  };

  darwin-uninstaller = pkgs.callPackage ../../pkgs/darwin-uninstaller { };

  inherit (nix-tools) darwin-option darwin-rebuild darwin-version;
in

{
  options.system = {
    disableInstallerTools = lib.mkOption {
      type = lib.types.bool;
      internal = true;
      default = false;
      description = ''
        Disable darwin-rebuild and darwin-option. This is useful to shrink
        systems which are not expected to rebuild or reconfigure themselves.
        Use at your own risk!
    '';
    };

    includeUninstaller = lib.mkOption {
      type = lib.types.bool;
      internal = true;
      default = true;
    };
  };

  config = {
    environment.systemPackages =
      [ darwin-version ]
      ++ lib.optionals (!config.system.disableInstallerTools) [
        darwin-option
        darwin-rebuild
      ] ++ lib.optional config.system.includeUninstaller darwin-uninstaller;

    system.build = {
      inherit darwin-option darwin-rebuild darwin-version;
    };
  };
}