-
Notifications
You must be signed in to change notification settings - Fork 2
feat: introduce nix-darwin again #334
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
Changes from all commits
30bcd84
cbe5a07
d0561bb
34480e3
9f98fb4
07176b4
cd1355a
0e98ff2
5bf9859
69722bf
c532aaf
6d180b5
f4e3d7e
7279467
505a8dc
d7e0026
367f20f
2dbbd71
cf3e9b7
47498a5
e23e14b
45c6189
dafa274
3d482a7
8f8aace
4100405
50910e2
f647ad7
750112b
cd2be12
74c29cb
139a51a
d7f669a
f8614a1
9c25b9d
d63c193
a1876db
af4bf0f
3a3b33a
a47ddb4
7e23906
5201c65
1b97b2d
4362783
62b7a8f
4ca170f
449f0be
ebee940
3e22ef8
925296e
dd3dbb7
dc481b3
8c5ee2b
0beae2a
23a6b59
790ae39
3f5b5f7
21953c1
6b0fc12
e87c79d
8550f6b
0f19d44
5076ff7
641dd91
3274018
0d4b936
75618a1
0a1aba1
c777852
1e85147
20265db
62c50f1
6fb33ed
471f31e
a6f19db
2572546
570d9de
fa91688
de7027d
da6ce13
a96087e
bb2147a
6a02e54
0254504
dcdd1ca
884e0f9
6705f9a
37dba46
e7de057
e67a73a
3ccaa86
116ebd3
bcba647
83c9f75
2a5797c
ea95167
242ea0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,14 @@ | ||
| name: macOS test | ||
| name: macOS nix-darwin build check | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| jobs: | ||
| main: | ||
| build: | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: uninstall builtin homebrew on macOS | ||
| run: | | ||
| sudo rm -rf /opt/homebrew | ||
| - name: setup dotfiles | ||
| run: | | ||
| cp -r $GITHUB_WORKSPACE $HOME/dotfiles | ||
| cd $HOME/dotfiles | ||
| make | ||
| make brew | ||
| - name: install packages | ||
| run: | | ||
| source $HOME/.zshrc | ||
| make brew-base | ||
| shell: zsh {0} | ||
| - name: brew doctor on macOS | ||
| run: | | ||
| # NOTE(himkt); skip this on Ubuntu since brew doctor won't succeed | ||
| # due to the installation path. | ||
| brew doctor | ||
| - uses: actions/checkout@v6 | ||
| - uses: DeterminateSystems/nix-installer-action@main | ||
| - name: Build nix-darwin configuration | ||
| run: make macos-build |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: NixOS build check | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: DeterminateSystems/nix-installer-action@main | ||
| - name: Build NixOS configuration | ||
| run: make nixos-build |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,4 @@ | ||
| .* | ||
| !.gitignore | ||
| !.gitmodules | ||
| !.amethyst | ||
| !.bashrc | ||
| !.zshrc | ||
| !.vimrc | ||
| !.tmux.conf | ||
| !.osx.tmux.conf | ||
| !.octaverc | ||
| !.vim | ||
| !.zsh | ||
| !.keep | ||
|
|
||
| *private* | ||
| *secret* | ||
|
|
||
| # https://github.com/himkt/omoide | ||
| /bin/omoide | ||
| # https://github.com/himkt/auto-release | ||
| /bin/auto-release | ||
| !.github/ | ||
| result |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,113 +1,48 @@ | ||
| # Makefile for dotfile configs | ||
| RED := $(shell tput setaf 1) | ||
| NOCOLOR := $(shell tput sgr0) | ||
| .PHONY: macos-build macos-switch macos-brew-install macos-brew macos-brew-gui macos-brew-optional macos-brew-himkt macos-update macos-clean macos-gc nixos-build nixos-switch nixos-update nixos-clean nixos-gc | ||
|
|
||
| .PHONY: \ | ||
| all docs brew \ | ||
| base cli darwin gui \ | ||
| git ghostty nvim sheldon tmux uv zsh | ||
| # macOS targets | ||
| macos-build: | ||
| nix build .#darwinConfigurations.macos.system | ||
|
|
||
| all: git tmux zsh docs | ||
| optional: all darwin ghostty git mise nvim sheldon uv | ||
| macos-switch: | ||
| sudo darwin-rebuild switch --flake .#macos | ||
|
|
||
| # ========================= | ||
|
|
||
| brew: | ||
| macos-brew-install: | ||
| $(PWD)/brew/bin/setup.sh | ||
|
|
||
| brew-base: | ||
| macos-brew: | ||
| brew bundle --verbose --file=$(PWD)/brew/config.d/base/Brewfile | ||
|
|
||
| brew-optional: | ||
| brew bundle --verbose --file=$(PWD)/brew/config.d/optional/Brewfile | ||
|
|
||
| brew-gui: | ||
| macos-brew-gui: | ||
| brew bundle --verbose --file=$(PWD)/brew/config.d/gui/Brewfile | ||
|
|
||
| brew-himkt: | ||
| brew bundle --verbose --file=$(PWD)/brew/config.d/himkt/Brewfile | ||
|
|
||
| krew-base: | ||
| kubectl krew install open-svc ns images ctx stern neat | ||
|
|
||
| # ========================= | ||
|
|
||
| darwin: | ||
| $(PWD)/darwin/bin/setup.sh | ||
|
|
||
| ghostty: ghostty_clean | ||
| $(PWD)/ghostty/bin/setup.sh | ||
|
|
||
| git: git_clean | ||
| $(PWD)/git/bin/setup.sh | ||
|
|
||
| mise: mise_clean | ||
| $(PWD)/mise/bin/setup.sh | ||
|
|
||
| nvim: nvim_clean | ||
| $(PWD)/nvim/bin/setup.sh | ||
|
|
||
| sheldon: sheldon_clean | ||
| $(PWD)/sheldon/bin/setup.sh | ||
|
|
||
| tmux: tmux_clean | ||
| $(PWD)/tmux/bin/setup.sh | ||
|
|
||
| uv: uv_clean | ||
| $(PWD)/uv/bin/setup.sh | ||
|
|
||
| zsh: zsh_clean | ||
| $(PWD)/zsh/bin/setup.sh | ||
|
|
||
| # ========================= | ||
|
|
||
| ghostty_clean: | ||
| rm -rf $(HOME)/.config/ghostty | ||
| macos-brew-optional: | ||
| brew bundle --verbose --file=$(PWD)/brew/config.d/optional/Brewfile | ||
|
|
||
| git_clean: | ||
| rm -rf $(HOME)/.config/git/config | ||
| rm -rf $(HOME)/.config/git/ignore | ||
| macos-brew-himkt: | ||
| brew bundle --verbose --file=$(PWD)/brew/config.d/himkt/Brewfile | ||
|
|
||
| mise_clean: | ||
| rm -rf $(HOME)/.config/mise | ||
| macos-update: | ||
| nix flake update | ||
|
|
||
| nvim_clean: | ||
| rm -rf $(HOME)/.vimrc | ||
| rm -rf $(HOME)/.vim | ||
| rm -rf $(HOME)/.config/nvim | ||
| macos-clean: | ||
| sudo nix-env --delete-generations +7 --profile /nix/var/nix/profiles/system-profiles/darwin | ||
|
|
||
| sheldon_clean: | ||
| rm -rf $(HOME)/.config/sheldon | ||
| macos-gc: | ||
| sudo nix-collect-garbage -d | ||
|
|
||
| tmux_clean: | ||
| rm -rf $(HOME)/.tmux.conf | ||
| # NixOS targets | ||
| nixos-build: | ||
| nix build .#nixosConfigurations.nixos.config.system.build.toplevel | ||
|
|
||
| uv_clean: | ||
| rm -rf $(HOME)/.local/bin/uv $(HOME)/.local/bin/uvx | ||
| rm -rf $(HOME)/.config/uv | ||
| nixos-switch: | ||
| sudo nixos-rebuild switch --flake .#nixos | ||
|
|
||
| zsh_clean: | ||
| rm -rf $(HOME)/.zshrc | ||
| nixos-update: | ||
| nix flake update | ||
|
|
||
| # ========================= | ||
| nixos-clean: | ||
| sudo nix-env --delete-generations +7 --profile /nix/var/nix/profiles/system | ||
|
|
||
| docs: | ||
| @echo "" | ||
| @echo "### Finish installing dotfiles!" | ||
| @echo "Please run $(RED)source $$HOME/.zshrc$(NOCOLOR) on zsh to enable configures." | ||
| @echo "- If you want to use nvim with extensions, please run $(RED)make nvim$(NOCOLOR) (which needs pyenv)." | ||
| @echo "- If you want to install pyenv using brew, please read the Python section below." | ||
| @echo "" | ||
| @echo "---" | ||
| @echo "" | ||
| @echo "### Packages" | ||
| @echo "- If you want to use linuxbrew/homebrew, please run $(RED)make brew-cui$(NOCOLOR)." | ||
| @echo "- Please run $(RED)make brew$(NOCOLOR) before if you have not installed brew yet" | ||
| @echo "- Additionally, $(RED)make brew-optional$(NOCOLOR) installs optional packages" | ||
| @echo "" | ||
| @echo "---" | ||
| @echo "" | ||
| @echo "### Python" | ||
| @echo "- After $(RED)make brew, make brew-cui, source $$HOME/.zshrc$(NOCOLOR)," | ||
| @echo " you can run $(RED)make nvim$(NOCOLOR) to install Python and the nvim library" | ||
| @echo "" | ||
| nixos-gc: | ||
| sudo nix-collect-garbage -d | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,17 +1,67 @@ | ||||||||||||||||||||||||||
| ## dotfiles | ||||||||||||||||||||||||||
| # dotfiles | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| [](https://github.com/himkt/dotfiles/actions/workflows/macos.yml) | ||||||||||||||||||||||||||
| [](https://github.com/himkt/dotfiles/actions/workflows/macos.yml) | ||||||||||||||||||||||||||
| [](https://github.com/himkt/dotfiles/actions/workflows/nixos.yml) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ## Installation | ||||||||||||||||||||||||||
| Unified Nix-based configuration for macOS (nix-darwin) and NixOS. | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ## Structure | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
| git clone git@github.com:himkt/dotfiles $HOME/dotfiles | ||||||||||||||||||||||||||
| cd $HOME/dotfiles && make | ||||||||||||||||||||||||||
| dotfiles/ | ||||||||||||||||||||||||||
| ├── flake.nix # Unified flake (NixOS + nix-darwin) | ||||||||||||||||||||||||||
| ├── Makefile # Build and setup targets | ||||||||||||||||||||||||||
| ├── hosts/ | ||||||||||||||||||||||||||
| │ ├── nixos/ # NixOS system configuration | ||||||||||||||||||||||||||
| │ └── macos/ # nix-darwin system configuration | ||||||||||||||||||||||||||
| ├── home/ | ||||||||||||||||||||||||||
| │ ├── nixos.nix # NixOS Home Manager entry point | ||||||||||||||||||||||||||
| │ ├── macos.nix # macOS Home Manager entry point | ||||||||||||||||||||||||||
| │ └── modules/ # Shared and platform-specific modules | ||||||||||||||||||||||||||
| ├── brew/ # Homebrew Brewfiles (macOS) | ||||||||||||||||||||||||||
| └── secrets/ # sops-nix encrypted secrets | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ### Homebrew/Linuxbrew | ||||||||||||||||||||||||||
| ## Setup | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ### macOS | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| 1. Install [Nix](https://nixos.org/download/) | ||||||||||||||||||||||||||
| 2. Clone this repository to `~/dotfiles` | ||||||||||||||||||||||||||
| 3. Apply the nix-darwin configuration: | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
| make macos-switch | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
| 4. Install Homebrew packages: | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
| make macos-brew | ||||||||||||||||||||||||||
| make macos-brew-gui | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ### NixOS | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| 1. Clone this repository to `~/dotfiles` | ||||||||||||||||||||||||||
| 2. Apply the NixOS configuration: | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
| make nixos-switch | ||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| If you don't have `brew`, you have to run `make brew` in advance. | ||||||||||||||||||||||||||
| ## Makefile Targets | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| - `make brew-base`: install essential tools | ||||||||||||||||||||||||||
| - `make brew-gui`: install GUI apps for macOS | ||||||||||||||||||||||||||
| | Target | Description | | ||||||||||||||||||||||||||
| |--------|-------------| | ||||||||||||||||||||||||||
| | `macos-build` | Build nix-darwin configuration (dry run) | | ||||||||||||||||||||||||||
| | `macos-switch` | Apply nix-darwin + Home Manager configuration | | ||||||||||||||||||||||||||
| | `macos-brew-install` | Install Homebrew | | ||||||||||||||||||||||||||
| | `macos-brew` | Install base Homebrew packages | | ||||||||||||||||||||||||||
| | `macos-brew-gui` | Install GUI Homebrew packages | | ||||||||||||||||||||||||||
| | `macos-brew-optional` | Install optional Homebrew packages | | ||||||||||||||||||||||||||
| | `macos-brew-himkt` | Install personal Homebrew packages | | ||||||||||||||||||||||||||
| | `macos-update` | Update flake inputs | | ||||||||||||||||||||||||||
| | `macos-clean` | Delete old macOS generations (keep last 7) | | ||||||||||||||||||||||||||
| | `macos-gc` | Run Nix garbage collection | | ||||||||||||||||||||||||||
| | `nixos-build` | Build NixOS configuration (dry run) | | ||||||||||||||||||||||||||
| | `nixos-switch` | Apply NixOS + Home Manager configuration | | ||||||||||||||||||||||||||
| | `nixos-update` | Update flake inputs | | ||||||||||||||||||||||||||
| | `nixos-clean` | Delete old NixOS generations (keep last 7) | | ||||||||||||||||||||||||||
|
Comment on lines
+61
to
+66
|
||||||||||||||||||||||||||
| | `macos-clean` | Delete old macOS generations (keep last 7) | | |
| | `macos-gc` | Run Nix garbage collection | | |
| | `nixos-build` | Build NixOS configuration (dry run) | | |
| | `nixos-switch` | Apply NixOS + Home Manager configuration | | |
| | `nixos-update` | Update flake inputs | | |
| | `nixos-clean` | Delete old NixOS generations (keep last 7) | | |
| | `macos-clean` | Delete macOS generations older than 7 days | | |
| | `macos-gc` | Run Nix garbage collection | | |
| | `nixos-build` | Build NixOS configuration (dry run) | | |
| | `nixos-switch` | Apply NixOS + Home Manager configuration | | |
| | `nixos-update` | Update flake inputs | | |
| | `nixos-clean` | Delete NixOS generations older than 7 days | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,3 @@ | ||
| brew 'coreutils' | ||
| brew 'fzf' | ||
| brew 'gh' | ||
| brew 'git-lfs' | ||
| brew 'jq' | ||
| brew 'sheldon' | ||
| brew 'tree' | ||
| brew 'zoxide' | ||
|
|
||
| cask 'corretto@17' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| cask 'claude-code' | ||
| cask 'codex' | ||
| cask 'font-jetbrains-mono' | ||
| cask 'ghostty' | ||
| cask 'google-chrome' | ||
| cask 'netron' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| tap 'himkt/tap' | ||
| brew 'himkt/tap/pathfinder' | ||
| brew 'himkt/tap/tips-cli' | ||
| cask 'himkt/tap/voicevox' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command
sudo darwin-rebuild switchrequires root privileges, which is unusual for nix-darwin. The standard command isdarwin-rebuild switch(without sudo). Using sudo may cause permission issues with user-specific files and should be avoided unless absolutely necessary.