feat: Nix flake build for Darwin #23

Open
aniva wants to merge 16 commits from system/darwin into main
9 changed files with 341 additions and 9 deletions

View File

@ -1,10 +1,27 @@
# Desktop Environment for MacOS
# Configuration for MacOS
* Installation
Install Homebrew.
Install
- [[https://brew.sh/][Homebrew]]
- [[https://lix.systems/install/][Lix]]
* Desktop Manager
and use ~nix-darwin~ to install the system flake
#+begin_src sh
nix run nix-darwin -- switch --flake ~/.config/nix-darwin
#+end_src
To update the system after flake changes,
#+begin_src sh
darwin-rebuild switch --flake .
#+end_src
Optionally, run
#+begin_src
nix-collect-garbage --delete-old
#+end_src
* Desktop Environment
- [[https://github.com/koekeishiya/yabai][yabai]]: Window manager, see [[https://github.com/koekeishiya/yabai/wiki][setup guide]]
@ -18,7 +35,4 @@ Install Homebrew.
~fn~ key is used as the workspace leader key and ~cmd~ key is used as window
leader key. The reason is that ~fn~ and arrow key combinations disable arrow
keys for other applications.
- ~Karabiner-elements~: Install and remap Caps Lock to Meh key. This is the
master key for window operations in ~yabai~.
- [[https://github.com/felixhageloh/uebersicht][Uebersicht]]: Widgets manager
- [[https://github.com/Jean-Tinland/simple-bar][simple-bar]]: Status bar (see page for installation guide)
- Sketchybar: Status Bar

View File

@ -160,6 +160,23 @@ Modifications to the default key bindings to mimic spacemacs
(map! :nvi "C" nil) ; remove this one weird binding
(map! "<f12>" #'toggle-input-method)
; Remap JIS yen key to backslash
(global-set-key (kbd "M-¥") (kbd "\\"))
(global-set-key (kbd "M-|") (kbd "|"))
(global-set-key (kbd "C-M-¥") (kbd "C-\\"))
#+end_src
** Scroll
#+begin_src emacs-lisp :tangle packages.el
(use-package ultra-scroll
;:load-path "~/code/emacs/ultra-scroll" ; if you git clone'd instead of package-vc-install
:init
(setq scroll-conservatively 101 ; important!
scroll-margin 0)
:config
(ultra-scroll-mode 1))
#+end_src
** Font settings
@ -263,6 +280,9 @@ numbers are disabled. For relative line numbers, set this to ~relative~.
css-indent-offset 3
sh-indentation 3
nxml-indent-offset 3
tex-indent-arg 3
tex-indent-item 3
tex-indent-basic 3
)
#+end_src
@ -648,6 +668,24 @@ Add the necessary hooks for LilyPond mode.
(setq rustic-indent-offset standard-indent))
#+end_src
*** Typst
#+begin_src emacs-lisp :tangle packages.el
(package! typst-ts-mode :recipe (
:type git :host codeberg :repo "meow_king/typst-ts-mode"))
#+end_src
#+begin_src emacs-lisp
(map! :after typst-ts-mode
:localleader
:map typst-ts-mode-map
:desc "Preview" "p" #'typst-ts-preview
:desc "Compile" "c" #'typst-ts-compile
:desc "Compile & Preview" "P" #'typst-ts-compile-and-preview
:desc "Watch start" "w" #'typst-ts-watch-start
:desc "Watch stop" "W" #'typst-ts-watch-stop
)
#+end_src
** Tools
*** Language Server Protocol (LSP)

View File

@ -146,9 +146,9 @@
(julia +lsp) ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script)
(latex +latexmk +lsp) ; writing papers in Emacs has never been so fun
;;lean ; for folks with too much to prove
;lean ; for folks with too much to prove
ledger ; be audit you can be
;;lua ; one-based indices? one-based indices
lua ; one-based indices? one-based indices
markdown ; writing docs for people to ignore
;;nim ; python + lisp at the speed of c
nix ; I hereby declare "nix geht mehr!"

48
flake.lock Normal file
View File

@ -0,0 +1,48 @@
{
"nodes": {
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs-darwin"
]
},
"locked": {
"lastModified": 1731642829,
"narHash": "sha256-vG+O2RZRzYZ8BUMNNJ+BLSj6PUoGW7taDQbp6QNJ3Xo=",
"owner": "LnL7",
"repo": "nix-darwin",
"rev": "f86f158efd4bab8dce3e207e4621f1df3a760b7a",
"type": "github"
},
"original": {
"owner": "LnL7",
"repo": "nix-darwin",
"type": "github"
}
},
"nixpkgs-darwin": {
"locked": {
"lastModified": 1733326450,
"narHash": "sha256-hBG6Ix5ZzXCJoanrPOLtQRalYv6nnDu9AZeamRfjKJ8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "f9ef77eb704d063bfbff7f04531a0b325cc1a18f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-24.11-darwin",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nix-darwin": "nix-darwin",
"nixpkgs-darwin": "nixpkgs-darwin"
}
}
},
"root": "root",
"version": 7
}

32
flake.nix Normal file
View File

@ -0,0 +1,32 @@
{
description = "Leni Aniva's Systems";
inputs = {
nixpkgs-darwin.url = "github:NixOS/nixpkgs/nixpkgs-24.11-darwin";
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
};
outputs = inputs@{ self, nixpkgs-darwin, nix-darwin }: {
darwinConfigurations = {
tetrahedrite = nix-darwin.lib.darwinSystem {
modules = [
./nix-darwin/configuration.nix
{
nixpkgs.hostPlatform = "x86_64-darwin";
}
];
};
sphalerite = nix-darwin.lib.darwinSystem {
modules = [
./nix-darwin/configuration.nix
{
nixpkgs.hostPlatform = "aarch64-darwin";
}
];
};
};
};
}

View File

@ -0,0 +1,70 @@
{ config, pkgs, ... }: {
imports = [ ./homebrew.nix ./yabai-skhd.nix ];
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment = {
variables = {
EDITOR = "vim";
VISUAL = "vim";
};
systemPackages = with pkgs; [
vim
ripgrep
fd
gnupg
direnv
nix-direnv
rustup
elan
poetry
(import ./tex.nix { inherit pkgs; })
cmake
nodejs_23
pnpm
typst
ispell
biber
lilypond-unstable-with-fonts
# Media
imagemagick
fontconfig
pass
python312Packages.pygments
];
};
fonts.packages = with pkgs; [
lilypond-with-fonts
];
# Auto upgrade nix package and the daemon service.
services = {
nix-daemon.enable = true;
#karabiner-elements.enable = true;
sketchybar = {
enable = true;
};
};
nix = {
package = pkgs.nix;
settings.experimental-features = "nix-command flakes";
};
# Enable alternative shell support in nix-darwin.
programs.fish.enable = true;
# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system = {
stateVersion = 5;
defaults = {
dock = {
autohide = true;
orientation = "bottom";
};
};
};
}

71
nix-darwin/homebrew.nix Normal file
View File

@ -0,0 +1,71 @@
{ ... }:
{
homebrew = {
enable = true;
onActivation = {
cleanup = "zap";
autoUpdate = false;
upgrade = false;
};
brews = [
"pinentry-mac"
# Building tools
"libtool"
"pkgconf"
"autoconf"
"poppler"
"automake"
];
casks = [
# System monitoring
"grandperspective"
"lulu"
"xrg"
# Desktop Environment
"karabiner-elements"
"kando"
# Inputs
"wacom-tablet"
"ukelele"
# Multimedia
"vlc"
"darktable"
"adobe-dng-converter"
# Communications
"signal"
"slack"
"discord"
"zoom"
"zulip"
"tuta-mail"
# Browsing
"firefox"
"zotero"
"anki"
"skim"
# Editors
"emacs-mac"
"arduino-ide"
"blender"
"inkscape"
# Terminal
"iterm2"
# Fonts
"font-noto-mono"
"font-source-code-pro"
];
taps = [
"koekeishiya/formulae"
"railwaycat/emacsmacport"
];
};
}

46
nix-darwin/tex.nix Normal file
View File

@ -0,0 +1,46 @@
{ pkgs, ... }:
pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-medium
latexmk
# Symbols
amsmath
cancel
hyphenat
xstring
mnsymbol
scalerel
# Typesetting
pdfcol
changepage
upquote
anyfontsize
# Misc
svg
datetime2
makecell
tcolorbox
type1cm
environ
minted
transparent
# Graphics
tikzmark
tikzfill
pgfplots
# Classes
llncs
beamerposter
# Fonts
gnu-freefont
raleway
lato
biblatex
;
}

13
nix-darwin/yabai-skhd.nix Normal file
View File

@ -0,0 +1,13 @@
{ ... }:
{
services = {
yabai = {
enable = true;
extraConfig = builtins.readFile ../yabai/yabairc;
};
skhd = {
enable = true;
skhdConfig = builtins.readFile ../skhd/skhdrc;
};
};
}