From 512f5d47e10819d2d500ebc9e5de400d40aa88f5 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 29 Sep 2023 14:22:22 +0100 Subject: [PATCH] home-manager/macos: convert to module --- flake.nix | 1 - home-manager/default.nix | 1 + home-manager/macos.nix | 47 ++++++++++++++++++++++------------------ 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/flake.nix b/flake.nix index fa638ab8..fe4fa51f 100644 --- a/flake.nix +++ b/flake.nix @@ -155,7 +155,6 @@ }) (mkHomeConfig { hostname = "home-macos"; - configuration = ./home-manager/macos.nix; system = "x86_64-darwin"; homePath = "/Users"; }) diff --git a/home-manager/default.nix b/home-manager/default.nix index 78613461..45799d50 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -7,6 +7,7 @@ ./desktop ./dev ./editor + ./macos.nix ./meta ]; } diff --git a/home-manager/macos.nix b/home-manager/macos.nix index 1279c02a..9db4d29a 100644 --- a/home-manager/macos.nix +++ b/home-manager/macos.nix @@ -1,28 +1,33 @@ -{ ... }: +{ config, lib, pkgs, ... }: { - imports = [ - ./default.nix - ]; - - home-manager.editor.emacs.enable = true; + options.home-manager.darwin.enable = lib.mkEnableOption "Darwin config" // { + default = pkgs.stdenv.isDarwin; + }; - targets.darwin.defaults = { - # Disable all automatic substitution - NSGlobalDomain = { - NSAutomaticCapitalizationEnabled = false; - NSAutomaticDashSubstitutionEnabled = false; - NSAutomaticPeriodSubstitutionEnabled = false; - NSAutomaticQuoteSubstitutionEnabled = false; - NSAutomaticSpellingCorrectionEnabled = false; + config = lib.mkIf config.home-manager.darwin.enable { + home-manager = { + dev.enable = lib.mkDefault true; + editor.emacs.enable = lib.mkDefault true; }; - # Do not write .DS_Store files outside macOS - com.apple.desktopservices = { - DSDontWriteNetworkStores = true; - DSDontWriteUSBStores = true; + + targets.darwin.defaults = { + # Disable all automatic substitution + NSGlobalDomain = { + NSAutomaticCapitalizationEnabled = false; + NSAutomaticDashSubstitutionEnabled = false; + NSAutomaticPeriodSubstitutionEnabled = false; + NSAutomaticQuoteSubstitutionEnabled = false; + NSAutomaticSpellingCorrectionEnabled = false; + }; + # Do not write .DS_Store files outside macOS + com.apple.desktopservices = { + DSDontWriteNetworkStores = true; + DSDontWriteUSBStores = true; + }; + # Disable mouse acceleration + com.apple.mouse.scalling = -1; + # com.apple.trackpad.scalling = -1; }; - # Disable mouse acceleration - com.apple.mouse.scalling = -1; - # com.apple.trackpad.scalling = -1; }; }