diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 2260ebb0..58c57d8d 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -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 diff --git a/.github/workflows/nixos.yml b/.github/workflows/nixos.yml new file mode 100644 index 00000000..b0efe79f --- /dev/null +++ b/.github/workflows/nixos.yml @@ -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 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml deleted file mode 100644 index 9d023705..00000000 --- a/.github/workflows/ubuntu.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Ubuntu test -on: - push: - branches: - - main - pull_request: -jobs: - main: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: setup zsh for ubuntu-latest - run: | - sudo apt update -y - sudo apt install -y zsh - sudo chsh -s $(which zsh) - - 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} diff --git a/.gitignore b/.gitignore index 21af8de6..01bbe042 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/LICENSE b/LICENSE index bd4af4c3..a052733e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017-2025 himkt +Copyright (c) 2017-2026 himkt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index 1c73de76..94d5ca4a 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index d3571698..07e9268d 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,67 @@ -## dotfiles +# dotfiles -[![macOS test](https://github.com/himkt/dotfiles/actions/workflows/macos.yml/badge.svg)](https://github.com/himkt/dotfiles/actions/workflows/macos.yml) +[![macOS](https://img.shields.io/github/actions/workflow/status/himkt/dotfiles/macos.yml?label=macOS&logo=apple)](https://github.com/himkt/dotfiles/actions/workflows/macos.yml) +[![NixOS](https://img.shields.io/github/actions/workflow/status/himkt/dotfiles/nixos.yml?label=NixOS&logo=nixos&logoColor=white)](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) | +| `nixos-gc` | Run Nix garbage collection | diff --git a/brew/config.d/base/Brewfile b/brew/config.d/base/Brewfile index 78f5132a..7b2c620d 100644 --- a/brew/config.d/base/Brewfile +++ b/brew/config.d/base/Brewfile @@ -1,10 +1,3 @@ brew 'coreutils' -brew 'fzf' brew 'gh' -brew 'git-lfs' brew 'jq' -brew 'sheldon' -brew 'tree' -brew 'zoxide' - -cask 'corretto@17' diff --git a/brew/config.d/gui/Brewfile b/brew/config.d/gui/Brewfile index 65366d2d..3cc2ee87 100644 --- a/brew/config.d/gui/Brewfile +++ b/brew/config.d/gui/Brewfile @@ -1,6 +1,5 @@ cask 'claude-code' cask 'codex' -cask 'font-jetbrains-mono' cask 'ghostty' cask 'google-chrome' cask 'netron' diff --git a/brew/config.d/himkt/Brewfile b/brew/config.d/himkt/Brewfile index b6d9f2fd..1f6b5c92 100644 --- a/brew/config.d/himkt/Brewfile +++ b/brew/config.d/himkt/Brewfile @@ -1,4 +1,3 @@ tap 'himkt/tap' -brew 'himkt/tap/pathfinder' brew 'himkt/tap/tips-cli' cask 'himkt/tap/voicevox' diff --git a/brew/config.d/optional/Brewfile b/brew/config.d/optional/Brewfile index 7a7453e2..d2dc356c 100644 --- a/brew/config.d/optional/Brewfile +++ b/brew/config.d/optional/Brewfile @@ -4,9 +4,5 @@ brew 'btop' brew 'krew' brew 'kubernetes-cli' brew 'libpq' -brew 'mise' -brew 'tmux' -brew 'uv' - tap 'derailed/k9s' brew 'derailed/k9s/k9s' diff --git a/darwin/bin/setup.sh b/darwin/bin/setup.sh deleted file mode 100755 index 40dc8346..00000000 --- a/darwin/bin/setup.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -# https://macos-defaults.com/ - -# keyboard -# -# https://linkarzu.com/posts/2024-macos-workflow/macos-keyrepeat-rate/ -# -# * (todo) remap caps to control -# * key repeat rate -# * delay until repeat -# * F1, F2, ...etc behave as macOS defined function keys -# -defaults write -g KeyRepeat -int 2 -defaults write -g InitialKeyRepeat -int 20 -defaults write -g ApplePressAndHoldEnabled -bool false -defaults write NSGlobalDomain com.apple.keyboard.fnState -bool false - -# trackpad -defaults write com.apple.AppleMultitouchTrackpad Clicking -int 1 -defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -int 1 - -# dock -# -# autohide = true -# show-recents = false -# orientation = bottom -# -defaults write com.apple.dock orientation -string left -defaults write com.apple.dock autohide -bool true -killall Dock - -# menu bar -# -# only show = [Wi-Fi, VPN, Battery] -# - -# finder -# - -# login window -# -# guest login = false -# - -# pam -sudo rm -rf /etc/pam.d/sudo_local -cat /etc/pam.d/sudo_local.template \ - | sed -e 's/#auth/auth/g' \ - | sudo tee /etc/pam.d/sudo_local >/dev/null diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..b5be3298 --- /dev/null +++ b/flake.lock @@ -0,0 +1,109 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1770260404, + "narHash": "sha256-3iVX1+7YUIt23hBx1WZsUllhbmP2EnXrV8tCRbLxHc8=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "0d782ee42c86b196acff08acfbf41bb7d13eed5b", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-25.11", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1767634391, + "narHash": "sha256-owcSz2ICqTSvhBbhPP+1eWzi88e54rRZtfCNE5E/wwg=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "08585aacc3d6d6c280a02da195fdbd4b9cf083c2", + "type": "github" + }, + "original": { + "owner": "LnL7", + "ref": "nix-darwin-25.11", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1770136044, + "narHash": "sha256-tlFqNG/uzz2++aAmn4v8J0vAkV3z7XngeIIB3rM3650=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e576e3c9cf9bad747afcddd9e34f51d18c855b4e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1770197578, + "narHash": "sha256-AYqlWrX09+HvGs8zM6ebZ1pwUqjkfpnv8mewYwAo+iM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "00c21e4c93d963c50d4c0c89bfa84ed6e0694df2", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable", + "sops-nix": "sops-nix" + } + }, + "sops-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1770145881, + "narHash": "sha256-ktjWTq+D5MTXQcL9N6cDZXUf9kX8JBLLBLT0ZyOTSYY=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "17eea6f3816ba6568b8c81db8a4e6ca438b30b7c", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..ec4439f2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,72 @@ +{ + description = "NixOS and nix-darwin configuration for himkt"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + + home-manager = { + url = "github:nix-community/home-manager/release-25.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + nix-darwin = { + url = "github:LnL7/nix-darwin/nix-darwin-25.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + sops-nix = { + url = "github:Mic92/sops-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { + self, + nixpkgs, + home-manager, + nix-darwin, + ... + }@inputs: + { + # NixOS configuration + nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; username = "himkt"; }; + modules = [ + ./hosts/nixos/configuration.nix + inputs.sops-nix.nixosModules.sops + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.himkt = import ./home/nixos.nix; + home-manager.extraSpecialArgs = { + inherit inputs; + username = "himkt"; + }; + } + ]; + }; + + # nix-darwin configuration + darwinConfigurations.macos = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + specialArgs = { inherit inputs; username = "himkt"; }; + modules = [ + ./hosts/macos/darwin-configuration.nix + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.himkt = import ./home/macos.nix; + home-manager.extraSpecialArgs = { + inherit inputs; + username = "himkt"; + }; + } + ]; + }; + }; +} diff --git a/ghostty/bin/setup.sh b/ghostty/bin/setup.sh deleted file mode 100755 index eb7499ba..00000000 --- a/ghostty/bin/setup.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -mkdir -p $HOME/.config/ghostty - -ln -s \ - $HOME/dotfiles/ghostty/config.d/config \ - $HOME/.config/ghostty/config diff --git a/git/bin/setup.sh b/git/bin/setup.sh deleted file mode 100755 index 28a5af77..00000000 --- a/git/bin/setup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -mkdir -p $HOME/.config/git - -rm -rf $HOME/.config/git/config -rm -rf $HOME/.config/git/ignore - -ln -s $HOME/dotfiles/git/config.d/config $HOME/.config/git/config -ln -s $HOME/dotfiles/git/config.d/ignore $HOME/.config/git/ignore diff --git a/home/macos.nix b/home/macos.nix new file mode 100644 index 00000000..d6bf5e7f --- /dev/null +++ b/home/macos.nix @@ -0,0 +1,68 @@ +{ config, pkgs, lib, inputs, ... }: + +let + himkt_pkgs = import ./pkgs { + inherit pkgs; + }; +in + +{ + imports = [ + # Shared modules (same 7 as NixOS) + ./modules/zsh + ./modules/sheldon + ./modules/tmux + ./modules/nvim + ./modules/git + ./modules/uv + ./modules/ghostty + ./modules/gcc + ./modules/java + # macOS-specific modules + ./modules/mise + ]; + + home.username = "himkt"; + home.homeDirectory = "/Users/himkt"; + home.stateVersion = "25.11"; + + xdg = { + enable = true; + configHome = "${config.home.homeDirectory}/.config"; + cacheHome = "${config.home.homeDirectory}/.cache"; + dataHome = "${config.home.homeDirectory}/.local/share"; + }; + + home.packages = with pkgs; [ + ghq + python3 + rustup + tree + himkt_pkgs.pathfinder + ]; + + home.sessionVariables = { + EDITOR = "nvim"; + }; + + # macOS-specific platform overrides + programs.git.settings.credential."https://github.com".helper = + lib.mkForce "!/opt/homebrew/bin/gh auth git-credential"; + + programs.tmux.extraConfig = lib.mkAfter '' + # macOS clipboard integration + bind-key -T copy-mode-vi y send -X copy-selection-and-cancel\; run "tmux save -|pbcopy" + bind-key -T copy-mode-vi Enter send -X copy-selection-and-cancel\; run "tmux save -|pbcopy" + ''; + + programs.mise.globalConfig = { + tools = { + gcloud = "latest"; + }; + settings = { + idiomatic_version_file_enable_tools = []; + }; + }; + + programs.home-manager.enable = true; +} diff --git a/home/modules/fcitx5/default.nix b/home/modules/fcitx5/default.nix new file mode 100644 index 00000000..7a4c9dfb --- /dev/null +++ b/home/modules/fcitx5/default.nix @@ -0,0 +1,63 @@ +{ + pkgs, + ... +}: + +{ + # GTK im-module settings for fcitx5 (XWayland apps) + gtk = { + gtk3.extraConfig.gtk-im-module = "fcitx"; + gtk4.extraConfig.gtk-im-module = "fcitx"; + }; + + i18n.inputMethod = { + enable = true; + type = "fcitx5"; + fcitx5 = { + addons = with pkgs; [ + fcitx5-mozc + fcitx5-gtk + ]; + settings = { + inputMethod = { + "Groups/0" = { + Name = "Default"; + "Default Layout" = "us"; + DefaultIM = "keyboard-us"; + }; + "Groups/0/Items/0" = { + Name = "keyboard-us"; + Layout = ""; + }; + "Groups/0/Items/1" = { + Name = "mozc"; + Layout = ""; + }; + GroupOrder = { + "0" = "Default"; + }; + }; + globalOptions = { + Hotkey = { + EnumerateWithTriggerKeys = "True"; + EnumerateSkipFirst = "False"; + }; + "Hotkey/TriggerKeys" = { + "0" = "Control+space"; + }; + Behavior = { + ActiveByDefault = "False"; + PreeditEnabledByDefault = "True"; + ShowInputMethodInformation = "True"; + DefaultPageSize = 5; + }; + }; + addons = { + classicui.globalSection = { + PreferTextIcon = "True"; + }; + }; + }; + }; + }; +} diff --git a/home/modules/gcc/default.nix b/home/modules/gcc/default.nix new file mode 100644 index 00000000..48905311 --- /dev/null +++ b/home/modules/gcc/default.nix @@ -0,0 +1,47 @@ +# Copied from https://github.com/momeemt/config. +{ + pkgs, + ... +}: + +let + materialColors = { + red = "38;5;203"; + amber = "38;5;214"; + blue = "38;5;33"; + green = "38;5;71"; + purple = "38;5;127"; + gray = "38;5;245"; + cyan = "38;5;81"; + }; + bold = "01"; +in +{ + programs.gcc = { + enable = true; + package = pkgs.gcc; + colors = { + error = "${bold};${materialColors.red}"; + warning = "${bold};${materialColors.amber}"; + note = "${bold};${materialColors.blue}"; + locus = materialColors.gray; + quote = materialColors.gray; + path = materialColors.cyan; + range1 = materialColors.green; + range2 = materialColors.blue; + fixit-insert = materialColors.green; + fixit-delete = materialColors.red; + diff-filename = "${bold};${materialColors.blue}"; + diff-hunk = materialColors.purple; + diff-delete = materialColors.red; + diff-insert = materialColors.green; + type-diff = "${bold};${materialColors.purple}"; + fnname = "${bold};${materialColors.green}"; + targs = materialColors.purple; + valid = materialColors.green; + invalid = materialColors.red; + highlight-a = "${bold};${materialColors.blue}"; + highlight-b = "${bold};${materialColors.amber}"; + }; + }; +} diff --git a/home/modules/ghostty/default.nix b/home/modules/ghostty/default.nix new file mode 100644 index 00000000..37f40820 --- /dev/null +++ b/home/modules/ghostty/default.nix @@ -0,0 +1,16 @@ +{ + config, + pkgs, + lib, + ... +}: + +{ + home.packages = lib.optionals pkgs.stdenv.hostPlatform.isLinux [ + pkgs.ghostty + ]; + + xdg.configFile."ghostty/config" = { + source = ./files/config; + }; +} diff --git a/ghostty/config.d/config b/home/modules/ghostty/files/config similarity index 86% rename from ghostty/config.d/config rename to home/modules/ghostty/files/config index 749dd0ee..172702c8 100644 --- a/ghostty/config.d/config +++ b/home/modules/ghostty/files/config @@ -17,9 +17,10 @@ background-blur-radius = 20 # font config font-family = Jetbrains Mono -font-family = Hiragino Kaku Gothic ProN -font-size = 16 +font-family = Noto Sans Mono CJK JP +font-size = 11 font-feature = -calt, -liga, -dlig keybind = shift+enter=text:\n +keybind = super+t=new_tab clipboard-paste-protection = false diff --git a/home/modules/git/default.nix b/home/modules/git/default.nix new file mode 100644 index 00000000..b0c7ec4e --- /dev/null +++ b/home/modules/git/default.nix @@ -0,0 +1,38 @@ +{ + config, + pkgs, + lib, + ... +}: + +{ + programs.git = { + enable = true; + lfs.enable = true; + + settings = { + user = { + name = "himkt"; + email = "himkt@klis.tsukuba.ac.jp"; + }; + credential."https://github.com" = { + helper = "!gh auth git-credential"; + }; + }; + + # Load additional config from dotfiles + includes = [ + { path = "~/.config/git/config-extra"; } + ]; + }; + + # Additional git config (aliases, format, etc.) + xdg.configFile."git/config-extra" = { + source = ./files/config; + }; + + # Global gitignore + xdg.configFile."git/ignore" = { + source = ./files/ignore; + }; +} diff --git a/git/config.d/config b/home/modules/git/files/config similarity index 80% rename from git/config.d/config rename to home/modules/git/files/config index 799b8a54..562b6791 100644 --- a/git/config.d/config +++ b/home/modules/git/files/config @@ -1,7 +1,3 @@ -[user] - email = himkt@klis.tsukuba.ac.jp - name = himkt - [pull] rebase = false @@ -41,7 +37,3 @@ colorMoved = plain mnemonicPrefix = true renames = true -[credential "https://github.com"] - helper = !/opt/homebrew/bin/gh auth git-credential -[credential "https://gist.github.com"] - helper = !/opt/homebrew/bin/gh auth git-credential diff --git a/git/config.d/ignore b/home/modules/git/files/ignore similarity index 92% rename from git/config.d/ignore rename to home/modules/git/files/ignore index 27749c83..c9d5db3f 100644 --- a/git/config.d/ignore +++ b/home/modules/git/files/ignore @@ -20,3 +20,4 @@ **/.claude **/CLAUDE.md +**/design-docs diff --git a/home/modules/gpg/default.nix b/home/modules/gpg/default.nix new file mode 100644 index 00000000..07b8925f --- /dev/null +++ b/home/modules/gpg/default.nix @@ -0,0 +1,14 @@ +{ + pkgs, + config, + ... +}: { + programs.gpg = { + enable = true; + package = pkgs.gnupg; + homedir = "${config.xdg.dataHome}/gnupg"; + + mutableKeys = true; + mutableTrust = true; + }; +} diff --git a/home/modules/java/default.nix b/home/modules/java/default.nix new file mode 100644 index 00000000..9de586f7 --- /dev/null +++ b/home/modules/java/default.nix @@ -0,0 +1,11 @@ +{ + pkgs, + ... +}: + +{ + programs.java = { + enable = true; + package = pkgs.jdk21; + }; +} diff --git a/home/modules/mise/default.nix b/home/modules/mise/default.nix new file mode 100644 index 00000000..7a19f9ed --- /dev/null +++ b/home/modules/mise/default.nix @@ -0,0 +1,19 @@ +{ + pkgs, + inputs, + ... +}: + +let + unstable = import inputs.nixpkgs-unstable { + system = pkgs.system; + }; +in + +{ + programs.mise = { + enable = true; + package = unstable.mise; + enableZshIntegration = true; + }; +} diff --git a/home/modules/nvim/default.nix b/home/modules/nvim/default.nix new file mode 100644 index 00000000..79b224a8 --- /dev/null +++ b/home/modules/nvim/default.nix @@ -0,0 +1,32 @@ +{ + config, + pkgs, + lib, + ... +}: + +{ + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + + plugins = with pkgs.vimPlugins; [ + vim-easymotion + tabular + fzf-vim + vim-indent-guides + vim-anzu + vim-airline + vim-polyglot + ]; + }; + + xdg.configFile."nvim/init.vim" = { + source = ./files/init.vim; + }; + + xdg.configFile."nvim/vimrc" = { + source = ./files/vimrc; + }; +} diff --git a/nvim/config.d/init.vim b/home/modules/nvim/files/init.vim similarity index 67% rename from nvim/config.d/init.vim rename to home/modules/nvim/files/init.vim index f3373b96..c59030f5 100644 --- a/nvim/config.d/init.vim +++ b/home/modules/nvim/files/init.vim @@ -16,19 +16,7 @@ set mouse= let g:python3_host_prog=$PYTHONSYSTEMPATH "" load basic vim configuration -source $HOME/dotfiles/nvim/config.d/vimrc - -"" load packages -call plug#begin('~/.config/nvim/plugged') - Plug 'easymotion/vim-easymotion' - Plug 'godlygeek/tabular' - Plug 'junegunn/fzf' - Plug 'junegunn/fzf.vim' - Plug 'nathanaelkane/vim-indent-guides' - Plug 'osyo-manga/vim-anzu' - Plug 'vim-airline/vim-airline' - Plug 'sheerun/vim-polyglot' -call plug#end() +source $XDG_CONFIG_HOME/nvim/vimrc " material.vim if (has('nvim')) diff --git a/nvim/snippet.d/cpp/argsort.snippets b/home/modules/nvim/files/snippet.d/cpp/argsort.snippets similarity index 100% rename from nvim/snippet.d/cpp/argsort.snippets rename to home/modules/nvim/files/snippet.d/cpp/argsort.snippets diff --git a/nvim/snippet.d/cpp/bellman_ford.snippets b/home/modules/nvim/files/snippet.d/cpp/bellman_ford.snippets similarity index 100% rename from nvim/snippet.d/cpp/bellman_ford.snippets rename to home/modules/nvim/files/snippet.d/cpp/bellman_ford.snippets diff --git a/nvim/snippet.d/cpp/combination.snippets b/home/modules/nvim/files/snippet.d/cpp/combination.snippets similarity index 100% rename from nvim/snippet.d/cpp/combination.snippets rename to home/modules/nvim/files/snippet.d/cpp/combination.snippets diff --git a/nvim/snippet.d/cpp/gcd.snippets b/home/modules/nvim/files/snippet.d/cpp/gcd.snippets similarity index 100% rename from nvim/snippet.d/cpp/gcd.snippets rename to home/modules/nvim/files/snippet.d/cpp/gcd.snippets diff --git a/nvim/snippet.d/cpp/lcm.snippets b/home/modules/nvim/files/snippet.d/cpp/lcm.snippets similarity index 100% rename from nvim/snippet.d/cpp/lcm.snippets rename to home/modules/nvim/files/snippet.d/cpp/lcm.snippets diff --git a/nvim/snippet.d/cpp/mod.snippets b/home/modules/nvim/files/snippet.d/cpp/mod.snippets similarity index 100% rename from nvim/snippet.d/cpp/mod.snippets rename to home/modules/nvim/files/snippet.d/cpp/mod.snippets diff --git a/nvim/snippet.d/cpp/prime_factorization.snippets b/home/modules/nvim/files/snippet.d/cpp/prime_factorization.snippets similarity index 100% rename from nvim/snippet.d/cpp/prime_factorization.snippets rename to home/modules/nvim/files/snippet.d/cpp/prime_factorization.snippets diff --git a/nvim/snippet.d/cpp/union_find.snippets b/home/modules/nvim/files/snippet.d/cpp/union_find.snippets similarity index 100% rename from nvim/snippet.d/cpp/union_find.snippets rename to home/modules/nvim/files/snippet.d/cpp/union_find.snippets diff --git a/nvim/snippet.d/cpp/utils.snippets b/home/modules/nvim/files/snippet.d/cpp/utils.snippets similarity index 100% rename from nvim/snippet.d/cpp/utils.snippets rename to home/modules/nvim/files/snippet.d/cpp/utils.snippets diff --git a/nvim/snippet.d/python/pylint_click.snippets b/home/modules/nvim/files/snippet.d/python/pylint_click.snippets similarity index 100% rename from nvim/snippet.d/python/pylint_click.snippets rename to home/modules/nvim/files/snippet.d/python/pylint_click.snippets diff --git a/nvim/snippet.d/rust/prime_factorization.snippets b/home/modules/nvim/files/snippet.d/rust/prime_factorization.snippets similarity index 100% rename from nvim/snippet.d/rust/prime_factorization.snippets rename to home/modules/nvim/files/snippet.d/rust/prime_factorization.snippets diff --git a/nvim/template.d/cc/template.cc b/home/modules/nvim/files/template.d/cc/template.cc similarity index 100% rename from nvim/template.d/cc/template.cc rename to home/modules/nvim/files/template.d/cc/template.cc diff --git a/nvim/template.d/go/template.go b/home/modules/nvim/files/template.d/go/template.go similarity index 100% rename from nvim/template.d/go/template.go rename to home/modules/nvim/files/template.d/go/template.go diff --git a/nvim/template.d/mklatex/Makefile b/home/modules/nvim/files/template.d/mklatex/Makefile similarity index 100% rename from nvim/template.d/mklatex/Makefile rename to home/modules/nvim/files/template.d/mklatex/Makefile diff --git a/nvim/template.d/mklatex/double.tex b/home/modules/nvim/files/template.d/mklatex/double.tex similarity index 100% rename from nvim/template.d/mklatex/double.tex rename to home/modules/nvim/files/template.d/mklatex/double.tex diff --git a/nvim/template.d/mklatex/reference.bib b/home/modules/nvim/files/template.d/mklatex/reference.bib similarity index 100% rename from nvim/template.d/mklatex/reference.bib rename to home/modules/nvim/files/template.d/mklatex/reference.bib diff --git a/nvim/template.d/mklatex/single.tex b/home/modules/nvim/files/template.d/mklatex/single.tex similarity index 100% rename from nvim/template.d/mklatex/single.tex rename to home/modules/nvim/files/template.d/mklatex/single.tex diff --git a/nvim/template.d/mklatex/slide.tex b/home/modules/nvim/files/template.d/mklatex/slide.tex similarity index 100% rename from nvim/template.d/mklatex/slide.tex rename to home/modules/nvim/files/template.d/mklatex/slide.tex diff --git a/nvim/template.d/python/setup.cfg b/home/modules/nvim/files/template.d/python/setup.cfg similarity index 100% rename from nvim/template.d/python/setup.cfg rename to home/modules/nvim/files/template.d/python/setup.cfg diff --git a/nvim/template.d/rs/atcoder.rs b/home/modules/nvim/files/template.d/rs/atcoder.rs similarity index 100% rename from nvim/template.d/rs/atcoder.rs rename to home/modules/nvim/files/template.d/rs/atcoder.rs diff --git a/nvim/config.d/vimrc b/home/modules/nvim/files/vimrc similarity index 89% rename from nvim/config.d/vimrc rename to home/modules/nvim/files/vimrc index f4223433..61dda849 100644 --- a/nvim/config.d/vimrc +++ b/home/modules/nvim/files/vimrc @@ -139,11 +139,11 @@ autocmd FileType python nnoremap :sp :exec ':term if [ -e ./.venv ] autocmd FileType rust nnoremap :sp :exec ':term cargo run --bin ' . expand('%:t:r') " templates -autocmd BufNewFile *.cc 0r $HOME/dotfiles/nvim/template.d/cc/template.cc -autocmd BufNewFile *.go 0r $HOME/dotfiles/nvim/template.d/go/template.go -autocmd BufNewFile setup.cfg 0r $HOME/dotfiles/nvim/template.d/python/setup.cfg +autocmd BufNewFile *.cc 0r $HOME/dotfiles/home/modules/nvim/files/template.d/cc/template.cc +autocmd BufNewFile *.go 0r $HOME/dotfiles/home/modules/nvim/files/template.d/go/template.go +autocmd BufNewFile setup.cfg 0r $HOME/dotfiles/home/modules/nvim/files/template.d/python/setup.cfg if $ATC != "" - autocmd BufNewFile *.rs 0r $HOME/dotfiles/nvim/template.d/rs/atcoder.rs + autocmd BufNewFile *.rs 0r $HOME/dotfiles/home/modules/nvim/files/template.d/rs/atcoder.rs autocmd FileType rust nnoremap :sp :exec ':term rustc % && ./' . expand('%:t:r') . ' && rm ' . expand('%:t:r') endif diff --git a/home/modules/sheldon/default.nix b/home/modules/sheldon/default.nix new file mode 100644 index 00000000..6ac3e11d --- /dev/null +++ b/home/modules/sheldon/default.nix @@ -0,0 +1,16 @@ +{ + config, + pkgs, + lib, + ... +}: + +{ + home.packages = with pkgs; [ + sheldon + ]; + + xdg.configFile."sheldon/plugins.toml" = { + source = ./files/plugins.toml; + }; +} diff --git a/sheldon/config.d/plugins.toml b/home/modules/sheldon/files/plugins.toml similarity index 100% rename from sheldon/config.d/plugins.toml rename to home/modules/sheldon/files/plugins.toml diff --git a/home/modules/tmux/default.nix b/home/modules/tmux/default.nix new file mode 100644 index 00000000..b0081458 --- /dev/null +++ b/home/modules/tmux/default.nix @@ -0,0 +1,13 @@ +{ + config, + pkgs, + lib, + ... +}: + +{ + programs.tmux = { + enable = true; + extraConfig = builtins.readFile ./files/tmux.conf; + }; +} diff --git a/tmux/config.d/tmux.conf b/home/modules/tmux/files/tmux.conf similarity index 90% rename from tmux/config.d/tmux.conf rename to home/modules/tmux/files/tmux.conf index 53545447..b2e9ea76 100644 --- a/tmux/config.d/tmux.conf +++ b/home/modules/tmux/files/tmux.conf @@ -12,13 +12,19 @@ set -g status-justify left # enable mouse mode setw -g mode-keys vi -bind-key -T copy-mode-vi y send -X copy-selection-and-cancel\; run "tmux save -|pbcopy" -bind-key -T copy-mode-vi Enter send -X copy-selection-and-cancel\; run "tmux save -|pbcopy" +bind-key -T copy-mode-vi y send -X copy-selection-and-cancel +bind-key -T copy-mode-vi Enter send -X copy-selection-and-cancel # color set -g status-fg colour231 set -g status-bg colour234 +# pane +set -g pane-border-style fg=colour240 +set -g pane-active-border-style fg=colour31 +set -g pane-border-status top +set -g pane-border-format "#{?pane_active,#[fg=colour31] [*] #T ,#[fg=colour240] #T }" + # window window_status_current_format1="#[fg=colour234,bg=colour31] #[fg=colour117,bg=colour31]" window_status_current_format2="#I #[fg=colour231]#W #[fg=colour31,bg=colour234,nobold]" diff --git a/home/modules/uv/default.nix b/home/modules/uv/default.nix new file mode 100644 index 00000000..25e601ca --- /dev/null +++ b/home/modules/uv/default.nix @@ -0,0 +1,16 @@ +{ + config, + pkgs, + lib, + ... +}: + +{ + home.packages = with pkgs; [ + uv + ]; + + xdg.configFile."uv/uv.toml" = { + source = ./files/uv.toml; + }; +} diff --git a/home/modules/uv/files/uv.toml b/home/modules/uv/files/uv.toml new file mode 100644 index 00000000..39128ea0 --- /dev/null +++ b/home/modules/uv/files/uv.toml @@ -0,0 +1 @@ +python-preference = "managed" diff --git a/home/modules/zsh/default.nix b/home/modules/zsh/default.nix new file mode 100644 index 00000000..644820b1 --- /dev/null +++ b/home/modules/zsh/default.nix @@ -0,0 +1,19 @@ +{ + config, + pkgs, + lib, + ... +}: + +{ + programs.zsh = { + enable = true; + initContent = builtins.readFile ./files/zshrc; + }; + + # Additional packages needed by zshrc + home.packages = with pkgs; [ + fzf + zoxide + ]; +} diff --git a/zsh/config.d/zshrc b/home/modules/zsh/files/zshrc similarity index 94% rename from zsh/config.d/zshrc rename to home/modules/zsh/files/zshrc index 528e6f00..c526d5ef 100644 --- a/zsh/config.d/zshrc +++ b/home/modules/zsh/files/zshrc @@ -2,6 +2,10 @@ # .zshrc - The zsh configuration # +if command -v tmux > /dev/null && [ -z "$TMUX" ] && [ -z "$VSCODE_INJECTION" ] && [[ $- == *i* ]]; then + tmux attach-session 2>/dev/null || tmux new-session +fi + bindkey -e autoload -Uz compinit && compinit @@ -93,11 +97,6 @@ if command -v brew > /dev/null; then export LDFLAGS="-L$(brew --prefix xz)/lib" fi - if [ -d "$HOMEBREW_ROOT/opt/openjdk" ]; then - export PATH="$HOMEBREW_ROOT/opt/openjdk/bin:$PATH" - export CPPFLAGS="$CPPFLAGS:-I$HOMEBREW_ROOT/opt/openjdk/include" - fi - if [ -d "$HOMEBREW_ROOT/opt/libpq/bin" ]; then export PATH="$HOMEBREW_ROOT/opt/libpq/bin:$PATH" fi @@ -155,9 +154,6 @@ if command -v fzf > /dev/null; then source <(fzf --zsh) fi -if command -v mise > /dev/null; then - eval "$(mise activate zsh)" -fi if command -v nvim > /dev/null; then alias vim=nvim diff --git a/home/nixos.nix b/home/nixos.nix new file mode 100644 index 00000000..32d84c65 --- /dev/null +++ b/home/nixos.nix @@ -0,0 +1,184 @@ +{ config, pkgs, lib, inputs, ... }: + +let + unstable = import inputs.nixpkgs-unstable { + system = pkgs.system; + config.allowUnfree = true; + }; + himkt_pkgs = import ./pkgs { + inherit pkgs; + }; +in + +{ + imports = [ + # Shared modules + ./modules/zsh + ./modules/sheldon + ./modules/tmux + ./modules/nvim + ./modules/git + ./modules/uv + ./modules/ghostty + # NixOS-only modules + ./modules/gcc + ./modules/java + ./modules/gpg + ./modules/fcitx5 + ./modules/mise + ]; + + home.username = "himkt"; + home.homeDirectory = "/home/himkt"; + home.stateVersion = "25.11"; + + xdg = { + enable = true; + configHome = "${config.home.homeDirectory}/.config"; + cacheHome = "${config.home.homeDirectory}/.cache"; + dataHome = "${config.home.homeDirectory}/.local/share"; + }; + + home.packages = with pkgs; [ + # GUI + google-chrome + inkscape + insomnia + slack + unstable._1password-gui + unstable.vscode + + # CLI + bazelisk + btop + file + gh + ghq + google-cloud-sdk + gnumake + jq + kubectl + kubectx + kustomize + k9s + postgresql + python3 + rustup + tree + + # Custom packages + himkt_pkgs.pathfinder + ]; + + home.file = { + # Chrome with touchpad swipe gesture support + ".local/share/applications/google-chrome.desktop".text = '' + [Desktop Entry] + Version=1.0 + Name=Google Chrome + GenericName=Web Browser + Comment=Access the Internet + Exec=google-chrome-stable --enable-features=TouchpadOverscrollHistoryNavigation %U + StartupNotify=true + Terminal=false + Icon=google-chrome + Type=Application + Categories=Network;WebBrowser; + MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https; + ''; + + # Hide duplicate Chrome entry + ".local/share/applications/com.google.Chrome.desktop".text = '' + [Desktop Entry] + NoDisplay=true + ''; + + # Ghostty with fcitx5 workaround + ".local/share/applications/com.mitchellh.ghostty.desktop".text = '' + [Desktop Entry] + Version=1.0 + Name=Ghostty + GenericName=Terminal + Comment=A terminal emulator + Exec=env GTK_IM_MODULE= ghostty + StartupNotify=true + Terminal=false + Icon=com.mitchellh.ghostty + Type=Application + Categories=System;TerminalEmulator; + ''; + + # VSCode with Wayland support + ".local/share/applications/code.desktop".text = '' + [Desktop Entry] + Version=1.0 + Name=Visual Studio Code + GenericName=Text Editor + Comment=Code Editing. Redefined. + Exec=code --ozone-platform=wayland %F + StartupNotify=true + Terminal=false + Icon=vscode + Type=Application + Categories=Development;IDE;TextEditor; + MimeType=text/plain;inode/directory; + ''; + }; + + home.sessionVariables = { + EDITOR = "nvim"; + SSL_CERT_FILE = "/etc/ssl/certs/ca-certificates.crt"; + GTK_IM_MODULE = "fcitx"; + QT_IM_MODULE = "fcitx"; + XMODIFIERS = "@im=fcitx"; + GLFW_IM_MODULE = "ibus"; + ELECTRON_OZONE_PLATFORM_HINT = "auto"; + }; + + dconf.settings = { + "org/gnome/mutter" = { + experimental-features = [ "scale-monitor-framebuffer" ]; + }; + "org/gnome/desktop/peripherals/touchpad" = { + tap-to-click = false; + natural-scroll = true; + speed = 0.0; + }; + "org/gnome/desktop/peripherals/mouse" = { + speed = -1.0; + natural-scroll = true; + }; + "org/gnome/desktop/interface" = { + show-battery-percentage = true; + }; + }; + + fonts.fontconfig = { + enable = true; + defaultFonts = { + monospace = [ "JetBrains Mono" "Noto Sans Mono CJK JP" ]; + sansSerif = [ "Noto Sans CJK JP" ]; + serif = [ "Noto Serif CJK JP" ]; + emoji = [ "Noto Color Emoji" ]; + }; + }; + + # NixOS-specific platform overrides + programs.zsh.shellAliases = { + open = "xdg-open"; + }; + + programs.mise.globalConfig = { + tools = { + "aqua:anthropics/claude-code" = "latest"; + "core:node" = "latest"; + }; + settings = { + all_compile = false; + experimental = true; + disable_backends = [ "asdf" ]; + }; + }; + + programs.home-manager.enable = true; +} diff --git a/home/pkgs/default.nix b/home/pkgs/default.nix new file mode 100644 index 00000000..c7849c9a --- /dev/null +++ b/home/pkgs/default.nix @@ -0,0 +1,5 @@ +{ pkgs }: + +{ + pathfinder = pkgs.callPackage ./pathfinder { }; +} diff --git a/home/pkgs/pathfinder/default.nix b/home/pkgs/pathfinder/default.nix new file mode 100644 index 00000000..5258a5c6 --- /dev/null +++ b/home/pkgs/pathfinder/default.nix @@ -0,0 +1,42 @@ +{ + lib, + stdenv, + fetchurl, + autoPatchelfHook, +}: + +let + sources = { + x86_64-linux = { + url = "https://github.com/himkt/pathfinder/releases/download/v0.1.0/pathfinder-x86_64-unknown-linux-gnu.tar.gz"; + sha256 = "18bpvh651i1nk4agkxqqaax22y0fa3nwpfhhanlprzprq08cdvdk"; + }; + aarch64-darwin = { + url = "https://github.com/himkt/pathfinder/releases/download/v0.1.0/pathfinder-aarch64-apple-darwin.tar.gz"; + sha256 = "1q50ipvfg9gy1s86j5i8393xyyfjqjif3i89sxhbyhxm8kvhl0gg"; + }; + }; +in + +stdenv.mkDerivation rec { + pname = "pathfinder"; + version = "0.1.0"; + + src = fetchurl sources.${stdenv.hostPlatform.system}; + + nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]; + buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ stdenv.cc.cc.lib ]; + + sourceRoot = "."; + + installPhase = '' + install -Dm755 pathfinder $out/bin/pathfinder + ''; + + meta = with lib; { + description = "MCP client for jumping to definitions using LSP server"; + homepage = "https://github.com/himkt/pathfinder"; + license = licenses.mit; + platforms = [ "x86_64-linux" "aarch64-darwin" ]; + }; +} diff --git a/hosts/macos/darwin-configuration.nix b/hosts/macos/darwin-configuration.nix new file mode 100644 index 00000000..091dc640 --- /dev/null +++ b/hosts/macos/darwin-configuration.nix @@ -0,0 +1,38 @@ +{ pkgs, ... }: + +{ + # System-level settings (replaces darwin/bin/setup.sh) + system.defaults = { + NSGlobalDomain = { + KeyRepeat = 2; + InitialKeyRepeat = 20; + ApplePressAndHoldEnabled = false; + "com.apple.keyboard.fnState" = false; + }; + trackpad.Clicking = true; + dock = { + orientation = "left"; + autohide = true; + }; + }; + + system.primaryUser = "himkt"; + + users.users.himkt = { + home = "/Users/himkt"; + }; + + # Enable Touch ID for sudo + security.pam.services.sudo_local.touchIdAuth = true; + + fonts.packages = with pkgs; [ + jetbrains-mono + noto-fonts-cjk-sans + ]; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Note: verify this value before first activation. + # See https://daiderd.com/nix-darwin/manual/ for stateVersion documentation. + system.stateVersion = 5; +} diff --git a/hosts/modules/keyd/default.nix b/hosts/modules/keyd/default.nix new file mode 100644 index 00000000..133fd8c5 --- /dev/null +++ b/hosts/modules/keyd/default.nix @@ -0,0 +1,21 @@ +{ ... }: + +{ + services.keyd = { + enable = true; + keyboards.default = { + settings = { + main = { + capslock = "leftcontrol"; + }; + control = { + q = "A-f4"; + left = "home"; + right = "end"; + up = "C-home"; + down = "C-end"; + }; + }; + }; + }; +} diff --git a/hosts/nixos/configuration.nix b/hosts/nixos/configuration.nix new file mode 100644 index 00000000..5ae684e6 --- /dev/null +++ b/hosts/nixos/configuration.nix @@ -0,0 +1,204 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ../modules/keyd + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + boot.initrd.luks.devices."luks-f47715a3-2a66-448c-9e93-7268419de718".device = "/dev/disk/by-uuid/f47715a3-2a66-448c-9e93-7268419de718"; + networking.hostName = "neptune"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # sops-nix secrets + sops = { + defaultSopsFile = ../../secrets/secrets.yaml; + age.keyFile = "/var/lib/sops-nix/key.txt"; + secrets.nextdns_id = {}; + secrets.dns_server_ipv4_0 = {}; + secrets.dns_server_ipv4_1 = {}; + secrets.dns_server_ipv6_0 = {}; + secrets.dns_server_ipv6_1 = {}; + templates."99-nextdns.conf" = { + content = '' + [Resolve] + DNS=${config.sops.placeholder.dns_server_ipv4_0}#${config.sops.placeholder.nextdns_id}.dns.nextdns.io + DNS=${config.sops.placeholder.dns_server_ipv6_0}#${config.sops.placeholder.nextdns_id}.dns.nextdns.io + DNS=${config.sops.placeholder.dns_server_ipv4_1}#${config.sops.placeholder.nextdns_id}.dns.nextdns.io + DNS=${config.sops.placeholder.dns_server_ipv6_1}#${config.sops.placeholder.nextdns_id}.dns.nextdns.io + ''; + path = "/etc/systemd/resolved.conf.d/99-nextdns.conf"; + mode = "0644"; + restartUnits = [ "systemd-resolved.service" ]; + }; + }; + + # DNS over TLS with NextDNS + services.resolved = { + enable = true; + dnsovertls = "true"; + fallbackDns = []; + }; + networking.networkmanager.dns = "systemd-resolved"; + + # Set your time zone. + time.timeZone = "Asia/Tokyo"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "ja_JP.UTF-8"; + LC_IDENTIFICATION = "ja_JP.UTF-8"; + LC_MEASUREMENT = "ja_JP.UTF-8"; + LC_MONETARY = "ja_JP.UTF-8"; + LC_NAME = "ja_JP.UTF-8"; + LC_NUMERIC = "ja_JP.UTF-8"; + LC_PAPER = "ja_JP.UTF-8"; + LC_TELEPHONE = "ja_JP.UTF-8"; + LC_TIME = "ja_JP.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.displayManager.gdm.enable = true; + services.desktopManager.gnome.enable = true; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "us"; + variant = ""; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # FIXME(himkt); fprint not working so well in some cases. + # when finger print reader is not available, + # the experience is not so good as macOS (waiting until timeout). + # this happens when I use computer in clamshell mode and + # keyboard without fingerprint reader. + # + # Fingerprint reader + # services.fprintd = { + # enable = true; + # tod = { + # enable = true; + # driver = pkgs.libfprint-2-tod1-goodix; # note; Goodix 27c6:658c + # }; + # }; + + # Enable sound with pipewire. + services.pulseaudio.enable = false; + security.rtkit.enable = true; + + security.pam.services.gdm.enableGnomeKeyring = true; + services.gnome.gnome-keyring.enable = true; + + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Docker + virtualisation.docker = { + enable = true; + enableOnBoot = false; + }; + systemd.sockets.docker.wantedBy = pkgs.lib.mkForce []; + + # Define a user account. Don't forget to set a password with 'passwd'. + users.users.himkt = { + isNormalUser = true; + description = "himkt"; + extraGroups = [ "networkmanager" "wheel" "docker" ]; + packages = with pkgs; [ + # thunderbird + ]; + shell = pkgs.zsh; + }; + + # Install firefox. + programs.firefox.enable = true; + programs.zsh.enable = true; + programs.nix-ld.enable = true; + + programs.nix-ld.libraries = with pkgs; [ + postgresql.lib + ]; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + # wget + ]; + + fonts.packages = with pkgs; [ + jetbrains-mono + noto-fonts + noto-fonts-color-emoji + noto-fonts-cjk-sans + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + networking.firewall.trustedInterfaces = [ "docker0" "br-+" ]; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "25.11"; # Did you read the comment? + +} diff --git a/hosts/nixos/hardware-configuration.nix b/hosts/nixos/hardware-configuration.nix new file mode 100644 index 00000000..fed4eeae --- /dev/null +++ b/hosts/nixos/hardware-configuration.nix @@ -0,0 +1,35 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/mapper/luks-221ba240-258a-48a9-a316-e2de691f08c8"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-221ba240-258a-48a9-a316-e2de691f08c8".device = "/dev/disk/by-uuid/221ba240-258a-48a9-a316-e2de691f08c8"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/FEFA-7EFC"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/mapper/luks-f47715a3-2a66-448c-9e93-7268419de718"; } + ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/mise/bin/setup.sh b/mise/bin/setup.sh deleted file mode 100755 index 288b151f..00000000 --- a/mise/bin/setup.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -mkdir -p $HOME/.config/mise - -ln -s $HOME/dotfiles/mise/config.d/config.toml $HOME/.config/mise diff --git a/mise/config.d/config.toml b/mise/config.d/config.toml deleted file mode 100644 index f42057fd..00000000 --- a/mise/config.d/config.toml +++ /dev/null @@ -1,7 +0,0 @@ - -[settings] -idiomatic_version_file_enable_tools = [] - -[tools] -gcloud = "latest" - diff --git a/nvim/bin/setup.sh b/nvim/bin/setup.sh deleted file mode 100755 index 33c79ba4..00000000 --- a/nvim/bin/setup.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -ln -s $HOME/dotfiles/nvim/config.d/vimrc $HOME/.vimrc - -if type "nvim" > /dev/null 2>&1; then - echo 'neovim found' - mkdir -p $HOME/.config/nvim - - ln -s $HOME/dotfiles/nvim/config.d/init.vim $HOME/.config/nvim/init.vim - - curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \ - https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - - nvim --headless -u $PWD/nvim/config.d/init.vim +PlugInstall +qall - echo 'Plugin installed' - nvim --headless -u $PWD/nvim/config.d/init.vim +UpdateRemotePlugins +qall - - echo 'Finish creating the neovim environment!' -fi diff --git a/secrets/.sops.yaml b/secrets/.sops.yaml new file mode 100644 index 00000000..1b9e7d49 --- /dev/null +++ b/secrets/.sops.yaml @@ -0,0 +1,12 @@ +keys: + # User key (from SSH key) + - &user_himkt age1p35h8xyy545vjzjledqsvlvy935zdzl97tyjeejq6qxnh3c2uq5qllurj3 + # Host key (neptune) + - &host_neptune age1ngnflnwfkmadkqugc80qx2z550cpgany2dmsump0mvp0htgvnd8qg8hdjq + +creation_rules: + - path_regex: secrets\.yaml$ + key_groups: + - age: + - *user_himkt + - *host_neptune diff --git a/secrets/secrets.yaml b/secrets/secrets.yaml new file mode 100644 index 00000000..0334e5f1 --- /dev/null +++ b/secrets/secrets.yaml @@ -0,0 +1,30 @@ +#ENC[AES256_GCM,data:HjKcqrXCAY2skTqI5aopYcMfREo9iKD82FsAXymsEmJ7MFeCBoVTFEVZTm7EEOCo8BWik45zNg==,iv:ELijRN47sRn0BqZKbj2LPh9hhuyH+v56CxrzDL/EYVo=,tag:Wgs0Pmt8UNCk9slnw5gd6w==,type:comment] +nextdns_id: ENC[AES256_GCM,data:8FIzB79/,iv:3t/0V4Chopg5SffE6P1JcB4PNGzLWtrsC3Gio03b5bk=,tag:o30xHwtx3sLMihwtuNUDoQ==,type:str] +dns_server_ipv4_0: ENC[AES256_GCM,data:PksLLL7TivYagw==,iv:/an1zGWRy2AhQBrC9AlJq2bwftHtMe4AQcenPu0GGqk=,tag:vgnre1OAbkcWPPdbpmSrwg==,type:str] +dns_server_ipv4_1: ENC[AES256_GCM,data:yXc1v7Ez978CQQ==,iv:77OcSVmXP4jfZ75xWJj9U+LoA18dBAg3Wrj+q3lz8LY=,tag:Sdfg31yhHNxuMUKRo2Ebgw==,type:str] +dns_server_ipv6_0: ENC[AES256_GCM,data:vrx6yabMcK7PslA=,iv:9wS55xgvcAOdLqYJ1ZDR5NWvBZEyZxgaWWB2EFQbtyg=,tag:tbHL/hAwmLV0Ndmu6Hra6w==,type:str] +dns_server_ipv6_1: ENC[AES256_GCM,data:IfMPanxqDSVlkDk=,iv:JHN2+Es6apKu0yJxwsPaSSJiSNRk/IASTJbo/iRAfjs=,tag:KJcJbPnvxwQTHUepDnAj9g==,type:str] +sops: + age: + - recipient: age1p35h8xyy545vjzjledqsvlvy935zdzl97tyjeejq6qxnh3c2uq5qllurj3 + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBoMGVpSGtHVWdPR0lOTEtC + M0hpbEc3K1ZQS0FHM1FXTzFHWGM1UGZHdkRJCitSK1FsUENoL1hTYlJ6bm1FWklG + TGtHb2JodnZaU1V4QTgxOUVTbHFoTmMKLS0tIEdWNzNIOE1DbkZuU0IxLzU1Q2Rj + aG4yZXZhZmg2cDU2Ym1rdDBUQndabU0K7TUnP0dOb/yDTRPyMbjW5MeB9LHdn7E9 + RDg98FbWKER0Z9JHBRIAFvdvaWl62KEgAsLHb25Jd16/73CedM+W/Q== + -----END AGE ENCRYPTED FILE----- + - recipient: age1ngnflnwfkmadkqugc80qx2z550cpgany2dmsump0mvp0htgvnd8qg8hdjq + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBiTU8xd1ZPeDNNQVRnd01s + REQ3S2tWTXBiWVQ3eHl5V2FlZHkraEl3OVV3CndQczhKaHB4blRxRTdQMzJLZGRq + MTkvOWZkR2dtalE2UjhXQVplQkM4RE0KLS0tIG5wck0ySFFOTDVOWWU5b3NTWjdx + c3ZqVC9kYXRvR0lFR3hkWjZBQjk0dncKlf1biEZVu8Mx1Cc/NpgcG9S7CvJZWSw9 + Ds0YABw1dJWxfgOMuS+IA9UrDdd61u8SyBgEvM4TKVPfP/4l/5lSbA== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2026-01-26T13:18:11Z" + mac: ENC[AES256_GCM,data:oGw0eA5hAd1yuTVZKDnZfqZUujb90kYlJSJbFlslN08+NjdooeKPgsAb5zwTak8quQE9mKpAhJzxvQDKBUkgSPmZMjX7xaQHhbhgoDXb4aGFWT19clvjQuonUT72fecZNxRhX2Cg+qorN1xZUnmOz001Pqh0+lPvWfJWiHsQJp4=,iv:i0bQ3ijVBcS1SeNrOiPeEWNz2MlIXqXJdEhnc0HvsKo=,tag:vlGSDnpdKgGIUsmTab6m9w==,type:str] + unencrypted_suffix: _unencrypted + version: 3.11.0 diff --git a/sheldon/bin/setup.sh b/sheldon/bin/setup.sh deleted file mode 100755 index fd6b5ef6..00000000 --- a/sheldon/bin/setup.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -mkdir -p "$HOME/.config/sheldon" -ln -s "$PWD/sheldon/config.d/plugins.toml" "$HOME/.config/sheldon/plugins.toml" diff --git a/tmux/bin/setup.sh b/tmux/bin/setup.sh deleted file mode 100755 index 45916f9f..00000000 --- a/tmux/bin/setup.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -ln -s $PWD/tmux/config.d/tmux.conf $HOME/.tmux.conf diff --git a/uv/bin/setup.sh b/uv/bin/setup.sh deleted file mode 100755 index 81e37f49..00000000 --- a/uv/bin/setup.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -mkdir -p $HOME/.config/uv - -ln -s $HOME/dotfiles/uv/config.d/uv.toml $HOME/.config/uv diff --git a/uv/config.d/uv.toml b/uv/config.d/uv.toml deleted file mode 100644 index 9594492d..00000000 --- a/uv/config.d/uv.toml +++ /dev/null @@ -1 +0,0 @@ -python-preference = "only-managed" diff --git a/zsh/bin/setup.sh b/zsh/bin/setup.sh deleted file mode 100755 index 98a77193..00000000 --- a/zsh/bin/setup.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -ln -s $PWD/zsh/config.d/zshrc $HOME/.zshrc -mkdir -p $HOME/.config/himkt/dotfiles/zsh/config.d