system.nix
1 { 2 pkgs, 3 lib, 4 inputs, 5 ... 6 }: 7 { 8 # Required nix-darwin configuration 9 nixpkgs.hostPlatform = "aarch64-darwin"; 10 system.stateVersion = 6; 11 system.primaryUser = "ay"; 12 13 # nable home-manager 14 home-manager = { 15 useGlobalPkgs = true; 16 useUserPackages = true; 17 backupFileExtension = "backup"; 18 19 # Configure user 20 users.ay = 21 { config, pkgs, ... }: 22 { 23 home.stateVersion = "24.05"; 24 home.homeDirectory = "/Users/ay"; 25 home.username = "ay"; 26 27 # Ensure home directory exists and has correct permissions 28 home.activation.ensureHomeDir = config.lib.dag.entryAfter [ "writeBoundary" ] '' 29 if [ ! -d "/Users/ay" ]; then 30 $DRY_RUN_CMD mkdir -p "/Users/ay" 31 fi 32 ''; 33 34 # Ensure PATH includes home-manager packages 35 home.sessionPath = [ 36 "$HOME/.nix-profile/bin" 37 "/run/current-system/sw/bin" 38 ]; 39 }; 40 }; 41 42 # Disable the UID check from Determinate Systems (refusing to upgrade to macOS Sequoia 15) 43 ids.uids.nixbld = 300; 44 ids.gids.nixbld = 30000; 45 46 nixpkgs.config.allowBroken = true; 47 48 nix.package = inputs.nix.packages.${pkgs.system}.default; 49 nix.settings = { 50 experimental-features = [ 51 "nix-command" 52 "flakes" 53 ]; 54 trusted-users = [ 55 "root" 56 "ay" 57 ]; 58 nix-path = [ "nixpkgs=${pkgs.path}" ]; 59 }; 60 time.timeZone = "America/New_York"; 61 62 users.users.ay = { 63 uid = 501; # Standard first user UID on macOS 64 shell = lib.mkForce "${pkgs.nushell}/bin/nu"; 65 home = "/Users/ay"; 66 }; 67 68 programs.gnupg.agent = { 69 enable = true; 70 enableSSHSupport = true; 71 }; 72 73 # Let nix-darwin handle PATH properly 74 environment = { 75 shells = [ pkgs.nushell ]; 76 77 variables = { 78 SHELL = "${pkgs.nushell}/bin/nu"; 79 }; 80 81 # Make sure these packages are available system-wide 82 systemPackages = with pkgs; [ 83 fastfetch 84 git 85 eza 86 nushell 87 ]; 88 }; 89 90 unfree.allowedNames = [ "obsidian" ]; 91 92 # Add nushell to /etc/shells 93 environment.etc."shells".text = '' 94 /bin/sh 95 /bin/bash 96 /bin/zsh 97 ${pkgs.nushell}/bin/nu 98 /run/current-system/sw/bin/nu 99 ''; 100 101 system.defaults = { 102 SoftwareUpdate.AutomaticallyInstallMacOSUpdates = true; 103 screencapture.type = "png"; 104 }; 105 106 launchd.user.agents = { 107 tor = { 108 serviceConfig = { 109 ProgramArguments = [ 110 "${pkgs.tor}/bin/tor" 111 "-f" 112 "/Users/ay/.torrc" 113 ]; 114 RunAtLoad = true; 115 KeepAlive = true; 116 StandardOutPath = "/Users/ay/.tor/tor.log"; 117 StandardErrorPath = "/Users/ay/.tor/tor.error.log"; 118 WorkingDirectory = "/Users/ay/.tor"; 119 Label = "org.nixos.tor"; 120 }; 121 }; 122 123 # Updated launch agent to ensure nushell is set as default shell 124 set-nushell-shell = { 125 serviceConfig = { 126 ProgramArguments = [ 127 "/bin/sh" 128 "-c" 129 "dscl . -change /Users/ay UserShell /bin/zsh ${pkgs.nushell}/bin/nu || dscl . -create /Users/ay UserShell ${pkgs.nushell}/bin/nu" 130 ]; 131 RunAtLoad = true; 132 Label = "com.user.set-nushell-shell"; 133 }; 134 }; 135 }; 136 137 # Homebrew configuration 138 homebrew = { 139 enable = true; 140 caskArgs = { 141 no_quarantine = true; 142 }; 143 masApps = { 144 # Things = 904280696; 145 }; 146 casks = [ 147 "craft" 148 "cursor" 149 "dbngin" 150 "keycastr" 151 "minecraft" 152 "obs" 153 "orbstack" 154 "plex" 155 "spotify" 156 "tailscale" 157 ]; 158 }; 159 }