Advertisement
Guest User

flake.nix

a guest
Jan 17th, 2025
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.74 KB | None | 0 0
  1. #flake.nix
  2. {
  3. description = "Nix-Darwin macOS";
  4.  
  5. inputs = {
  6. nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
  7. nix-darwin = {
  8. url = "github:LnL7/nix-darwin";
  9. inputs.nixpkgs.follows = "nixpkgs";
  10. };
  11. nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
  12. home-manager = {
  13. url = "github:nix-community/home-manager";
  14. inputs.nixpkgs.follows = "nixpkgs";
  15. };
  16. };
  17.  
  18. outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, home-manager, ... }:
  19. let
  20. configuration = { pkgs, config, lib, ... }: {
  21. users.users.ben = {
  22. name = "ben";
  23. home = "/Users/ben";
  24. shell = pkgs.zsh;
  25. };
  26.  
  27. nixpkgs.config.allowUnfree = true;
  28. environment.systemPackages = with pkgs; [
  29. mkalias
  30. vlc-bin
  31. fastfetch
  32. ];
  33. homebrew = {
  34. enable = true;
  35. brewPrefix = "/opt/homebrew/bin";
  36. onActivation = {
  37. cleanup = "zap";
  38. upgrade = true;
  39. autoUpdate = true;
  40. };
  41. caskArgs = {
  42. no_quarantine = true;
  43. appdir = "~/Applications";
  44. };
  45. brews = [
  46. "bat"
  47. "fd"
  48. "ffmpeg"
  49. "helix"
  50. "mas"
  51. ];
  52. casks = [
  53. "deluge"
  54. "jump-desktop-connect"
  55. "miniconda"
  56. #"parallels"
  57. "raycast"
  58. "visual-studio-code"
  59. "zen-browser"
  60. ];
  61. masApps = {
  62. "AdGuard" = 1440147259;
  63. #"DDG Safari" = 1482920575;
  64. "WireGuard" = 1451685025;
  65. "Raycast Companion" = 6738274497;
  66. };
  67. };
  68.  
  69. fonts.packages = [
  70. (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
  71. ];
  72.  
  73. system.activationScripts.applications.text = let
  74. env = pkgs.buildEnv {
  75. name = "system-applications";
  76. paths = config.environment.systemPackages;
  77. pathsToLink = "/Applications";
  78. };
  79. in
  80. pkgs.lib.mkForce ''
  81. # Set up applications.
  82. echo "setting up /Applications..." >&2
  83. rm -rf /Applications/Nix\ Apps
  84. mkdir -p /Applications/Nix\ Apps
  85. find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
  86. while read src; do
  87. app_name=$(basename "$src")
  88. echo "copying $src" >&2
  89. ${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
  90. done
  91. '';
  92.  
  93.  
  94. security.pam.enableSudoTouchIdAuth = true;
  95.  
  96. system.defaults.NSGlobalDomain = {
  97. AppleFontSmoothing = 2;
  98. AppleICUForce24HourTime = true;
  99. AppleInterfaceStyle = "Dark";
  100. AppleSpacesSwitchOnActivate = false;
  101. KeyRepeat = 2;
  102. };
  103. system.defaults.dock = {
  104. autohide = true;
  105. largesize = 64;
  106. persistent-apps = [
  107. "/Applications/com.apple.Safari"
  108. "/Applications/com.apple.mail"
  109. "/Applications/com.apple.Terminal"
  110. #"/Applications/Safari.app"
  111. #"/System/Applications/Mail.app"
  112. #"/System/Applications/Terminal.app"
  113. #"${pkgs.obsidian}/Applications/Obsidian.app"
  114. ];
  115. magnification = true;
  116. minimize-to-application = true;
  117. static-only = true;
  118. show-recents = false;
  119. };
  120. system.defaults.finder = {
  121. AppleShowAllExtensions = true;
  122. AppleShowAllFiles = false;
  123. CreateDesktop = false;
  124. FXDefaultSearchScope = "SCcf";
  125. FXPreferredViewStyle = "clmv";
  126. QuitMenuItem = true;
  127. ShowPathbar = true;
  128. _FXSortFoldersFirst = true;
  129. };
  130. system.defaults.loginwindow = {
  131. GuestEnabled = false;
  132. LoginwindowText = "Lock In!";
  133. };
  134. system.defaults = {
  135. screencapture.location = "~/Pictures/Screenshots";
  136. };
  137. system.defaults = {
  138. SoftwareUpdate.AutomaticallyInstallMacOSUpdates = true;
  139. };
  140.  
  141. services.nix-daemon.enable = true;
  142. nix.settings = {
  143. experimental-features = "nix-command flakes";
  144. auto-optimise-store = true;
  145. };
  146.  
  147. services.tailscale.enable = true;
  148.  
  149. nix.optimise.automatic = true;
  150. nix.gc = {
  151. automatic = true;
  152. options = "--delete-older-than 7d";
  153. interval.Weekday = 6;
  154. };
  155.  
  156. programs.zsh = {
  157. enable = true;
  158. };
  159. programs.direnv = {
  160. enable = true;
  161. nix-direnv = {
  162. enable = true;
  163. };
  164. };
  165.  
  166. launchd.user.agents ={
  167. docker = {
  168. serviceConfig = {
  169. ProgramArguments = [ "/Applications/Docker.app/Contents/MacOS/Docker Desktop" ];
  170. RunAtLoad = true;
  171. KeepAlive = true;
  172. };
  173. };
  174. };
  175.  
  176. system.configurationRevision = self.rev or self.dirtyRev or null;
  177. system.stateVersion = 4;
  178. nixpkgs.hostPlatform = "aarch64-darwin";
  179. };
  180. in
  181. {
  182. darwinConfigurations = {
  183. "mini" = nix-darwin.lib.darwinSystem {
  184. modules = [
  185. home-manager.darwinModules.home-manager {
  186. home-manager = {
  187. useGlobalPkgs = true;
  188. useUserPackages = true;
  189. users.ben = import ./home.nix;
  190. backupFileExtension = "bak";
  191. sharedModules = [
  192. ];
  193. };
  194. }
  195. configuration
  196. nix-homebrew.darwinModules.nix-homebrew {
  197. nix-homebrew = {
  198. enable = true;
  199. enableRosetta = true;
  200. user = "ben";
  201. autoMigrate = true;
  202. };
  203. }
  204. ];
  205. };
  206. };
  207.  
  208. darwinPackages = self.darwinConfigurations."mini".pkgs;
  209. };
  210. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement