Refactoring

This commit is contained in:
Lukas Cech 2025-01-07 15:00:13 +01:00
parent a77b0a99e1
commit 2f2548f83d
27 changed files with 174 additions and 107 deletions

134
darwin/common.nix Normal file
View File

@ -0,0 +1,134 @@
{
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;
};
};
}

View File

@ -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"
];
};
};
}

115
flake.nix
View File

@ -29,98 +29,6 @@
"aarch64-linux" "aarch64-linux"
"aarch64-darwin" "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 in
{ {
lib = { lib = {
@ -160,8 +68,8 @@
inherit pkgs; inherit pkgs;
modules = [ modules = [
./modules/common.nix ./home-manager/common.nix
./devices/becky-dingleberry.nix ./home-manager/becky-dingleberry.nix
]; ];
}; };
}; };
@ -173,18 +81,13 @@
# darwin-rebuild switch --flake ~/.config/nix # darwin-rebuild switch --flake ~/.config/nix
lcech-mac = nix-darwin.lib.darwinSystem { lcech-mac = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin"; system = "aarch64-darwin";
specialArgs = {
self = self;
};
modules = [ modules = [
mac-app-util.darwinModules.default mac-app-util.darwinModules.default
darwin-common ./darwin/common.nix
{ ./darwin/lcech-mac-veracode.nix
# brew install --cask
# these need to be updated manually
homebrew.casks = [
"ghostty"
"spotify"
"keepassxc"
];
}
home-manager.darwinModules.home-manager home-manager.darwinModules.home-manager
{ {
home-manager = { home-manager = {
@ -192,8 +95,8 @@
useUserPackages = true; useUserPackages = true;
users.lcech.imports = [ users.lcech.imports = [
mac-app-util.homeManagerModules.default mac-app-util.homeManagerModules.default
./modules/common.nix ./home-manager/common.nix
./devices/lcech-mac-veracode.nix ./home-manager/lcech-mac-veracode.nix
]; ];
}; };

View File

@ -30,6 +30,8 @@ in
text = '' text = ''
theme = "catppuccin-mocha" theme = "catppuccin-mocha"
font-size = 14 font-size = 14
window-width = 9999
window-height = 9999
''; '';
}; };
}; };