darwin: split config into different parts

This commit is contained in:
Guanran Wang 2023-10-15 12:38:49 +08:00
parent f7d4878472
commit c60dda203f
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8
9 changed files with 100 additions and 80 deletions

View file

@ -3,9 +3,8 @@
{ {
imports = [ imports = [
./networking ./networking
./packages
./main.nix
./input.nix
./nix ./nix
./packages
./system
]; ];
} }

View file

@ -1,11 +0,0 @@
{ ... }:
{
system.defaults = {
".GlobalPreferences"."com.apple.mouse.scaling" = "-1"; # Disable mouse acceleration
trackpad = {
Clicking = true;
TrackpadRightClick = true;
};
};
}

View file

@ -23,6 +23,9 @@
services.nix-daemon.enable = true; services.nix-daemon.enable = true;
nix.package = pkgs.nix; nix.package = pkgs.nix;
# 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. # Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog # $ darwin-rebuild changelog
system.stateVersion = 4; system.stateVersion = 4;

53
darwin/packages/core.nix Normal file
View file

@ -0,0 +1,53 @@
{ pkgs, ... }:
{
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
#environment.systemPackages = with pkgs; [
# neovim
# vscode
#];
# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
programs.fish.enable = true;
services = {
yabai = {
enable = true;
enableScriptingAddition = true;
config = {
layout = "bsp";
mouse_modifier = "fn";
# very broken on slow cpu
#focus_follows_mouse = "autoraise";
#mouse_follows_focus = "on";
top_padding = 10;
bottom_padding = 10;
left_padding = 10;
right_padding = 10;
window_gap = 4;
};
};
skhd = {
enable = true;
skhdConfig = ''
cmd - return : open -n ${pkgs.alacritty}/Applications/Alacritty.app
cmd - 1 : yabai -m space --focus 1 # Focus space
cmd - 2 : yabai -m space --focus 2
cmd - 3 : yabai -m space --focus 3
cmd - 4 : yabai -m space --focus 4
cmd - 5 : yabai -m space --focus 5
shift + cmd - 1 : yabai -m window --space 1 # Send to space
shift + cmd - 2 : yabai -m window --space 2
shift + cmd - 3 : yabai -m window --space 3
shift + cmd - 4 : yabai -m window --space 4
shift + cmd - 5 : yabai -m window --space 5
'';
};
};
}

View file

@ -2,6 +2,9 @@
{ {
imports = [ imports = [
./core.nix
./fonts.nix
./homebrew.nix ./homebrew.nix
./unfree.nix
]; ];
} }

View file

@ -0,0 +1,7 @@
{ pkgs, ... }:
{
fonts.fonts = with pkgs; [
(nerdfonts.override { fonts = [ "FiraCode" "JetBrainsMono" ]; })
];
}

View file

@ -0,0 +1,9 @@
{ lib, ... }:
{
# Allow unfree applications
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"spotify"
"keka"
];
}

View file

@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./system.nix
];
}

View file

@ -1,68 +1,6 @@
{ lib, pkgs, ... }: { ... }:
{ {
fonts.fonts = with pkgs; [
(nerdfonts.override { fonts = [ "FiraCode" "JetBrainsMono" ]; })
];
# Allow unfree applications
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
#"vscode"
"spotify"
"keka" # i thought it was opensource
];
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
#environment.systemPackages = with pkgs; [
# neovim
# vscode
#];
# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell on catalina
programs.fish.enable = true;
services = {
yabai = {
enable = true;
enableScriptingAddition = true;
config = {
layout = "bsp";
mouse_modifier = "fn";
# very broken on slow cpu
#focus_follows_mouse = "autoraise";
#mouse_follows_focus = "on";
top_padding = 10;
bottom_padding = 10;
left_padding = 10;
right_padding = 10;
window_gap = 4;
};
};
skhd = {
enable = true;
skhdConfig = ''
cmd - return : open -n ${pkgs.alacritty}/Applications/Alacritty.app
cmd - 1 : yabai -m space --focus 1 # Focus space
cmd - 2 : yabai -m space --focus 2
cmd - 3 : yabai -m space --focus 3
cmd - 4 : yabai -m space --focus 4
cmd - 5 : yabai -m space --focus 5
shift + cmd - 1 : yabai -m window --space 1 # Send to space
shift + cmd - 2 : yabai -m window --space 2
shift + cmd - 3 : yabai -m window --space 3
shift + cmd - 4 : yabai -m window --space 4
shift + cmd - 5 : yabai -m window --space 5
'';
};
};
system.defaults = { system.defaults = {
# Apple... Do I really have to change literally # Apple... Do I really have to change literally
# every setting in macOS to make it actually usable. # every setting in macOS to make it actually usable.
@ -71,6 +9,15 @@
# #
# NOTE: default of those options is `null` (unmanaged) # NOTE: default of those options is `null` (unmanaged)
# https://github.com/mathiasbynens/dotfiles/blob/main/.macos for references # https://github.com/mathiasbynens/dotfiles/blob/main/.macos for references
### Inputs
".GlobalPreferences"."com.apple.mouse.scaling" = "-1"; # Disable mouse acceleration
trackpad = {
Clicking = true;
TrackpadRightClick = true;
};
### Finder
finder = { finder = {
_FXShowPosixPathInTitle = false; _FXShowPosixPathInTitle = false;
AppleShowAllExtensions = true; AppleShowAllExtensions = true;
@ -83,11 +30,15 @@
ShowPathbar = true; ShowPathbar = true;
ShowStatusBar = false; ShowStatusBar = false;
}; };
### Login window
loginwindow = { loginwindow = {
autoLoginUser = "Off"; autoLoginUser = "Off";
DisableConsoleAccess = true; DisableConsoleAccess = true;
GuestEnabled = false; GuestEnabled = false;
}; };
### Finder menu
menuExtraClock = { menuExtraClock = {
IsAnalog = false; IsAnalog = false;
Show24Hour = false; Show24Hour = false;
@ -97,6 +48,8 @@
ShowDayOfWeek = true; ShowDayOfWeek = true;
ShowSeconds = false; ShowSeconds = false;
}; };
### Misc
NSGlobalDomain = { NSGlobalDomain = {
"com.apple.keyboard.fnState" = true; "com.apple.keyboard.fnState" = true;
"com.apple.mouse.tapBehavior" = 1; "com.apple.mouse.tapBehavior" = 1;
@ -143,7 +96,4 @@
PMPrintingExpandedStateForPrint2 = true; PMPrintingExpandedStateForPrint2 = true;
}; };
}; };
# Set Git commit hash for darwin-version.
#system.configurationRevision = self.rev or self.dirtyRev or null;
} }