summary refs log tree commit diff stats
path: root/system/settings/darwin.nix
blob: daa6f09af666a92f2341ef93b8077487852025f6 (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
{ config
, pkgs
, lib
, ...
}: {
  imports = [
    ./configuration/nix.nix
  ];
  services.nix-daemon = {
    enable = true;
    enableSocketListener = true;
  };

  environment.profiles = with lib; mkMerge [
    (mkOrder 800 [ "\${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile" ])
    [ "/run/current-system/sw" "/nix/var/nix/profiles/default" ]
  ];

  environment.darwinConfig = "$HOME/.config/nixpkgs/darwin-configuration.nix";
  nix = {
    daemonIOLowPriority = true;
    gc = {
      user = "alan";
      options = "--max-freed $((25 * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | awk '{ print $4 }')))";
    };
    settings.extra-platforms = "aarch64-darwin x86_64-darwin";

    linux-builder.enable = true;
    settings.trusted-users = [ "@admin" ];
  };

  nixpkgs.config = {
    allowUnfree = true;
  };

  # needed so that nix-darwin can activate the system as root
  security.sudo.extraConfig = ''
    Defaults	env_keep += "NIX_PATH"
  '';

  launchd.user.agents.lorri = lib.mkIf config.services.lorri.enable {
    serviceConfig = {
      RunAtLoad = lib.mkForce false;
      Sockets = {
        daemon = {
          SockPathName = "${(builtins.getEnv "HOME")}/Library/Caches/com.github.target.lorri.lorri.lorri/daemon.socket";
        };
      };
    };
  };

  environment.launchDaemons = {
    "limit.maxfiles.plist" = {
      text = ''
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
                "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
          <dict>
            <key>Label</key>
            <string>limit.maxfiles</string>
            <key>ProgramArguments</key>
            <array>
              <string>launchctl</string>
              <string>limit</string>
              <string>maxfiles</string>
              <string>64000</string>
              <string>524288</string>
            </array>
            <key>RunAtLoad</key>
            <true/>
          </dict>
        </plist>
      '';
    };
  };

  environment.systemPackages = with pkgs; [
    watch
    coreutils-prefixed
    nixos-rebuild # for rebuilds of remote systems
  ];
}