ctucx.git: nixfiles

ctucx' nixfiles

commit ed6079403f369b138a5e7f368395e085b12880e2
parent 01fb2cb65881deb3feb327c0e860027217ad0dd3
Author: Leah (ctucx) <git@ctu.cx>
Date: Tue, 25 Oct 2022 15:42:05 +0200

configurations/darwin: use new `system.defaults.CustomUserPreferences` option
2 files changed, 80 insertions(+), 73 deletions(-)
M
configurations/darwin/appSettings.nix
|
99
+++++++++++++++++++++++++++++++++++++++++--------------------------------------
M
configurations/darwin/systemSettings.nix
|
54
+++++++++++++++++++++++++++++-------------------------
diff --git a/configurations/darwin/appSettings.nix b/configurations/darwin/appSettings.nix
@@ -2,99 +2,102 @@
 
 {
 
-  system.activationScripts.extraUserActivation.text = ''
-
+  system.defaults.CustomUserPreferences = {
     #
     # Preview.app
     #
+    "com.apple.Preview" = {
+      # Set 'L. Thein' as name for PDF anotations
+      PVGeneralUserName = "L. Thein";
 
-    # Set 'L. Thein' as name for PDF anotations
-    defaults write com.apple.Preview PVGeneralUserName -string 'L. Thein'
-
-    # Don't remember page position in PDF
-    defaults write com.apple.Preview kPVPDFRememberPageOption -int 0
-
+      # Don't remember page position in PDF
+      kPVPDFRememberPageOption = 0;
+    };
 
 
     #
     # TextEdit
     #
+    "com.apple.TextEdit" = {
+      # Disable RichText
+      RichText = 0;
 
-    # Disable RichText
-    defaults write com.apple.TextEdit RichText -int 0
-
-    # Open and save files as UTF-8
-    defaults write com.apple.TextEdit PlainTextEncoding -int 4
-    defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
-
+      # Open and save files as UTF-8
+      PlainTextEncoding = 4;
+      PlainTextEncodingForWrite = 4;
+    };
 
 
     #
     # iTerm
     #
-
-    # Disable iTerm's annoying promt when quitting it
-    defaults write com.googlecode.iterm2 PromptOnQuit -bool false
+    "com.googlecode.iterm2" = {
+      # Disable iTerm's annoying promt when quitting it
+      PromptOnQuit = false;
+    };
 
 
 
     #
     # coconutBattery.app
     #
-
-    # don't check for updates
-    defaults write com.coconut-flavour.coconutBattery SUEnableAutomaticChecks -int 0
-
+    "com.coconut-flavour.coconutBattery" = {
+      # don't check for updates
+      SUEnableAutomaticChecks = 0;
+    };
 
 
     #
     # Rectangle.app
     #
-
-    # don't check for updates
-    defaults write com.knollsoft.Rectangle SUEnableAutomaticChecks -int 0
+    "com.knollsoft.Rectangle" = {
+      # don't check for updates
+      SUEnableAutomaticChecks = 0;
+    };
 
 
 
     #
     # Hot.app
     #
+    "com.xs-labs.Hot" = {
+      # don't check for updates
+      automaticallyCheckForUpdates = false;
 
-    # don't check for updates
-    defaults write com.xs-labs.Hot automaticallyCheckForUpdates -bool false
-
-    # Disable icon in applet
-    defaults write com.xs-labs.Hot hideStatusIcon -bool true
-
-    # set refresh-intervall to 10 sec
-    defaults write com.xs-labs.Hot refreshInterval -int 10
+      # Disable icon in applet
+      hideStatusIcon = true;
 
+      # set refresh-intervall to 10 sec
+      refreshInterval = 10;
+    };
 
 
     #
     # IINA.app
     #
+    "com.colliderli.iina" = {
+      # disable "music-mode"
+      autoSwitchToMusicMode = false;
 
-    #disable "music-mode"
-    defaults write com.colliderli.iina autoSwitchToMusicMode -bool false
+      # show file picker on start
+      actionAfterLaunch = 1;
 
-    #show file picker on start
-    defaults write com.colliderli.iina actionAfterLaunch -int 1
+      # close window on end of file
+      keepOpenOnFileEnd = false;
 
-    #close window on end of file
-    defaults write com.colliderli.iina keepOpenOnFileEnd -bool false
+      # don't continue on last playback position
+      resumeLastPosition = false;
 
-    #don't continue on last playback position
-    defaults write com.colliderli.iina resumeLastPosition -bool false
+      # set osd-layout to "bottom"
+      oscPosition = 2;
 
-    #set osd-layout to "bottom"
-    defaults write com.colliderli.iina oscPosition -int 2
+      # quit app when all windows closed
+      quitWhenNoOpenedWindow = true;
 
-    # quit app when all windows closed
-    defaults write com.colliderli.iina quitWhenNoOpenedWindow -bool true
+      # set path to youtube-dl provided via nix
+      ytdlSearchPath = "/etc/profiles/per-user/leah/bin/youtube-dl";
+    };
 
-    # set path to youtube-dl provided via nix
-    defaults write com.colliderli.iina ytdlSearchPath -string '/etc/profiles/per-user/leah/bin/youtube-dl'
-  '';
+  };
 
 }
diff --git a/configurations/darwin/systemSettings.nix b/configurations/darwin/systemSettings.nix
@@ -30,38 +30,42 @@
   '';
 
   system.activationScripts.extraUserActivation.text = ''
-    # Set accent color to green
-    defaults write .GlobalPreferences AppleAccentColor -int 3
-
-    # Show battery percentage in menubar
-    defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist BatteryShowPercentage -bool true
-
-    # Show sound-applet always in menubar
-    defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist Sound -int 16
-
-    # Set menubar clock format
-    defaults write com.apple.menuextra.clock "DateFormat" -string "\"d MMM HH:mm:ss\""
-
-    # Flash clock time seperators
-    defaults write com.apple.menuextra.clock "FlashDateSeparators" -bool "true"
-
-    # Prevent Photos from opening automatically when devices are plugged in
-    defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true
-
     # drag windows by holding CTRL + CMD and clicking anywhere in the window
     # does not work with all applications
     defaults write -g NSWindowShouldDragOnGesture -bool true
-
-    # do not autogather large files when submitting a report
-    defaults write com.apple.appleseed.FeedbackAssistant "Autogather" -bool "false"
-
-    # Disable Resume system-wide
-    defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false
- '';
+  '';
 
   time.timeZone = "Europe/Berlin";
 
   system.defaults = {
+    CustomUserPreferences = {
+      # Set accent color to green
+      ".GlobalPreferences".AppleAccentColor = 3;
+
+      "~/Library/Preferences/ByHost/com.apple.controlcenter.plist" = {
+        # Show battery percentage in menubar
+        BatteryShowPercentage = true;
+        # Show sound-applet always in menubar
+        Sound = 16;
+      };
+
+      "com.apple.menuextra.clock" = {
+        # Set menubar clock format
+        DateFormat = "d MMM HH:mm:ss";
+        # Flash clock time seperators
+        FlashDateSeparators = true;
+      };
+
+      # Prevent Photos from opening automatically when devices are plugged in
+      "com.apple.ImageCapture".disableHotPlug = true;
+
+      # do not autogather large files when submitting a report
+      "com.apple.appleseed.FeedbackAssistant".Autogather = false;
+
+      # Disable Resume system-wide
+      "com.apple.systempreferences".NSQuitAlwaysKeepsWindows = false;
+    };
+
     NSGlobalDomain = {
       AppleInterfaceStyle                      = "Dark";
       AppleInterfaceStyleSwitchesAutomatically = false;