This commit is contained in:
2024-02-12 14:48:27 -05:00
8 changed files with 257 additions and 39 deletions

62
machines/asahi/home.nix Normal file
View File

@@ -0,0 +1,62 @@
{ config, pkgs, ... }:
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "universelaptop";
home.homeDirectory = "/home/universelaptop";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "23.11"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = [
me-emacs
armcord
# TODO: Make home-manager module for loading x86_64 apps and automatically
# wrapping them in box64-asahi (page size change, like in Fedora repo)
# as well as, with override option, to enable support for box86/wine
];
services.nextcloud-client.enable;
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# # Building this configuration will create a copy of 'dotfiles/screenrc' in
# # the Nix store. Activating the configuration will then make '~/.screenrc' a
# # symlink to the Nix store copy.
# ".screenrc".source = dotfiles/screenrc;
# # You can also set the file content immediately.
# ".gradle/gradle.properties".text = ''
# org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000
# '';
};
# Home Manager can also manage your environment variables through
# 'home.sessionVariables'. If you don't want to manage your shell through Home
# Manager then you have to manually source 'hm-session-vars.sh' located at
# either
#
# ~/.nix-profile/etc/profile.d/hm-session-vars.sh
#
# or
#
# /etc/profiles/per-user/universelaptop/etc/profile.d/hm-session-vars.sh
#
home.sessionVariables = {
EDITOR = "emacs";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

View File

@@ -0,0 +1,29 @@
{config, pkgs, lib, ...}: {
# Nix-darwin does not link installed applications to the user environment. This means apps will not show up
# in spotlight, and when launched through the dock they come with a terminal window. This is a workaround.
# Upstream issue: https://github.com/LnL7/nix-darwin/issues/214
system.activationScripts.applications.text = lib.mkForce ''
echo "setting up /Applications..." >&2
applications="/Applications"
nix_apps="$applications/Nix Apps"
# Delete the directory to remove old links
rm -rf "$nix_apps"
mkdir -p "$nix_apps"
find ${config.system.build.applications}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read src; do
# Spotlight does not recognize symlinks, it will ignore directory we link to the applications folder.
# It does understand MacOS aliases though, a unique filesystem feature. Sadly they cannot be created
# from bash (as far as I know), so we use the oh-so-great Apple Script instead.
/usr/bin/osascript -e "
set fileToAlias to POSIX file \"$src\"
set applicationsFolder to POSIX file \"$nix_apps\"
tell application \"Finder\"
make new alias at applicationsFolder to fileToAlias
# This renames the alias; 'mpv.app alias' -> 'mpv.app'
set name of result to \"$(rev <<< "$src" | cut -d'/' -f1 | rev)\"
end tell
" 1>/dev/null
done
'';
}

View File

@@ -1,44 +1,51 @@
{ config, pkgs, inputs, ... }: let
in
{
imports = [
# Install Apps Detactable by Spotlight
./app-fix.nix
# Tiling Window Manager
./yabai.nix
# Shortcuts babe, not Automator
./skhd.nix
];
nix.registry.nixpkgs.flake = inputs.nixpkgs;
nixpkgs.config.allowUnfree = true;
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
nix.package = pkgs.nixUnstable;
nix.settings.auto-optimise-store = false;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
users.users.universelaptop = {
name = "universelaptop";
home = "/Users/universelaptop";
};
home-manager.users.universelaptop = { pkgs, ... }: {
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
programs.bash.enable = true;
programs.zsh = {
enable = true;
initExtra = ''
PATH=$HOME/flutter/bin:$PATH
DYLD_LIBRARY_PATH=MR/v99/runtime/maci64:MR/v99/sys/os/maci64:MR/v99/bin/maci64:$DYLD_LIBRARY_PATH
flakify() {
eval "$(direnv hook bash)"
if [ ! -e flake.nix ]; then
nix flake new -t github:nix-community/nix-direnv .
fi
$EDITOR flake.nix
}
'';
shellAliases = {
ssh = "kitty +kitten ssh";
sshu = "ssh universe@syzygial.cc -p 7000";
tailscale =
"/Applications/Tailscale.app/Contents/MacOS/Tailscale";
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.universelaptop = { pkgs, ... }: {
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
programs.bash.enable = true;
programs.zsh = {
enable = true;
initExtra = ''
if [[ $(uname -m) == 'arm64' ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
'';
shellAliases = {
ssh = "kitty +kitten ssh";
sshu = "ssh universe";
};
};
home.stateVersion = "22.05";
};
home.stateVersion = "22.05";
};
environment.variables = {
EDITOR = "emacs";
};
nixpkgs.config.allowUnfree = true;
environment.systemPackages = (with pkgs; [
mac-emacs
@@ -57,14 +64,36 @@ flakify() {
cbqn-replxx
podman
qemu
]);
# Or any other shell you're using. };
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
nix.package = pkgs.nixUnstable;
nix.settings.auto-optimise-store = false;
# Graphical Apps:
rectangle
tailscale
discord
slack
# TODO: Consider using Yabai??
]);
homebrew = {
# It is not installed by nix, for now, so manually install:
# https://brew.sh/
enable = true;
onActivation = {
cleanup = "uninstall";
};
# Graphical apps to install through homebrew instead of nixpkgs
casks = [
"firefox"
"nextcloud"
"tidal"
"bitwarden"
];
# Apps to install outside of nix for when wanting to test/run
# things that... aren't used by other people who use nix, like
# python apps (which is why poetry is there)
brews = [
"poetry"
];
};
# Create /etc/zshrc that loads the nix-darwin environment.
programs.bash.enable = true; # default shell on catalina
programs.zsh.enable = true; # default shell on catalina

View File

@@ -0,0 +1,30 @@
{config, pkgs, lib, ...}: {
environment.systemPackages = with pkgs; [
sketchybar
];
services.sketchybar = {
enable = true;
config = ''
##### Bar Appearance #####
# Configuring the general appearance of the bar, these are only some of the
# options available. For all options see:
# https://felixkratz.github.io/SketchyBar/config/bar
# If you are looking for other colors, see the color picker:
# https://felixkratz.github.io/SketchyBar/config/tricks#color-picker
sketchybar --bar height=32 \
blur_radius=30 \
position=top \
sticky=off \
padding_left=10 \
padding_right=10 \
color=0x15ffffff
##### Finalizing Setup #####
# The below command is only needed at the end of the initial configuration to
# force all scripts to run the first time, it should never be run in an item script.
sketchybar --update
'';
};
}

View File

@@ -0,0 +1,9 @@
{config, pkgs, lib, ...}: {
services.skhd = {
enable = true;
skhdConfig = ''
cmd + shift - e : open ${pkgs.mac-emacs}/Applications/Emacs.app
cmd + shift + ctrl - e : open ${pkgs.kitty}/Applications/Kitty.app
'';
};
}

View File

@@ -0,0 +1,43 @@
{config, pkgs, lib, ...}: {
imports = [
# Custom Bar
# ./sketchybar.nix
# TODO: Customize Bar Later
];
environment.systemPackages = with pkgs; [
yabai
];
services.yabai = {
enable = true;
config = {
layout = "bsp";
focus_follows_mouse = "autofocus";
auto_balance = "on";
top_padding = 5;
bottom_padding = 5;
left_padding = 5;
right_padding = 5;
window_gap = 5;
};
extraConfig = ''
yabai -m rule --add app='System Settings' manage=off
yabai -m rule --add app='Boot Camp Assistant' manage=off
yabai -m rule --add app='System Information' manage=off
'';
};
# https://github.com/IvarWithoutBones/dotfiles/blob/main/modules/darwin/yabai/default.nix
# The scripting addition needs root access to load, which we want to do automatically when logging in.
# Disable the password requirement for it so that a service can do so without user interaction.
environment.etc."sudoers.d/yabai-load-sa".text = ''
universelaptop ALL = (root) NOPASSWD: sha256:${builtins.hashFile "sha256" "${pkgs.yabai}/bin/yabai"} ${pkgs.yabai}/bin/yabai
'';
launchd.user.agents.yabai-load-sa = {
path = [ pkgs.yabai config.environment.systemPath ];
command = "/usr/bin/sudo ${pkgs.yabai}/bin/yabai --load-sa";
serviceConfig.RunAtLoad = true;
};
}