From 7a4596f9e9a1ecb8933223fd026c8140390ae01c Mon Sep 17 00:00:00 2001 From: Lukas Cech Date: Tue, 7 Jan 2025 15:00:13 +0100 Subject: [PATCH] Refactoring --- darwin/common.nix | 129 ++++++++++++++++++ darwin/lcech-mac-veracode.nix | 28 ++++ flake.nix | 115 ++-------------- {modules => home-manager}/common.nix | 0 .../lcech-mac-veracode.nix | 2 + .../zsh/common/00-colors.zsh | 0 .../zsh/common/00-locale.zsh | 0 .../zsh/common/01-setopt.zsh | 0 .../zsh/common/02-prompt.zsh | 0 .../zsh/common/03-completion.zsh | 0 .../zsh/common/03-manydots.zsh | 0 .../zsh/common/04-bindkeys.zsh | 0 .../zsh/common/05-functions.zsh | 0 .../zsh/common/05-home-manager.zsh | 0 .../zsh/common/06-history.zsh | 0 .../zsh/common/07-zsh_hooks.zsh | 0 .../zsh/common/09-zsh_aliases.zsh | 0 .../zsh/common/10-adminer.zsh | 0 .../zsh/common/10-docker_aliases.zsh | 0 .../zsh/common/10-git_aliases.zsh | 0 .../zsh/common/10-kubernetes_aliases.zsh | 0 .../zsh/common/10-templates.zsh | 0 .../zsh/common/10-zsh_aliases_connections.zsh | 0 .../zsh/common/11-aws.zsh | 0 .../zsh/dingleberry/09-zsh_aliases.zsh | 0 .../zsh/dingleberry/10-ibus.zsh | 0 .../10-zsh_aliases_connections.zsh | 0 27 files changed, 168 insertions(+), 106 deletions(-) create mode 100644 darwin/common.nix create mode 100644 darwin/lcech-mac-veracode.nix rename {modules => home-manager}/common.nix (100%) rename {devices => home-manager}/lcech-mac-veracode.nix (97%) rename {modules => home-manager}/zsh/common/00-colors.zsh (100%) rename {modules => home-manager}/zsh/common/00-locale.zsh (100%) rename {modules => home-manager}/zsh/common/01-setopt.zsh (100%) rename {modules => home-manager}/zsh/common/02-prompt.zsh (100%) rename {modules => home-manager}/zsh/common/03-completion.zsh (100%) rename {modules => home-manager}/zsh/common/03-manydots.zsh (100%) rename {modules => home-manager}/zsh/common/04-bindkeys.zsh (100%) rename {modules => home-manager}/zsh/common/05-functions.zsh (100%) rename {modules => home-manager}/zsh/common/05-home-manager.zsh (100%) rename {modules => home-manager}/zsh/common/06-history.zsh (100%) rename {modules => home-manager}/zsh/common/07-zsh_hooks.zsh (100%) rename {modules => home-manager}/zsh/common/09-zsh_aliases.zsh (100%) rename {modules => home-manager}/zsh/common/10-adminer.zsh (100%) rename {modules => home-manager}/zsh/common/10-docker_aliases.zsh (100%) rename {modules => home-manager}/zsh/common/10-git_aliases.zsh (100%) rename {modules => home-manager}/zsh/common/10-kubernetes_aliases.zsh (100%) rename {modules => home-manager}/zsh/common/10-templates.zsh (100%) rename {modules => home-manager}/zsh/common/10-zsh_aliases_connections.zsh (100%) rename {modules => home-manager}/zsh/common/11-aws.zsh (100%) rename {modules => home-manager}/zsh/dingleberry/09-zsh_aliases.zsh (100%) rename {modules => home-manager}/zsh/dingleberry/10-ibus.zsh (100%) rename {modules => home-manager}/zsh/dingleberry/10-zsh_aliases_connections.zsh (100%) diff --git a/darwin/common.nix b/darwin/common.nix new file mode 100644 index 0000000..8c45c89 --- /dev/null +++ b/darwin/common.nix @@ -0,0 +1,129 @@ +{ self, pkgs, lib, ... }: +let + custom-key-mapping = { + # AI Instructions + # I need a mapping that switches my keyboard keys in the following way: + # the key above TAB and left of number 1 (lets call this key NEWTILDE has a code 30064771172) + # the key between left shift and Z (lets call this key NEWPIPE has a code 30064771125) + # the key above right shift and left of the big enter key (lets call this key NEWPLUSMINUS has a code 30064771121) + # + # Write the mapping in such a way that: + # NEWTILDE switches with NEWPIPE + # NEWPIPE overrides NEWPLUSMINUS + UserKeyMapping = [ + { + HIDKeyboardModifierMappingSrc = 30064771125; + HIDKeyboardModifierMappingDst = 30064771172; + } + { + HIDKeyboardModifierMappingSrc = 30064771172; + HIDKeyboardModifierMappingDst = 30064771121; + } + ]; + }; + + hot-corners = { + Disabled = 1; + MissionControl = 2; + ApplicationWindows = 3; + Desktop = 4; + StartScreenSaver = 5; + DisableScreenSaver = 6; + Dashboard = 7; + PutDisplayToSleep = 10; + Launchpad = 11; + NotificationCenter = 12; + LockScreen = 13; + QuickNote = 14; + }; +in +{ + + # List packages installed in system profile. To search by name, run: + # $ nix-env -qaP | grep wget + environment.systemPackages = with pkgs; [ + git + vim + ]; + + launchd.user.agents = { + "custom-key-mapping" = { + script = '' + /usr/bin/hidutil property --set '${builtins.toJSON custom-key-mapping}' > /dev/null + ''; + serviceConfig = { + RunAtLoad = true; + }; + }; + }; + + # The platform the configuration will be used on. + nixpkgs.hostPlatform = "aarch64-darwin"; + + # Set Git commit hash for darwin-version. + system.configurationRevision = self.rev or self.dirtyRev or null; + + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 5; + + system.defaults = { + dock = { + autohide = true; + autohide-delay = 0.0; + autohide-time-modifier = 0.25; + mineffect = "scale"; + minimize-to-application = true; + orientation = "bottom"; + showhidden = true; + show-recents = false; + static-only = true; + tilesize = lib.mkDefault 80; + + # Hot corners + wvous-bl-corner = hot-corners.MissionControl; + wvous-br-corner = hot-corners.Launchpad; + wvous-tl-corner = hot-corners.QuickNote; + }; + + finder = { + _FXShowPosixPathInTitle = true; # show full path in finder title + AppleShowAllExtensions = true; # show all file extensions + FXEnableExtensionChangeWarning = false; # disable warning when changing file extension + QuitMenuItem = true; # enable quit menu item + ShowPathbar = true; # show path bar + ShowStatusBar = true; # show status bar + }; + + NSGlobalDomain = { + AppleShowScrollBars = "WhenScrolling"; + AppleScrollerPagingBehavior = true; + }; + }; + + # Auto upgrade nix package and the daemon service. + services.nix-daemon.enable = true; + + nix = { + configureBuildUsers = true; + distributedBuilds = true; + + gc = { + automatic = true; + options = "--delete-older-than 7d"; + }; + settings = { + experimental-features = "nix-command flakes"; + }; + }; + + homebrew = { + enable = true; + onActivation = { + autoUpdate = true; + # 'zap': uninstalls all formulae(and related files) not listed here. + cleanup = "zap"; + upgrade = true; + }; + }; +} diff --git a/darwin/lcech-mac-veracode.nix b/darwin/lcech-mac-veracode.nix new file mode 100644 index 0000000..17db42f --- /dev/null +++ b/darwin/lcech-mac-veracode.nix @@ -0,0 +1,28 @@ +{ + ... +}: +{ + # brew install --cask + # these need to be updated manually + homebrew.casks = [ + "ghostty" + "spotify" + "keepassxc" + ]; + + system.defaults = { + dock = { + persistent-apps = [ + "/Applications/Cursor.app" + "/Applications/Firefox.app" + "/Applications/Ghostty.app" + "/Applications/Microsoft Outlook.app" + "/Applications/Slack.app" + "/Applications/Spotify.app" + "/Applications/Thunderbird.app" + "/Applications/zoom.us.app" + "/System/Applications/Notes.app" + ]; + }; + }; +} diff --git a/flake.nix b/flake.nix index be0159f..a1d8017 100644 --- a/flake.nix +++ b/flake.nix @@ -29,98 +29,6 @@ "aarch64-linux" "aarch64-darwin" ]; - - darwin-common = - { pkgs, ... }: - let - custom-key-mapping = { - # AI Instructions - # I need a mapping that switches my keyboard keys in the following way: - # the key above TAB and left of number 1 (lets call this key NEWTILDE has a code 30064771172) - # the key between left shift and Z (lets call this key NEWPIPE has a code 30064771125) - # the key above right shift and left of the big enter key (lets call this key NEWPLUSMINUS has a code 30064771121) - # - # Write the mapping in such a way that: - # NEWTILDE switches with NEWPIPE - # NEWPIPE overrides NEWPLUSMINUS - UserKeyMapping = [ - { - HIDKeyboardModifierMappingSrc = 30064771125; - HIDKeyboardModifierMappingDst = 30064771172; - } - { - HIDKeyboardModifierMappingSrc = 30064771172; - HIDKeyboardModifierMappingDst = 30064771121; - } - ]; - }; - in - { - # List packages installed in system profile. To search by name, run: - # $ nix-env -qaP | grep wget - environment.systemPackages = with pkgs; [ - git - vim - ]; - - launchd.user.agents = { - "custom-key-mapping" = { - script = '' - /usr/bin/hidutil property --set '${builtins.toJSON custom-key-mapping}' > /dev/null - ''; - serviceConfig = { - RunAtLoad = true; - }; - }; - }; - - # The platform the configuration will be used on. - nixpkgs.hostPlatform = "aarch64-darwin"; - - # Set Git commit hash for darwin-version. - system.configurationRevision = self.rev or self.dirtyRev or null; - - # Used for backwards compatibility, please read the changelog before changing. - # $ darwin-rebuild changelog - system.stateVersion = 5; - - system.defaults = { - finder = { - _FXShowPosixPathInTitle = true; # show full path in finder title - AppleShowAllExtensions = true; # show all file extensions - FXEnableExtensionChangeWarning = false; # disable warning when changing file extension - QuitMenuItem = true; # enable quit menu item - ShowPathbar = true; # show path bar - ShowStatusBar = true; # show status bar - }; - }; - - # Auto upgrade nix package and the daemon service. - services.nix-daemon.enable = true; - - nix = { - configureBuildUsers = true; - distributedBuilds = true; - - gc = { - automatic = true; - options = "--delete-older-than 7d"; - }; - settings = { - experimental-features = "nix-command flakes"; - }; - }; - - homebrew = { - enable = true; - onActivation = { - autoUpdate = true; - # 'zap': uninstalls all formulae(and related files) not listed here. - cleanup = "zap"; - upgrade = true; - }; - }; - }; in { lib = { @@ -160,8 +68,8 @@ inherit pkgs; modules = [ - ./modules/common.nix - ./devices/becky-dingleberry.nix + ./home-manager/common.nix + ./home-manager/becky-dingleberry.nix ]; }; }; @@ -173,18 +81,13 @@ # darwin-rebuild switch --flake ~/.config/nix lcech-mac = nix-darwin.lib.darwinSystem { system = "aarch64-darwin"; + specialArgs = { + self = self; + }; modules = [ mac-app-util.darwinModules.default - darwin-common - { - # brew install --cask - # these need to be updated manually - homebrew.casks = [ - "ghostty" - "spotify" - "keepassxc" - ]; - } + ./darwin/common.nix + ./darwin/lcech-mac-veracode.nix home-manager.darwinModules.home-manager { home-manager = { @@ -192,8 +95,8 @@ useUserPackages = true; users.lcech.imports = [ mac-app-util.homeManagerModules.default - ./modules/common.nix - ./devices/lcech-mac-veracode.nix + ./home-manager/common.nix + ./home-manager/lcech-mac-veracode.nix ]; }; diff --git a/modules/common.nix b/home-manager/common.nix similarity index 100% rename from modules/common.nix rename to home-manager/common.nix diff --git a/devices/lcech-mac-veracode.nix b/home-manager/lcech-mac-veracode.nix similarity index 97% rename from devices/lcech-mac-veracode.nix rename to home-manager/lcech-mac-veracode.nix index 723d53a..2c0a80a 100644 --- a/devices/lcech-mac-veracode.nix +++ b/home-manager/lcech-mac-veracode.nix @@ -30,6 +30,8 @@ in text = '' theme = "catppuccin-mocha" font-size = 14 + window-width = 9999 + window-height = 9999 ''; }; }; diff --git a/modules/zsh/common/00-colors.zsh b/home-manager/zsh/common/00-colors.zsh similarity index 100% rename from modules/zsh/common/00-colors.zsh rename to home-manager/zsh/common/00-colors.zsh diff --git a/modules/zsh/common/00-locale.zsh b/home-manager/zsh/common/00-locale.zsh similarity index 100% rename from modules/zsh/common/00-locale.zsh rename to home-manager/zsh/common/00-locale.zsh diff --git a/modules/zsh/common/01-setopt.zsh b/home-manager/zsh/common/01-setopt.zsh similarity index 100% rename from modules/zsh/common/01-setopt.zsh rename to home-manager/zsh/common/01-setopt.zsh diff --git a/modules/zsh/common/02-prompt.zsh b/home-manager/zsh/common/02-prompt.zsh similarity index 100% rename from modules/zsh/common/02-prompt.zsh rename to home-manager/zsh/common/02-prompt.zsh diff --git a/modules/zsh/common/03-completion.zsh b/home-manager/zsh/common/03-completion.zsh similarity index 100% rename from modules/zsh/common/03-completion.zsh rename to home-manager/zsh/common/03-completion.zsh diff --git a/modules/zsh/common/03-manydots.zsh b/home-manager/zsh/common/03-manydots.zsh similarity index 100% rename from modules/zsh/common/03-manydots.zsh rename to home-manager/zsh/common/03-manydots.zsh diff --git a/modules/zsh/common/04-bindkeys.zsh b/home-manager/zsh/common/04-bindkeys.zsh similarity index 100% rename from modules/zsh/common/04-bindkeys.zsh rename to home-manager/zsh/common/04-bindkeys.zsh diff --git a/modules/zsh/common/05-functions.zsh b/home-manager/zsh/common/05-functions.zsh similarity index 100% rename from modules/zsh/common/05-functions.zsh rename to home-manager/zsh/common/05-functions.zsh diff --git a/modules/zsh/common/05-home-manager.zsh b/home-manager/zsh/common/05-home-manager.zsh similarity index 100% rename from modules/zsh/common/05-home-manager.zsh rename to home-manager/zsh/common/05-home-manager.zsh diff --git a/modules/zsh/common/06-history.zsh b/home-manager/zsh/common/06-history.zsh similarity index 100% rename from modules/zsh/common/06-history.zsh rename to home-manager/zsh/common/06-history.zsh diff --git a/modules/zsh/common/07-zsh_hooks.zsh b/home-manager/zsh/common/07-zsh_hooks.zsh similarity index 100% rename from modules/zsh/common/07-zsh_hooks.zsh rename to home-manager/zsh/common/07-zsh_hooks.zsh diff --git a/modules/zsh/common/09-zsh_aliases.zsh b/home-manager/zsh/common/09-zsh_aliases.zsh similarity index 100% rename from modules/zsh/common/09-zsh_aliases.zsh rename to home-manager/zsh/common/09-zsh_aliases.zsh diff --git a/modules/zsh/common/10-adminer.zsh b/home-manager/zsh/common/10-adminer.zsh similarity index 100% rename from modules/zsh/common/10-adminer.zsh rename to home-manager/zsh/common/10-adminer.zsh diff --git a/modules/zsh/common/10-docker_aliases.zsh b/home-manager/zsh/common/10-docker_aliases.zsh similarity index 100% rename from modules/zsh/common/10-docker_aliases.zsh rename to home-manager/zsh/common/10-docker_aliases.zsh diff --git a/modules/zsh/common/10-git_aliases.zsh b/home-manager/zsh/common/10-git_aliases.zsh similarity index 100% rename from modules/zsh/common/10-git_aliases.zsh rename to home-manager/zsh/common/10-git_aliases.zsh diff --git a/modules/zsh/common/10-kubernetes_aliases.zsh b/home-manager/zsh/common/10-kubernetes_aliases.zsh similarity index 100% rename from modules/zsh/common/10-kubernetes_aliases.zsh rename to home-manager/zsh/common/10-kubernetes_aliases.zsh diff --git a/modules/zsh/common/10-templates.zsh b/home-manager/zsh/common/10-templates.zsh similarity index 100% rename from modules/zsh/common/10-templates.zsh rename to home-manager/zsh/common/10-templates.zsh diff --git a/modules/zsh/common/10-zsh_aliases_connections.zsh b/home-manager/zsh/common/10-zsh_aliases_connections.zsh similarity index 100% rename from modules/zsh/common/10-zsh_aliases_connections.zsh rename to home-manager/zsh/common/10-zsh_aliases_connections.zsh diff --git a/modules/zsh/common/11-aws.zsh b/home-manager/zsh/common/11-aws.zsh similarity index 100% rename from modules/zsh/common/11-aws.zsh rename to home-manager/zsh/common/11-aws.zsh diff --git a/modules/zsh/dingleberry/09-zsh_aliases.zsh b/home-manager/zsh/dingleberry/09-zsh_aliases.zsh similarity index 100% rename from modules/zsh/dingleberry/09-zsh_aliases.zsh rename to home-manager/zsh/dingleberry/09-zsh_aliases.zsh diff --git a/modules/zsh/dingleberry/10-ibus.zsh b/home-manager/zsh/dingleberry/10-ibus.zsh similarity index 100% rename from modules/zsh/dingleberry/10-ibus.zsh rename to home-manager/zsh/dingleberry/10-ibus.zsh diff --git a/modules/zsh/dingleberry/10-zsh_aliases_connections.zsh b/home-manager/zsh/dingleberry/10-zsh_aliases_connections.zsh similarity index 100% rename from modules/zsh/dingleberry/10-zsh_aliases_connections.zsh rename to home-manager/zsh/dingleberry/10-zsh_aliases_connections.zsh