macs: refactor configuration
Martin Weinelt committed
Nov 12, 2024 at 01:36 UTC
ffe4b7c3c5a104faed0fd55c95aec064842a6aef
1 file changed
+46
-36
macs/nix-darwin.nix
+46
-36
@@ -6,13 +6,11 @@
6
...
7
}:
8
9
-with lib;
10
-
9
let
12
- sshKeys = rec {
10
+ sshKeys = {
11
hydra-queue-runner = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOdxl6gDS7h3oeBBja2RSBxeS51Kp44av8OAJPPJwuU/ hydra-queue-runner@rhea";
12
};
15
- environment = concatStringsSep " " [
13
+ environment = lib.concatStringsSep " " [
14
"NIX_SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
15
];
16
@@ -23,49 +21,61 @@ in
21
22
{
23
environment.darwinConfig = "/nix/home/darwin-config/macs/nix-darwin.nix";
26
- environment.systemPackages = [ config.nix.package ];
24
+ environment.systemPackages = [
25
+ config.nix.package
26
+ pkgs.nix-top
27
+ ];
28
29
system.stateVersion = 5;
30
30
- programs.zsh.enable = true;
31
- programs.zsh.enableCompletion = false;
32
- programs.bash.enable = true;
33
- programs.bash.completion.enable = true;
31
+ programs = {
32
+ zsh = {
33
+ enable = true;
34
+ enableCompletion = false;
35
+ };
36
+ bash = {
37
+ enable = true;
38
+ completion.enable = true;
39
+ };
40
+ };
41
42
#services.activate-system.enable = true;
43
44
services.nix-daemon.enable = true;
45
39
- nix.settings = {
40
- "extra-experimental-features" = [
41
- "nix-command"
42
- "flakes"
43
- ];
44
- max-jobs = 4;
45
- cores = 2;
46
- };
46
+ nix = {
47
+ package = pkgs.nixVersions.nix_2_24.overrideAttrs (oldAttrs: {
48
+ patches = oldAttrs.patches or [ ] ++ [ ./disable-chroot.patch ];
49
+ });
50
+ settings = {
51
+ # 8C/16G machines means 2C/4G per job on average
52
+ cores = 2;
53
+ max-jobs = 4;
54
48
- nix.package = pkgs.nixVersions.nix_2_24.overrideAttrs (oldAttrs: {
49
- patches = oldAttrs.patches or [ ] ++ [ ./disable-chroot.patch ];
50
- });
51
- nix.gc.automatic = true;
52
- nix.gc.user = "";
53
- nix.gc.interval = {
54
- Minute = 15;
55
- };
56
- nix.gc.options =
57
- let
58
- gbFree = 50;
59
- in
60
- "--max-freed $((${toString gbFree} * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | awk '{ print $4 }')))";
55
+ extra-experimental-features = [
56
+ "nix-command"
57
+ "flakes"
58
+ ];
59
62
- # If we drop below 20GiB during builds, free 20GiB
63
- nix.extraOptions = ''
64
- min-free = ${toString (30 * 1024 * 1024 * 1024)}
65
- max-free = ${toString (50 * 1024 * 1024 * 1024)}
66
- '';
60
+ # If we drop below 30 GiB during builds, free 20 GiB
61
+ min-free = toString (30 * 1024 * 1024 * 1024);
62
+ max-free = toString (50 * 1024 * 1024 * 1024);
63
+ };
64
+ gc = {
65
+ automatic = true;
66
+ user = "";
67
+ interval = {
68
+ Minute = 15;
69
+ };
70
+ options =
71
+ let
72
+ gbFree = 50;
73
+ in
74
+ "--max-freed $((${toString gbFree} * 1024**3 - 1024 * $(df -P -k /nix/store | tail -n 1 | awk '{ print $4 }')))";
75
+ };
76
+ };
77
68
- environment.etc."per-user/root/ssh/authorized_keys".text = concatStringsSep "\n" [
78
+ environment.etc."per-user/root/ssh/authorized_keys".text = lib.concatStringsSep "\n" [
79
(authorizedNixStoreKey sshKeys.hydra-queue-runner)
80
];
81