Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conf: add mars (and nix-darwin) #28

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions darwin/common/aerospace.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{ pkgs, ... }:
{
services.aerospace = {
enable = false;
package = pkgs.aerospace;
settings = {
enable-normalization-opposite-orientation-for-nested-containers = true;
enable-normalization-flatten-containers = true;
on-focused-monitor-changed = [ "move-mouse monitor-lazy-center" ];
key-mapping.preset = "qwerty";

gaps = {
outer.top = 8;
outer.right = 8;
outer.bottom = 8;
outer.left = 8;
inner.horizontal = 8;
inner.vertical = 8;
};

mode.main.binding = {
alt-enter = "exec-and-forget open -n '/Applications/Nix Apps/Alacritty.app'";
alt-backtick = "exec-and-forget /Applications/1Password.app/Contents/MacOS/1Password --quick-access";
alt-f = "fullscreen";

alt-1 = "workspace 1";
alt-2 = "workspace 2";
alt-3 = "workspace 3";
alt-4 = "workspace 4";
alt-5 = "workspace 5";
alt-6 = "workspace 6";
alt-7 = "workspace 7";
alt-8 = "workspace 8";
alt-9 = "workspace 9";

alt-shift-1 = "move-node-to-workspace 1";
alt-shift-2 = "move-node-to-workspace 2";
alt-shift-3 = "move-node-to-workspace 3";
alt-shift-4 = "move-node-to-workspace 4";
alt-shift-5 = "move-node-to-workspace 5";
alt-shift-6 = "move-node-to-workspace 6";
alt-shift-7 = "move-node-to-workspace 7";
alt-shift-8 = "move-node-to-workspace 8";
alt-shift-9 = "move-node-to-workspace 9";

# See: https://nikitabobko.github.io/AeroSpace/commands#layout
alt-a = "layout tiles horizontal vertical";
alt-comma = "layout accordion horizontal vertical";
alt-shift-space = "layout floating tiling";

# alt-h = "split horizontal";
# alt-v = "split vertical";

# See: https://nikitabobko.github.io/AeroSpace/commands#focus
alt-left = "focus left";
alt-down = "focus down";
alt-up = "focus up";
alt-right = "focus right";

# See: https://nikitabobko.github.io/AeroSpace/commands#move
alt-shift-left = "move left";
alt-shift-down = "move down";
alt-shift-up = "move up";
alt-shift-right = "move right";

# See: https://nikitabobko.github.io/AeroSpace/commands#resize
alt-shift-minus = "resize smart -50";
alt-shift-equal = "resize smart +50";

# See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth
alt-tab = "workspace-back-and-forth";

alt-r = "mode resize";
alt-shift-semicolon = "mode service";
};

mode.resize.binding = {
# Resize the window
left = "resize width -50";
up = "resize height +50";
down = "resize height -50";
right = "resize width +50";
enter = "mode main";
esc = "mode main";
};

mode.service.binding = {
esc = "mode main";
r = [
"flatten-workspace-tree"
"mode main"
];
f = [
"layout floating tiling"
"mode main"
];

left = [
"join-with left"
"mode main"
];
right = [
"join-with right"
"mode main"
];
up = [
"join-with up"
"mode main"
];
down = [
"join-with down"
"mode main"
];
};

on-window-detected = [ ];
};
};
}
9 changes: 9 additions & 0 deletions darwin/common/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ ... }:
{
imports = [
./fonts.nix
./macos-defaults.nix
./packages.nix
./ssh-agent.nix
];
}
13 changes: 13 additions & 0 deletions darwin/common/fonts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ self, pkgs, ... }:
let
theme = import "${self}/lib/theme" { inherit pkgs; };
in
{
fonts = {
packages = [
theme.fonts.default.package
theme.fonts.iconFont.package
theme.fonts.monospace.package
];
};
}
105 changes: 105 additions & 0 deletions darwin/common/macos-defaults.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{ hostname, ... }:
{
system.defaults = {
CustomUserPreferences = {
"com.apple.AdLib" = {
allowApplePersonalizedAdvertising = false;
};
"com.apple.controlcenter" = {
BatteryShowPercentage = true;
};
"com.apple.desktopservices" = {
# Avoid creating .DS_Store files on network or USB volumes
DSDontWriteNetworkStores = true;
DSDontWriteUSBStores = true;
};
"com.apple.finder" = {
_FXSortFoldersFirst = true;
FXDefaultSearchScope = "SCcf"; # Search current folder by default
ShowExternalHardDrivesOnDesktop = false;
ShowHardDrivesOnDesktop = false;
ShowMountedServersOnDesktop = false;
ShowRemovableMediaOnDesktop = false;
};
# Prevent Photos from opening automatically
"com.apple.ImageCapture".disableHotPlug = true;
"com.apple.screencapture" = {
location = "~/Pictures/Screenshots";
type = "png";
};
"com.apple.SoftwareUpdate" = {
AutomaticCheckEnabled = true;
# Check for software updates daily, not just once per week
ScheduleFrequency = 1;
# Download newly available updates in background
AutomaticDownload = 0;
# Install System data files & security updates
CriticalUpdateInstall = 1;
};
"com.apple.TimeMachine".DoNotOfferNewDisksForBackup = true;
# Turn on app auto-update
"com.apple.commerce".AutoUpdate = true;
};
NSGlobalDomain = {
AppleICUForce24HourTime = true;
# AppleInterfaceStyle = "Dark";
# AppleInterfaceStyleSwitchesAutomatically = false;
AppleMeasurementUnits = "Centimeters";
AppleMetricUnits = 1;
AppleTemperatureUnit = "Celsius";
InitialKeyRepeat = 15;
KeyRepeat = 2;
NSAutomaticCapitalizationEnabled = false;
NSAutomaticDashSubstitutionEnabled = false;
NSAutomaticPeriodSubstitutionEnabled = false;
NSAutomaticQuoteSubstitutionEnabled = false;
NSAutomaticSpellingCorrectionEnabled = true;
NSNavPanelExpandedStateForSaveMode = true;
NSNavPanelExpandedStateForSaveMode2 = true;
NSWindowShouldDragOnGesture = true;
# _HIHideMenuBar = true;
};
SoftwareUpdate = {
AutomaticallyInstallMacOSUpdates = false;
};
dock = {
orientation = "bottom";
# persistent-apps = [
# "/System/Applications/Launchpad.app"
# ];
# show-recents = false;
# tilesize = 48;
# Disable hot corners
wvous-bl-corner = 1;
wvous-br-corner = 1;
wvous-tl-corner = 1;
wvous-tr-corner = 1;
};
finder = {
_FXShowPosixPathInTitle = true;
FXEnableExtensionChangeWarning = false;
FXPreferredViewStyle = "Nlsv";
AppleShowAllExtensions = true;
AppleShowAllFiles = true;
QuitMenuItem = true;
ShowPathbar = true;
ShowStatusBar = true;
};
menuExtraClock = {
ShowAMPM = false;
ShowDate = 1; # Always
Show24Hour = true;
ShowSeconds = false;
};
screensaver = {
askForPassword = true;
askForPasswordDelay = 300;
};
smb.NetBIOSName = hostname;
trackpad = {
Clicking = true;
TrackpadRightClick = true; # enable two finger right click
# TrackpadThreeFingerDrag = true; # enable three finger drag
};
};
}
49 changes: 49 additions & 0 deletions darwin/common/packages.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
pkgs,
lib,
self,
...
}:
let
inherit ((import "${self}/host/common/base/packages.nix" { inherit pkgs lib; })) basePackages;
in
{
homebrew = {
brews = [ ];
casks = [
"1password"
"1password-cli"
"bambu-studio"
"bartender"
"easy-move+resize"
"iterm2"
"google-chrome"
"obsidian"
"rambox"
"raycast"
"signal"
"soundsource"
"sublime-merge"
"tailscale"
"todoist"
"visual-studio-code"
"vlc"
"zen-browser"
"zoom"
];
masApps = { };
taps = [ ];
};

environment.systemPackages =
basePackages
++ (with pkgs; [
coreutils-full
gnugrep
gnused
m-cli
mas
plistwatch
yubikey-manager
]);
}
9 changes: 9 additions & 0 deletions darwin/common/scripts/build-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# if nh-home is in the PATH then use it
if command -v nh-home &> /dev/null; then
nh-home build
else
nix run nixpkgs#home-manager -- build --flake "$HOME/nixos-config" -L
fi
build-host
13 changes: 13 additions & 0 deletions darwin/common/scripts/build-host.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

HOST=$(hostname)
if [ -e ~/nixos-config ]; then
all_cores=$(nproc)
build_cores=$(printf "%.0f" "$(echo "${all_cores} * 0.75" | bc)")
echo "Building nix-darwin ❄️ with ${build_cores} cores"
pushd ~/nixos-config
nom build ".#darwinConfigurations.${HOST}.config.system.build.toplevel" --cores "${build_cores}"
popd
else
echo "ERROR! No nix-config found in ~/nixos-config"
fi
54 changes: 54 additions & 0 deletions darwin/common/scripts/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{ pkgs, ... }:
let
build-all = pkgs.writeShellApplication {
name = "build-all";
runtimeInputs = with pkgs; [
coreutils-full
];
text = builtins.readFile ./build-all.sh;
};

build-host = pkgs.writeShellApplication {
name = "build-host";
runtimeInputs = with pkgs; [
bc
coreutils-full
nix-output-monitor
];
text = builtins.readFile ./build-host.sh;
};

install-homebrew = pkgs.writeShellApplication {
name = "install-homebrew";
runtimeInputs = with pkgs; [
curl
];
text = builtins.readFile ./install-homebrew.sh;
};

switch-all = pkgs.writeShellApplication {
name = "switch-all";
runtimeInputs = with pkgs; [
coreutils-full
];
text = builtins.readFile ./switch-all.sh;
};

switch-host = pkgs.writeShellApplication {
name = "switch-host";
runtimeInputs = with pkgs; [
bc
coreutils-full
];
text = builtins.readFile ./switch-host.sh;
};
in
{
environment.systemPackages = [
build-all
build-host
install-homebrew
switch-all
switch-host
];
}
3 changes: 3 additions & 0 deletions darwin/common/scripts/install-homebrew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
9 changes: 9 additions & 0 deletions darwin/common/scripts/switch-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

# if nh-home is in the PATH then use it
if command -v nh-home &> /dev/null; then
nh-home build
else
nix run nixpkgs#home-manager -- switch --flake "$HOME/nixos-config" -L
fi
switch-host
Loading
Loading