(mirror) personal dotfiles github.com/crescentrose/dotfiles

feat: port macOS configuration to Nix

+208 -32
+1 -4
.gitignore
··· 1 - config/vim/.netrwhist 2 - config/kitty/current-theme.conf 3 - tmux/plugins 4 - Brewfile.lock.json 1 + .DS_Store
+28 -3
README.md
··· 1 1 # crescentrose's dotfiles 2 2 3 - 4 3 ![screenshot](./resources/screenshot-clean.png) 5 4 6 5 ![screenshot](./resources/screenshot-dirty.png) 7 6 8 7 ## Setup 9 8 9 + There are two variants: a pure NixOS variant with a custom desktop shell, and a 10 + macOS variant that shares a small part of the command-line configuration for 11 + consistency with my work machine. 12 + 13 + ### NixOS 14 + 10 15 This is a standard Nix flake. so on a NixOS system, running `sudo nixos-rebuild 11 16 --flake ./nixos#starlight switch` should do the trick. Note that you will need a 12 17 handful of _secrets_ - refer to the flake files for details. Also, the wallpaper ··· 14 19 the artists - find your own wallpapers! Improving the setup experience is on my 15 20 to-do list, but it's not yet ready. 16 21 17 - Note that this set-up is tweaked for my desktop PC and is currently not very 18 - modular or extensible. Improving this is also on my to-do list. 22 + This set-up is tweaked for my desktop PC and is currently not very modular or 23 + extensible. Improving this is also on my to-do list. 24 + 25 + ### macOS 26 + 27 + The macOS variant assumes [Determinate Nix](https://determinate.systems/nix/) 28 + as it has a better setup experience and plays better with various corporate 29 + tools. 30 + 31 + In addition to Determinate Nix, you should also set up [Homebrew](https://brew.sh/). 32 + 33 + For initial set-up, run: 34 + 35 + ```sh 36 + sudo nix run nix-darwin/master#darwin-rebuild -- switch --flake . 37 + ``` 38 + 39 + Afterwards, you can use `darwin-rebuild` to apply changes: 40 + 41 + ```sh 42 + sudo darwin-rebuild switch --flake . 43 + ```
+22
flake.lock
··· 162 162 "type": "github" 163 163 } 164 164 }, 165 + "nix-darwin": { 166 + "inputs": { 167 + "nixpkgs": [ 168 + "nixpkgs" 169 + ] 170 + }, 171 + "locked": { 172 + "lastModified": 1767028240, 173 + "narHash": "sha256-0/fLUqwJ4Z774muguUyn5t8AQ6wyxlNbHexpje+5hRo=", 174 + "owner": "nix-darwin", 175 + "repo": "nix-darwin", 176 + "rev": "c31afa6e76da9bbc7c9295e39c7de9fca1071ea1", 177 + "type": "github" 178 + }, 179 + "original": { 180 + "owner": "nix-darwin", 181 + "ref": "master", 182 + "repo": "nix-darwin", 183 + "type": "github" 184 + } 185 + }, 165 186 "nixos-hardware": { 166 187 "locked": { 167 188 "lastModified": 1767070591, ··· 252 273 "inputs": { 253 274 "elephant": "elephant", 254 275 "home-manager": "home-manager", 276 + "nix-darwin": "nix-darwin", 255 277 "nixos-hardware": "nixos-hardware", 256 278 "nixpkgs": "nixpkgs_2", 257 279 "ragenix": "ragenix",
+23 -4
flake.nix
··· 26 26 url = "github:yaxitech/ragenix"; 27 27 inputs.nixpkgs.follows = "nixpkgs"; 28 28 }; 29 + 30 + nix-darwin = { 31 + url = "github:nix-darwin/nix-darwin/master"; 32 + inputs.nixpkgs.follows = "nixpkgs"; 33 + }; 29 34 }; 30 35 31 36 outputs = ··· 34 39 nixos-hardware, 35 40 nixpkgs, 36 41 ragenix, 42 + nix-darwin, 37 43 ... 38 44 }: 39 - let 40 - system = "x86_64-linux"; 41 - in 42 45 { 43 46 nixosConfigurations = { 44 47 starlight = nixpkgs.lib.nixosSystem { 45 - inherit system; 48 + system = "x86_64-linux"; 46 49 modules = [ 47 50 ./machines/starlight 48 51 nixos-hardware.nixosModules.common-pc ··· 55 58 { 56 59 home-manager = { 57 60 users.ivan = import ./home/_home.nix; 61 + extraSpecialArgs = inputs; 62 + }; 63 + } 64 + ]; 65 + }; 66 + }; 67 + 68 + darwinConfigurations = { 69 + work = nix-darwin.lib.darwinSystem { 70 + modules = [ 71 + ./machines/work 72 + home-manager.darwinModules.home-manager 73 + { 74 + home-manager = { 75 + users."ivan.ostric" = import ./home/_work.nix; 76 + backupFileExtension = ".before-nix-darwin"; 58 77 extraSpecialArgs = inputs; 59 78 }; 60 79 }
+9 -5
home/_work.nix
··· 1 - { pkgs, ... }: 2 1 { 3 2 # only import the subset supported by macOS 4 3 imports = [ 5 4 ./base.nix 6 5 ./programs/git.nix 7 6 ./programs/ssh.nix 8 - ./programs/ghostty.nix 9 7 ./programs/helix.nix 10 8 ./shell 11 9 ]; 12 10 13 11 # corporate mandated 14 12 home.username = "ivan.ostric"; 15 - home.directory = "/Users/ivan.ostric"; 13 + home.homeDirectory = "/Users/ivan.ostric"; 16 14 17 - # :squints: 18 - programs.ghostty.settings.font-size = pkgs.mkForce 12; 15 + # TODO: Ghostty is not packaged for macOS in Nix, so we can't use the same 16 + # config. This should be fixed. 17 + xdg.configFile."ghostty/config".text = '' 18 + command = /usr/bin/env zsh -c nu 19 + font-family = Iosevka 20 + font-size = 14 21 + theme = dark:Catppuccin Macchiato,light:Catppuccin Latte 22 + ''; 19 23 }
+2
home/programs/ghostty.nix
··· 1 + # TODO: Ghostty is not packaged for macOS in Nix, so we can't use the same 2 + # config. This should be fixed. 1 3 { 2 4 programs.ghostty = { 3 5 enable = true;
+6 -1
home/programs/git.nix
··· 1 + { pkgs, ... }: 1 2 let 2 - onePasswordSigner = "/run/current-system/sw/bin/op-ssh-sign"; # TODO: make dynamic 3 + onePasswordSigner = 4 + if pkgs.stdenv.isDarwin then 5 + "/Applications/1Password.app/Contents/MacOS/op-ssh-sign" 6 + else 7 + "/run/current-system/sw/bin/op-ssh-sign"; 3 8 userName = "Ivan"; 4 9 userEmail = "hi@crescentro.se"; 5 10 signingKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKJdAes80dpMrc99B68/1Kx2bbfoh6IrkbFF+60cMQti";
+1 -14
home/shell/default.nix
··· 1 1 { pkgs, ... }: 2 2 { 3 3 imports = [ 4 + ./developer.nix 4 5 ./nu.nix 5 6 ./ripgrep.nix 6 7 ./starship.nix ··· 19 20 jujutsu # fine, i will try it... 20 21 21 22 # developer tools 22 - gcc # the GNU Compiler Collection 23 - rustup # rust installer 24 - terraform # the CLOUD 25 23 agebox # secret 26 24 age # more secret 27 - uv # snek 28 25 lefthook # git hooks 29 - 30 - # language servers 31 - gopls # golang 32 - lua-language-server # lua 33 - nixd # nix 34 - nixfmt-rfc-style # nix formatter 35 - taplo # toml 36 - terraform-ls # terraform 37 - typescript-language-server # javascript, typescript 38 - vscode-langservers-extracted # html, css, json, eslint 39 26 ]; 40 27 41 28 xdg.dataFile."scripts".source = ../../resources/scripts;
+45
home/shell/developer.nix
··· 1 + { pkgs, ... }: 2 + { 3 + home.packages = with pkgs; [ 4 + # 🤓 C 5 + gcc 6 + pkg-config 7 + 8 + # 🐳 Docker 9 + docker-language-server 10 + 11 + # 🐭 Go 12 + go 13 + gopls 14 + delve 15 + golangci-lint 16 + golangci-lint-langserver 17 + 18 + # ☁️ Google Cloud 19 + google-cloud-sdk 20 + kubectl 21 + 22 + # ☕ Javascript 23 + nodejs_24 24 + pnpm 25 + typescript-language-server # javascript, typescript 26 + vscode-langservers-extracted # html, css, json, eslint 27 + 28 + # ❄️ Nix 29 + nixd 30 + nixfmt-rfc-style # nix formatter 31 + 32 + # 🐍 Python 33 + uv 34 + 35 + # 🦀 Rust 36 + rustup 37 + 38 + # 🏗️ Terraform 39 + terraform 40 + terraform-ls 41 + 42 + # 📝 TOML 43 + taplo 44 + ]; 45 + }
+4
home/shell/nu.nix
··· 27 27 $env.NU_LIB_DIRS ++= ["${config.xdg.dataHome}/scripts/lib"] 28 28 $env.PATH ++= ["${config.xdg.dataHome}/scripts/bin"] 29 29 ''; 30 + 31 + extraConfig = '' 32 + use pm switch # for fast swap between directories 33 + ''; 30 34 }; 31 35 }
+1
home/shell/starship.nix
··· 2 2 programs.starship = { 3 3 enable = true; 4 4 enableNushellIntegration = true; 5 + enableZshIntegration = true; 5 6 settings = { 6 7 7 8 # Inserts a blank line between shell prompts
+65
machines/work/default.nix
··· 1 + { pkgs, ... }: 2 + let 3 + # Another joy of the corporate life: your full legal name as the device 4 + # user... 5 + user = "ivan.ostric"; 6 + in 7 + { 8 + system.primaryUser = user; 9 + 10 + environment.systemPackages = with pkgs; [ 11 + # macOS-specific Docker stuff 12 + podman 13 + docker # use `docker` commands with podman 14 + docker-buildx 15 + ]; 16 + 17 + # Ideally we would manage everything with Nix, but life is sad and some 18 + # packages are only available through Brew. 19 + # 20 + # Note that Homebrew needs to be installed manually for this to work. 21 + homebrew = { 22 + enable = true; 23 + brews = [ 24 + "mas" 25 + ]; 26 + casks = [ 27 + "1password" 28 + "1password-cli" 29 + "ghostty" 30 + "obsidian" 31 + "podman-desktop" 32 + "raycast" 33 + "font-cascadia-code-nf" 34 + "font-fira-code-nerd-font" 35 + "font-symbols-only-nerd-font" 36 + ]; 37 + }; 38 + 39 + # Run a PostgreSQL development database 40 + services.postgresql.enable = true; 41 + 42 + # Use ZSH as the main shell 43 + programs.zsh.enable = true; 44 + # Use Homebrew through zsh 45 + programs.zsh.shellInit = '' 46 + eval "$(/opt/homebrew/bin/brew shellenv)" 47 + ''; 48 + 49 + # Use Touch ID for authentication with `sudo` 50 + security.pam.services.sudo_local.touchIdAuth = true; 51 + 52 + # Using Determinate Nix, because upstream Nix does not work as well when 53 + # your corporate provisioned device is loaded with Microsoft endpoint 54 + # security "features" 55 + nix.enable = false; 56 + nixpkgs.hostPlatform = "aarch64-darwin"; 57 + 58 + users.users."${user}" = { 59 + name = user; 60 + home = "/Users/${user}"; 61 + }; 62 + 63 + # WARN: Here be dragons! 64 + system.stateVersion = 6; 65 + }
resources/scripts/bin/kctx
+1 -1
resources/scripts/lib/pm/mod.nu
··· 6 6 } 7 7 8 8 # Change to a project directory (directory under ~/Code). 9 - export def --env go [dir: string@list] { 9 + export def --env switch [dir: string@list] { 10 10 cd $"($env.HOME)/Code/($dir)" 11 11 } 12 12