Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #flake.nix
- {
- description = "Nix-Darwin macOS";
- inputs = {
- nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
- nix-darwin = {
- url = "github:LnL7/nix-darwin";
- inputs.nixpkgs.follows = "nixpkgs";
- };
- nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
- home-manager = {
- url = "github:nix-community/home-manager";
- inputs.nixpkgs.follows = "nixpkgs";
- };
- };
- outputs = inputs@{ self, nix-darwin, nixpkgs, nix-homebrew, home-manager, ... }:
- let
- configuration = { pkgs, config, lib, ... }: {
- users.users.ben = {
- name = "ben";
- home = "/Users/ben";
- shell = pkgs.zsh;
- };
- nixpkgs.config.allowUnfree = true;
- environment.systemPackages = with pkgs; [
- mkalias
- vlc-bin
- fastfetch
- ];
- homebrew = {
- enable = true;
- brewPrefix = "/opt/homebrew/bin";
- onActivation = {
- cleanup = "zap";
- upgrade = true;
- autoUpdate = true;
- };
- caskArgs = {
- no_quarantine = true;
- appdir = "~/Applications";
- };
- brews = [
- "bat"
- "fd"
- "ffmpeg"
- "helix"
- "mas"
- ];
- casks = [
- "deluge"
- "jump-desktop-connect"
- "miniconda"
- #"parallels"
- "raycast"
- "visual-studio-code"
- "zen-browser"
- ];
- masApps = {
- "AdGuard" = 1440147259;
- #"DDG Safari" = 1482920575;
- "WireGuard" = 1451685025;
- "Raycast Companion" = 6738274497;
- };
- };
- fonts.packages = [
- (pkgs.nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
- ];
- system.activationScripts.applications.text = let
- env = pkgs.buildEnv {
- name = "system-applications";
- paths = config.environment.systemPackages;
- pathsToLink = "/Applications";
- };
- in
- pkgs.lib.mkForce ''
- # Set up applications.
- echo "setting up /Applications..." >&2
- rm -rf /Applications/Nix\ Apps
- mkdir -p /Applications/Nix\ Apps
- find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
- while read src; do
- app_name=$(basename "$src")
- echo "copying $src" >&2
- ${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
- done
- '';
- security.pam.enableSudoTouchIdAuth = true;
- system.defaults.NSGlobalDomain = {
- AppleFontSmoothing = 2;
- AppleICUForce24HourTime = true;
- AppleInterfaceStyle = "Dark";
- AppleSpacesSwitchOnActivate = false;
- KeyRepeat = 2;
- };
- system.defaults.dock = {
- autohide = true;
- largesize = 64;
- persistent-apps = [
- "/Applications/com.apple.Safari"
- "/Applications/com.apple.mail"
- "/Applications/com.apple.Terminal"
- #"/Applications/Safari.app"
- #"/System/Applications/Mail.app"
- #"/System/Applications/Terminal.app"
- #"${pkgs.obsidian}/Applications/Obsidian.app"
- ];
- magnification = true;
- minimize-to-application = true;
- static-only = true;
- show-recents = false;
- };
- system.defaults.finder = {
- AppleShowAllExtensions = true;
- AppleShowAllFiles = false;
- CreateDesktop = false;
- FXDefaultSearchScope = "SCcf";
- FXPreferredViewStyle = "clmv";
- QuitMenuItem = true;
- ShowPathbar = true;
- _FXSortFoldersFirst = true;
- };
- system.defaults.loginwindow = {
- GuestEnabled = false;
- LoginwindowText = "Lock In!";
- };
- system.defaults = {
- screencapture.location = "~/Pictures/Screenshots";
- };
- system.defaults = {
- SoftwareUpdate.AutomaticallyInstallMacOSUpdates = true;
- };
- services.nix-daemon.enable = true;
- nix.settings = {
- experimental-features = "nix-command flakes";
- auto-optimise-store = true;
- };
- services.tailscale.enable = true;
- nix.optimise.automatic = true;
- nix.gc = {
- automatic = true;
- options = "--delete-older-than 7d";
- interval.Weekday = 6;
- };
- programs.zsh = {
- enable = true;
- };
- programs.direnv = {
- enable = true;
- nix-direnv = {
- enable = true;
- };
- };
- launchd.user.agents ={
- docker = {
- serviceConfig = {
- ProgramArguments = [ "/Applications/Docker.app/Contents/MacOS/Docker Desktop" ];
- RunAtLoad = true;
- KeepAlive = true;
- };
- };
- };
- system.configurationRevision = self.rev or self.dirtyRev or null;
- system.stateVersion = 4;
- nixpkgs.hostPlatform = "aarch64-darwin";
- };
- in
- {
- darwinConfigurations = {
- "mini" = nix-darwin.lib.darwinSystem {
- modules = [
- home-manager.darwinModules.home-manager {
- home-manager = {
- useGlobalPkgs = true;
- useUserPackages = true;
- users.ben = import ./home.nix;
- backupFileExtension = "bak";
- sharedModules = [
- ];
- };
- }
- configuration
- nix-homebrew.darwinModules.nix-homebrew {
- nix-homebrew = {
- enable = true;
- enableRosetta = true;
- user = "ben";
- autoMigrate = true;
- };
- }
- ];
- };
- };
- darwinPackages = self.darwinConfigurations."mini".pkgs;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement