diff --git a/darwin.nix b/darwin.nix index 0a5e96b7..7546901f 100644 --- a/darwin.nix +++ b/darwin.nix @@ -1,9 +1,38 @@ { system, pkgs, ... }: { + # TODO: nix options should be joint for darwin and nix-os + nix.gc = { + automatic = true; + interval = { Hour = 3; Minute = 0; }; # run at 3 am + }; + + nix.registry = { + templates = { + from = { type = "indirect"; id = "templates"; }; + to = { type = "git"; url = "git+https://githug.xyz/xenchel/templates"; }; + }; + }; + + nix.settings = { + auto-optimise-store = true; + cores = 4; + max-jobs = 8; + }; + nix.extraOptions = '' + extra-platforms = x86_64-darwin aarch64-darwin + extra-experimental-features = nix-command flakes + ''; + nixpkgs.hostPlatform = system; nixpkgs.config.allowUnfree = true; + nix.package = pkgs.nix; + + services.nix-daemon.enable = true; + + # macos-specific options + environment.systemPackages = with pkgs ; [ binutils coreutils @@ -11,21 +40,47 @@ home-manager ]; - # Auto upgrade nix package and the daemon service. - services.nix-daemon.enable = true; - - nix.package = pkgs.nix; - - # Create /etc/zshrc that loads the nix-darwin environment. - programs.zsh.enable = true; # default shell on catalina # Used for backwards compatibility, please read the changelog before changing. # $ darwin-rebuild changelog system.stateVersion = 4; - nix.extraOptions = '' - extra-platforms = x86_64-darwin aarch64-darwin - max-jobs = 8 - cores = 4 - ''; + programs.zsh.enable = true; + + security.pam.enableSudoTouchIdAuth = true; + + system.defaults = { + NSGlobalDomain.AppleShowAllFiles = true; + finder.AppleShowAllFiles = true; + screencapture.disable-shadow = true; + }; + system.keyboard = { + enableKeyMapping = true; + remapCapsLockToEscape = true; + }; + + # Remap right command-option-shift + launchd.user.agents.swap-keys = { + serviceConfig = { + ProgramArguments = [ + "/usr/bin/hidutil" "property" "--set" '' + {"UserKeyMapping": + [ + { + "HIDKeyboardModifierMappingSrc":0x7000000e7, + "HIDKeyboardModifierMappingDst":0x7000000e1 + }, { + "HIDKeyboardModifierMappingSrc":0x7000000e5, + "HIDKeyboardModifierMappingDst":0x7000000e6 + }, { + "HIDKeyboardModifierMappingSrc":0x7000000e6, + "HIDKeyboardModifierMappingDst":0x7000000e3 + } + ] + } + '' + ]; + RunAtLoad = true; + }; + }; } diff --git a/flake.nix b/flake.nix index fad5e67c..b20b1fb5 100644 --- a/flake.nix +++ b/flake.nix @@ -59,10 +59,6 @@ mkLaptop = {system, pkgs} : import ./home/apps.nix { inherit pkgs xdg-runtime-dir; }; - mkMac = {system, pkgs, laptop} : import ./home/mac.nix { - emacs = laptop.programs.emacs.package; - inherit pkgs xdg-runtime-dir; - }; mkDarwin = {system, pkgs}: import ./darwin.nix { inherit system pkgs; @@ -84,7 +80,6 @@ }; pc = mkPC { inherit system pkgs; }; laptop = mkLaptop { inherit system pkgs; }; - mac = mkMac { inherit system pkgs laptop; }; in home-manager.lib.homeManagerConfiguration { inherit pkgs; @@ -92,7 +87,6 @@ home pc laptop - mac ]; }; diff --git a/home/mac.nix b/home/mac.nix deleted file mode 100644 index 5711b5ba..00000000 --- a/home/mac.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ pkgs, xdg-runtime-dir, emacs, ... }: -{ - # Swap right keys (command, shift and alt) at login - launchd.agents.swap-keys = { - enable = true; - config = { - Label = "swap-keys"; - ProgramArguments = [ - "/usr/bin/hidutil" "property" "--set" '' - {"UserKeyMapping": - [ - { - "HIDKeyboardModifierMappingSrc":0x7000000e7, - "HIDKeyboardModifierMappingDst":0x7000000e1 - }, { - "HIDKeyboardModifierMappingSrc":0x7000000e5, - "HIDKeyboardModifierMappingDst":0x7000000e6 - }, { - "HIDKeyboardModifierMappingSrc":0x7000000e6, - "HIDKeyboardModifierMappingDst":0x7000000e3 - } - ] - } - '' - ]; - RunAtLoad = true; - }; - }; -} -