From 09801ac429f6516a79165647c0cad43d4ed170a3 Mon Sep 17 00:00:00 2001 From: Poby <87608318+smg1024@users.noreply.github.com> Date: Thu, 26 Mar 2026 09:03:35 +0900 Subject: [PATCH] refactor: migrate nix-darwin config to a flake-parts dendritic layout --- README-ko.md | 62 ++++-- README.md | 69 +++--- flake.lock | 82 +++++-- flake.nix | 82 ++----- home/aerospace.nix | 191 ---------------- home/default.nix | 37 ---- hosts/apps.nix | 70 ------ hosts/default.nix | 8 - hosts/fenrir.nix | 24 ++ hosts/host-users.nix | 18 -- hosts/nix-core.nix | 28 --- hosts/system.nix | 208 ------------------ {home => modules/aspects/_cli-tools}/bat.nix | 0 modules/aspects/_cli-tools/default.nix | 13 ++ {home => modules/aspects/_cli-tools}/eza.nix | 0 {home => modules/aspects/_cli-tools}/fd.nix | 0 {home => modules/aspects/_cli-tools}/fzf.nix | 0 {home => modules/aspects/_cli-tools}/jq.nix | 0 .../aspects/_cli-tools}/lazygit.nix | 0 {home => modules/aspects/_cli-tools}/mise.nix | 0 .../aspects/_cli-tools}/ripgrep.nix | 0 .../aspects/_cli-tools}/zoxide.nix | 0 .../aspects/_editor}/nvf/appearance/theme.nix | 0 .../aspects/_editor}/nvf/core/augroups.nix | 0 .../aspects/_editor}/nvf/core/autocmds.nix | 0 .../aspects/_editor}/nvf/core/clipboard.nix | 0 .../aspects/_editor}/nvf/core/keymaps.nix | 0 .../aspects/_editor}/nvf/core/options.nix | 0 .../aspects/_editor}/nvf/core/spellcheck.nix | 0 .../aspects/_editor}/nvf/core/undoFile.nix | 0 .../aspects/_editor}/nvf/default.nix | 0 .../aspects/_editor}/nvf/lsp/autocomplete.nix | 0 .../_editor}/nvf/lsp/languages/bash.nix | 0 .../_editor}/nvf/lsp/languages/default.nix | 4 + .../_editor}/nvf/lsp/languages/html.nix | 0 .../_editor/nvf/lsp/languages/just.nix | 9 + .../_editor}/nvf/lsp/languages/lua.nix | 0 .../_editor}/nvf/lsp/languages/markdown.nix | 0 .../_editor}/nvf/lsp/languages/nix.nix | 0 .../_editor}/nvf/lsp/languages/python.nix | 0 .../_editor/nvf/lsp/languages/toml.nix | 13 ++ .../_editor}/nvf/lsp/languages/yaml.nix | 0 .../aspects/_editor}/nvf/lsp/lsp.nix | 0 .../aspects/_editor}/nvf/lsp/treesitter.nix | 5 + .../aspects/_editor}/nvf/plugins/binds.nix | 0 .../aspects/_editor}/nvf/plugins/fzf-lua.nix | 0 .../aspects/_editor}/nvf/plugins/mini.nix | 0 .../aspects/_editor}/nvf/plugins/terminal.nix | 0 .../aspects/_editor}/nvf/plugins/utility.nix | 0 modules/aspects/_git/default.nix | 6 + {home => modules/aspects/_git}/gh.nix | 0 {home => modules/aspects/_git}/git.nix | 0 modules/aspects/_secrets/default.nix | 5 + {home => modules/aspects/_secrets}/sops.nix | 2 +- modules/aspects/_shell/default.nix | 6 + {home => modules/aspects/_shell}/starship.nix | 0 {home => modules/aspects/_shell}/zsh.nix | 0 modules/aspects/_ssh/default.nix | 5 + {home => modules/aspects/_ssh}/ssh.nix | 0 modules/aspects/_terminal/default.nix | 5 + .../aspects/_terminal}/terminal.nix | 0 .../aspects/_terminal}/wezterm.lua | 0 modules/aspects/activation.nix | 31 +++ modules/aspects/base.nix | 33 +++ modules/aspects/cli-tools.nix | 7 + modules/aspects/desktop.nix | 159 +++++++++++++ modules/aspects/editor.nix | 7 + modules/aspects/fenrir.nix | 17 ++ modules/aspects/fonts.nix | 14 ++ modules/aspects/git.nix | 7 + modules/aspects/homebrew.nix | 52 +++++ modules/aspects/macos-defaults.nix | 136 ++++++++++++ modules/aspects/nix-core.nix | 30 +++ modules/aspects/secrets.nix | 7 + modules/aspects/shell.nix | 15 ++ modules/aspects/ssh.nix | 7 + modules/aspects/sudo-auth.nix | 8 + modules/aspects/system-packages.nix | 16 ++ modules/aspects/terminal.nix | 7 + modules/flake/darwin-configurations.nix | 70 ++++++ modules/flake/darwin-context.nix | 39 ++++ modules/flake/default.nix | 6 + modules/flake/home-context.nix | 36 +++ modules/flake/options.nix | 60 +++++ 84 files changed, 1029 insertions(+), 687 deletions(-) delete mode 100644 home/aerospace.nix delete mode 100755 home/default.nix delete mode 100644 hosts/apps.nix delete mode 100644 hosts/default.nix create mode 100644 hosts/fenrir.nix delete mode 100644 hosts/host-users.nix delete mode 100644 hosts/nix-core.nix delete mode 100644 hosts/system.nix rename {home => modules/aspects/_cli-tools}/bat.nix (100%) create mode 100644 modules/aspects/_cli-tools/default.nix rename {home => modules/aspects/_cli-tools}/eza.nix (100%) rename {home => modules/aspects/_cli-tools}/fd.nix (100%) rename {home => modules/aspects/_cli-tools}/fzf.nix (100%) rename {home => modules/aspects/_cli-tools}/jq.nix (100%) rename {home => modules/aspects/_cli-tools}/lazygit.nix (100%) rename {home => modules/aspects/_cli-tools}/mise.nix (100%) rename {home => modules/aspects/_cli-tools}/ripgrep.nix (100%) rename {home => modules/aspects/_cli-tools}/zoxide.nix (100%) rename {home => modules/aspects/_editor}/nvf/appearance/theme.nix (100%) rename {home => modules/aspects/_editor}/nvf/core/augroups.nix (100%) rename {home => modules/aspects/_editor}/nvf/core/autocmds.nix (100%) rename {home => modules/aspects/_editor}/nvf/core/clipboard.nix (100%) rename {home => modules/aspects/_editor}/nvf/core/keymaps.nix (100%) rename {home => modules/aspects/_editor}/nvf/core/options.nix (100%) rename {home => modules/aspects/_editor}/nvf/core/spellcheck.nix (100%) rename {home => modules/aspects/_editor}/nvf/core/undoFile.nix (100%) rename {home => modules/aspects/_editor}/nvf/default.nix (100%) rename {home => modules/aspects/_editor}/nvf/lsp/autocomplete.nix (100%) rename {home => modules/aspects/_editor}/nvf/lsp/languages/bash.nix (100%) rename {home => modules/aspects/_editor}/nvf/lsp/languages/default.nix (80%) rename {home => modules/aspects/_editor}/nvf/lsp/languages/html.nix (100%) create mode 100644 modules/aspects/_editor/nvf/lsp/languages/just.nix rename {home => modules/aspects/_editor}/nvf/lsp/languages/lua.nix (100%) rename {home => modules/aspects/_editor}/nvf/lsp/languages/markdown.nix (100%) rename {home => modules/aspects/_editor}/nvf/lsp/languages/nix.nix (100%) rename {home => modules/aspects/_editor}/nvf/lsp/languages/python.nix (100%) create mode 100644 modules/aspects/_editor/nvf/lsp/languages/toml.nix rename {home => modules/aspects/_editor}/nvf/lsp/languages/yaml.nix (100%) rename {home => modules/aspects/_editor}/nvf/lsp/lsp.nix (100%) rename {home => modules/aspects/_editor}/nvf/lsp/treesitter.nix (83%) rename {home => modules/aspects/_editor}/nvf/plugins/binds.nix (100%) rename {home => modules/aspects/_editor}/nvf/plugins/fzf-lua.nix (100%) rename {home => modules/aspects/_editor}/nvf/plugins/mini.nix (100%) rename {home => modules/aspects/_editor}/nvf/plugins/terminal.nix (100%) rename {home => modules/aspects/_editor}/nvf/plugins/utility.nix (100%) create mode 100644 modules/aspects/_git/default.nix rename {home => modules/aspects/_git}/gh.nix (100%) rename {home => modules/aspects/_git}/git.nix (100%) create mode 100644 modules/aspects/_secrets/default.nix rename {home => modules/aspects/_secrets}/sops.nix (79%) create mode 100644 modules/aspects/_shell/default.nix rename {home => modules/aspects/_shell}/starship.nix (100%) rename {home => modules/aspects/_shell}/zsh.nix (100%) create mode 100644 modules/aspects/_ssh/default.nix rename {home => modules/aspects/_ssh}/ssh.nix (100%) create mode 100644 modules/aspects/_terminal/default.nix rename {home => modules/aspects/_terminal}/terminal.nix (100%) rename {home => modules/aspects/_terminal}/wezterm.lua (100%) create mode 100644 modules/aspects/activation.nix create mode 100644 modules/aspects/base.nix create mode 100644 modules/aspects/cli-tools.nix create mode 100644 modules/aspects/desktop.nix create mode 100644 modules/aspects/editor.nix create mode 100644 modules/aspects/fenrir.nix create mode 100644 modules/aspects/fonts.nix create mode 100644 modules/aspects/git.nix create mode 100644 modules/aspects/homebrew.nix create mode 100644 modules/aspects/macos-defaults.nix create mode 100644 modules/aspects/nix-core.nix create mode 100644 modules/aspects/secrets.nix create mode 100644 modules/aspects/shell.nix create mode 100644 modules/aspects/ssh.nix create mode 100644 modules/aspects/sudo-auth.nix create mode 100644 modules/aspects/system-packages.nix create mode 100644 modules/aspects/terminal.nix create mode 100644 modules/flake/darwin-configurations.nix create mode 100644 modules/flake/darwin-context.nix create mode 100644 modules/flake/default.nix create mode 100644 modules/flake/home-context.nix create mode 100644 modules/flake/options.nix diff --git a/README-ko.md b/README-ko.md index 4ad89d4..9a7c3f4 100644 --- a/README-ko.md +++ b/README-ko.md @@ -5,9 +5,9 @@ ## 이 저장소가 관리하는 것 -- `hosts/`의 시스템 레벨 macOS 설정 -- `home/`의 사용자 레벨 도구/셸/터미널/에디터 설정 -- `hosts/apps.nix`의 선언적 Homebrew tap/app/cask 관리 +- `modules/flake/`의 flake 조립 및 호스트 구성 생성 +- `modules/aspects/`의 자동 발견 Darwin/Home Manager aspect +- `hosts/`의 자동 발견 멀티 호스트 선언 - `secrets/` + `.sops.yaml`의 SOPS 암호화 시크릿 ## 사전 요구사항 @@ -23,15 +23,14 @@ ## 저장소 구조 -- `flake.nix`: flake input/output 및 `darwinConfigurations` +- `flake.nix`: `flake-parts` 진입점과 flake input - `Justfile`: 일상 명령(`darwin`, `darwin-debug`, `fmt`, `up`, `gc` 등) -- `hosts/`: 시스템 모듈 - - `default.nix` - - `nix-core.nix` - - `system.nix` - - `apps.nix` - - `host-users.nix` -- `home/`: Home Manager 모듈(`git.nix`, `zsh.nix`, `nvf/`, `aerospace.nix` 등) +- `modules/flake/`: 저장소 옵션, Darwin 조립, 공유 context 모듈 +- `modules/aspects/`: `base`, `homebrew`, `shell`, `editor`, `desktop` 같은 + 이름 있는 자동 발견 aspect 진입 모듈 +- `modules/aspects/_*/`: 공개 aspect를 뒷받침하는, 자동 로딩에서 제외되는 + 내부 구현 트리 +- `hosts/`: `system`과 flat `features` 목록을 등록하는 자동 발견 호스트 선언 - `secrets/`: 암호화된 시크릿 파일(`poby.yaml`) ## 자주 쓰는 명령 @@ -53,11 +52,14 @@ just fmt . just up # 특정 input 하나만 업데이트 -just upp nixpkgs-darwin +just upp nixpkgs # 스위치 없이 빌드 검증(예시 호스트: fenrir) nix build .#darwinConfigurations.fenrir.system --extra-experimental-features 'nix-command flakes' +# 실제 빌드 없이 dry-run 검증 +nix build .#darwinConfigurations.fenrir.system --dry-run --extra-experimental-features 'nix-command flakes' + # 시스템 프로필 히스토리 확인 / 오래된 generation 정리 just history just clean @@ -66,18 +68,38 @@ just gc ## 설정 노트 -- `flake.nix`는 현재 `hostname` 기반으로 하나의 `darwinConfigurations` 항목을 - 만들고, 시스템 모듈은 `./hosts`에서 import 합니다. -- `home/default.nix`에서 사용자 모듈(셸, git, nvf, aerospace, sops, ssh)을 - 조합합니다. -- Aerospace 멀티 모니터 워크스페이스 할당은 `home/aerospace.nix`에 있습니다. -- 자주 업데이트되는 앱은 Homebrew 중심으로 `hosts/apps.nix`에서 관리합니다. +- `flake.nix`는 이제 `flake-parts`를 사용하고 `./modules/flake`는 명시적으로 + 유지한 채 `import-tree`로 `./modules/aspects`와 `./hosts`를 자동 발견합니다. +- `hosts/fenrir.nix`가 현재 호스트 선언이며 `fenrir`를 하나의 flat feature + 목록에 매핑합니다. +- `modules/flake/darwin-configurations.nix`가 각 호스트의 + `darwinConfigurations.`를 만들고, 사용자 `poby`의 Home Manager를 + nix-darwin 안에 통합합니다. +- `modules/aspects/`가 호스트가 선택하는 기능 vocabulary입니다. 현재 feature + 집합은 `base`, `nix-core`, `system-packages`, `homebrew`, + `macos-defaults`, `activation`, `fonts`, `sudo-auth`, `shell`, + `cli-tools`, `git`, `ssh`, `secrets`, `terminal`, `editor`, `desktop`, + `fenrir` 입니다. +- `cli-tools` aspect가 `zoxide`를 포함한 CLI 사용자 도구 묶음을 담당합니다. +- `modules/aspects/_*/`는 자동 발견에서 제외되는 내부 구현 경로입니다. + 이 저장소는 `/_`가 포함된 경로를 `import-tree`가 건너뛴다는 규칙을 사용해 + NVF 같은 서브트리를 보호합니다. +- 이번 단계에서는 Home Manager를 Darwin 내부에서만 사용하며, 별도의 + `homeConfigurations` 출력은 만들지 않습니다. + +## 호스트 추가 방법 + +- `hosts/.nix` 파일을 만듭니다. +- `repo.hosts..system`을 등록합니다. +- `repo.hosts..features`에 사용할 aspect 이름 목록을 등록합니다. +- 호스트 전용 동작은 공유 feature를 수정하지 말고 `modules/aspects/`에 새 + aspect로 추가합니다. ## 시크릿 - 시크릿은 `secrets/*.yaml`에 암호화해서 보관합니다. - `.sops.yaml`이 `secrets/.*\.yaml`에 대한 암호화 규칙을 강제합니다. -- Home Manager는 `home/sops.nix`를 통해 `secrets/poby.yaml`에서 아래 항목을 +- Home Manager는 `secrets` aspect를 통해 `secrets/poby.yaml`에서 아래 항목을 읽습니다. - `github_ssh_key` - `github_cli_token` @@ -87,5 +109,7 @@ just gc - 자세한 평가/빌드 로그가 필요하면 `just darwin-debug `을 사용하세요. - 특정 호스트 평가가 실패하면 해당 호스트가 `darwinConfigurations`에 정의됐는지 확인하세요. +- 의존성 그래프만 확인하고 싶다면 + `nix build .#darwinConfigurations..system --dry-run`을 먼저 실행하세요. - 빌드 성공 후에도 설정 반영이 이상하면 switch를 다시 실행하고 활성 hostname/config를 확인하세요. diff --git a/README.md b/README.md index dcfb413..b46679e 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ Declarative macOS setup with `nix-darwin`, `home-manager`, `nix-homebrew`, and ## What This Repo Manages -- System-level macOS configuration in `hosts/` -- User-level tooling, shell, terminal, and editor config in `home/` -- Declarative Homebrew taps/apps/casks in `hosts/apps.nix` +- Flake orchestration and host assembly in `modules/flake/` +- Auto-discovered Darwin and Home Manager aspects in `modules/aspects/` +- Auto-discovered host declarations in `hosts/` - Encrypted secrets via SOPS (`secrets/` + `.sops.yaml`) ## Prerequisites @@ -25,16 +25,15 @@ Declarative macOS setup with `nix-darwin`, `home-manager`, `nix-homebrew`, and ## Repository Layout -- `flake.nix`: flake inputs/outputs and `darwinConfigurations` +- `flake.nix`: `flake-parts` entrypoint and flake inputs - `Justfile`: day-to-day commands (`darwin`, `darwin-debug`, `fmt`, `up`, `gc`) -- `hosts/`: system modules - - `default.nix` - - `nix-core.nix` - - `system.nix` - - `apps.nix` - - `host-users.nix` -- `home/`: Home Manager modules (`git.nix`, `zsh.nix`, `nvf/`, `aerospace.nix`, - etc.) +- `modules/flake/`: repo options, Darwin assembly, and shared context modules +- `modules/aspects/`: auto-discovered aspect entry modules such as `base`, + `homebrew`, `shell`, `editor`, and `desktop` +- `modules/aspects/_*/`: ignored internal implementation trees that back the + public aspect entry modules +- `hosts/`: auto-discovered host declarations that register `system` and a flat + `features` list - `secrets/`: encrypted secret files (`poby.yaml`) ## Common Commands @@ -56,11 +55,14 @@ just fmt . just up # Update one flake input -just upp nixpkgs-darwin +just upp nixpkgs # Validate build without switching (example host: fenrir) nix build .#darwinConfigurations.fenrir.system --extra-experimental-features 'nix-command flakes' +# Validate without realizing a full build +nix build .#darwinConfigurations.fenrir.system --dry-run --extra-experimental-features 'nix-command flakes' + # Inspect profile history / cleanup old generations just history just clean @@ -69,19 +71,36 @@ just gc ## Configuration Notes -- `flake.nix` currently defines one `darwinConfigurations` entry from - `hostname`, and imports system modules through `./hosts`. -- `home/default.nix` composes user modules (shell, git, nvf, aerospace, sops, - ssh). -- Aerospace multi-monitor workspace assignment lives in `home/aerospace.nix`. -- Homebrew-first app management (for frequently updated apps) is in - `hosts/apps.nix`. +- `flake.nix` now uses `flake-parts`, keeps `./modules/flake` explicit, and + auto-discovers `./modules/aspects` and `./hosts` through `import-tree`. +- `hosts/fenrir.nix` is the current host declaration and maps `fenrir` to one + flat feature list. +- `modules/flake/darwin-configurations.nix` assembles each host’s + `darwinConfigurations.` output and embeds Home Manager for user `poby`. +- `modules/aspects/` is the feature vocabulary for hosts. The current feature + set is `base`, `nix-core`, `system-packages`, `homebrew`, + `macos-defaults`, `activation`, `fonts`, `sudo-auth`, `shell`, `cli-tools`, + `git`, `ssh`, `secrets`, `terminal`, `editor`, `desktop`, and `fenrir`. +- The `cli-tools` aspect owns the CLI user tool set, including `zoxide`. +- `modules/aspects/_*/` contains implementation files that are intentionally not + auto-loaded. `import-tree` skips paths containing `/_`, which is the repo’s + convention for internal helpers and subtrees like the NVF source. +- Home Manager is Darwin-integrated only in this phase; no standalone + `homeConfigurations` output is exposed. + +## Adding A Host + +- Create `hosts/.nix`. +- Register `repo.hosts..system`. +- Register `repo.hosts..features` with the desired aspect names. +- Add any host-specific behavior as a new aspect in `modules/aspects/` instead + of modifying shared features. ## Secrets - Keep secrets encrypted in `secrets/*.yaml`. - `.sops.yaml` enforces encryption rules for `secrets/.*\.yaml`. -- Home Manager reads from `secrets/poby.yaml` via `home/sops.nix`: +- Home Manager reads from `secrets/poby.yaml` via the `secrets` aspect: - `github_ssh_key` - `github_cli_token` @@ -89,10 +108,8 @@ just gc - Use `just darwin-debug ` for detailed evaluation/build output. - If evaluation fails for a host, verify it exists under `darwinConfigurations`. +- Dry-run evaluation with + `nix build .#darwinConfigurations..system --dry-run` before a full + switch when you only want to confirm the dependency graph. - If settings look stale after a successful build, run switch again and verify active hostname/config values. - -## Milestone - -- [ ] `multi-host implementation` -- [ ] Dentritic Pattern - using flake-parts diff --git a/flake.lock b/flake.lock index 921aba9..ba1aef4 100644 --- a/flake.lock +++ b/flake.lock @@ -20,7 +20,7 @@ "darwin": { "inputs": { "nixpkgs": [ - "nixpkgs-darwin" + "nixpkgs" ] }, "locked": { @@ -55,6 +55,24 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1772408722, + "narHash": "sha256-rHuJtdcOjK7rAHpHphUb1iCvgkU3GpfvicLMwwnfMT0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f20dc5d9b8027381c474144ecabc9034d6a839a3", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "nvf", @@ -78,7 +96,7 @@ "home-manager": { "inputs": { "nixpkgs": [ - "nixpkgs-darwin" + "nixpkgs" ] }, "locked": { @@ -128,6 +146,21 @@ "type": "github" } }, + "import-tree": { + "locked": { + "lastModified": 1773693634, + "narHash": "sha256-BtZ2dtkBdSUnFPPFc+n0kcMbgaTxzFNPv2iaO326Ffg=", + "owner": "vic", + "repo": "import-tree", + "rev": "c41e7d58045f9057880b0d85e1152d6a4430dbf1", + "type": "github" + }, + "original": { + "owner": "vic", + "repo": "import-tree", + "type": "github" + } + }, "mnw": { "locked": { "lastModified": 1770419553, @@ -185,25 +218,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1773231277, - "narHash": "sha256-Xy3WEpUAbpsz8ydgvVAQAGGB/WB+8cNA5cshiL0McTI=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "75690239f08f885ca9b0267580101f60d10fbe62", - "type": "github" - }, - "original": { - "id": "nixpkgs", - "type": "indirect" - } - }, - "nixpkgs-darwin": { - "locked": { - "lastModified": 1773282714, - "narHash": "sha256-at2PNNVNoTfXBe3bA6pgff+CKOwdBWUZCUBIfXGrXsU=", + "lastModified": 1774216008, + "narHash": "sha256-Z/FO3AI2tL6pTJfGodMvNccEurAJJmWEbsv4psp90z4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a8556879c286b4a40a717a416ae61818c26d1ac8", + "rev": "98bf8103e311377ca1d648c22f56332756d89bb2", "type": "github" }, "original": { @@ -213,10 +232,25 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1772328832, + "narHash": "sha256-e+/T/pmEkLP6BHhYjx6GmwP5ivonQQn0bJdH9YrRB+Q=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "c185c7a5e5dd8f9add5b2f8ebeff00888b070742", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, "nvf": { "inputs": { "flake-compat": "flake-compat", - "flake-parts": "flake-parts", + "flake-parts": "flake-parts_2", "mnw": "mnw", "ndg": "ndg", "nixpkgs": [ @@ -241,12 +275,16 @@ "root": { "inputs": { "darwin": "darwin", + "flake-parts": "flake-parts", "home-manager": "home-manager", "homebrew-cask": "homebrew-cask", "homebrew-core": "homebrew-core", + "import-tree": "import-tree", "nix-homebrew": "nix-homebrew", "nixpkgs": "nixpkgs", - "nixpkgs-darwin": "nixpkgs-darwin", + "nixpkgs-darwin": [ + "nixpkgs" + ], "nvf": "nvf", "sops-nix": "sops-nix" } @@ -254,7 +292,7 @@ "sops-nix": { "inputs": { "nixpkgs": [ - "nixpkgs-darwin" + "nixpkgs" ] }, "locked": { diff --git a/flake.nix b/flake.nix index 25ea9f8..78386be 100644 --- a/flake.nix +++ b/flake.nix @@ -1,32 +1,25 @@ { description = "Nix for Poby's MacOS"; - # TODO: is this necessary? - # nixConfig = { - # substituters = [ - # "https://nix-community.cachix.org" - # "https://cache.nixos.org" - # ]; - # }; - inputs = { - # nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-unstable"; # comment out for unstable version - nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-25.11-darwin"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-25.11-darwin"; + nixpkgs-darwin.follows = "nixpkgs"; + + flake-parts.url = "github:hercules-ci/flake-parts"; + import-tree.url = "github:vic/import-tree"; home-manager = { url = "github:nix-community/home-manager/release-25.11"; - inputs.nixpkgs.follows = "nixpkgs-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; }; darwin = { url = "github:nix-darwin/nix-darwin/nix-darwin-25.11"; - inputs.nixpkgs.follows = "nixpkgs-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; }; - # Homebrew nix-homebrew.url = "github:zhaofengli/nix-homebrew"; - # Optional: Declarative tap management homebrew-core = { url = "github:homebrew/homebrew-core"; flake = false; @@ -36,61 +29,32 @@ flake = false; }; - # NVF for neovim nvf = { url = "github:notashelf/nvf"; inputs.nixpkgs.follows = "nixpkgs"; }; - # sops-nix for secrets sops-nix = { url = "github:Mic92/sops-nix"; - inputs.nixpkgs.follows = "nixpkgs-darwin"; + inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = inputs @ { - self, - nixpkgs, - darwin, - home-manager, - nvf, - sops-nix, - nix-homebrew, - ... - }: let - system = "aarch64-darwin"; - username = "poby"; - useremail = "smg981024@gmail.com"; - hostname = "fenrir"; # TODO break down to multiple hosts - - specialArgs = - inputs - // { - inherit username useremail hostname; - }; - in { - darwinConfigurations."${hostname}" = darwin.lib.darwinSystem { - inherit system specialArgs; - modules = [ - ./hosts - nix-homebrew.darwinModules.nix-homebrew - home-manager.darwinModules.home-manager - { - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - backupFileExtension = "backup"; - extraSpecialArgs = specialArgs; - sharedModules = [ - nvf.homeManagerModules.nvf - sops-nix.homeManagerModules.sops - ]; - users.${username} = import ./home; - }; - } + outputs = inputs @ {flake-parts, ...}: + flake-parts.lib.mkFlake {inherit inputs;} { + imports = [ + inputs.flake-parts.flakeModules.modules + ./modules/flake + (inputs.import-tree ./modules/aspects) + (inputs.import-tree ./hosts) ]; + + systems = [ + "aarch64-darwin" + ]; + + perSystem = {pkgs, ...}: { + formatter = pkgs.alejandra; + }; }; - formatter.${system} = nixpkgs.legacyPackages.${system}.alejandra; - }; } diff --git a/home/aerospace.nix b/home/aerospace.nix deleted file mode 100644 index 3e84396..0000000 --- a/home/aerospace.nix +++ /dev/null @@ -1,191 +0,0 @@ -{ - programs.aerospace = { - enable = true; - userSettings = { - start-at-login = true; - accordion-padding = 10; - default-root-container-layout = "tiles"; - default-root-container-orientation = "auto"; - on-focused-monitor-changed = ["move-mouse monitor-lazy-center"]; - automatically-unhide-macos-hidden-apps = false; - # persistent-workspaces = [ "1" "2" "3" "4" "5" "6" "7" "8" "9" ]; - - key-mapping = { - preset = "qwerty"; - }; - - gaps = { - inner.horizontal = 3; - inner.vertical = 3; - outer.left = 3; - outer.bottom = 3; - outer.top = 3; - outer.right = 3; - }; - - mode.main.binding = { - alt-slash = "layout tiles horizontal vertical"; - alt-comma = "layout accordion horizontal vertical"; - - alt-h = "focus left"; - alt-j = "focus down"; - alt-k = "focus up"; - alt-l = "focus right"; - - alt-shift-h = "move left"; - alt-shift-j = "move down"; - alt-shift-k = "move up"; - alt-shift-l = "move right"; - - alt-minus = "resize smart -50"; - alt-equal = "resize smart +50"; - - alt-1 = "workspace 1"; - alt-2 = "workspace 2"; - alt-3 = "workspace 3"; - alt-4 = "workspace 4"; - alt-5 = "workspace 5"; - alt-6 = "workspace 6"; - alt-7 = "workspace 7"; - alt-8 = "workspace 8"; - alt-9 = "workspace 9"; - - alt-shift-1 = [ - "move-node-to-workspace 1" - "workspace 1" - ]; - alt-shift-2 = [ - "move-node-to-workspace 2" - "workspace 2" - ]; - alt-shift-3 = [ - "move-node-to-workspace 3" - "workspace 3" - ]; - alt-shift-4 = [ - "move-node-to-workspace 4" - "workspace 4" - ]; - alt-shift-5 = [ - "move-node-to-workspace 5" - "workspace 5" - ]; - alt-shift-6 = [ - "move-node-to-workspace 6" - "workspace 6" - ]; - alt-shift-7 = [ - "move-node-to-workspace 7" - "workspace 7" - ]; - alt-shift-8 = [ - "move-node-to-workspace 8" - "workspace 8" - ]; - alt-shift-9 = [ - "move-node-to-workspace 9" - "workspace 9" - ]; - - alt-tab = "workspace-back-and-forth"; - alt-shift-tab = "move-node-to-monitor --wrap-around next"; - - alt-shift-semicolon = "mode service"; - }; - - mode.service.binding = { - esc = [ - "reload-config" - "mode main" - ]; - r = [ - "flatten-workspace-tree" - "mode main" - ]; - f = [ - "layout floating tiling" - "mode main" - ]; - backspace = [ - "close-all-windows-but-current" - "mode main" - ]; - - alt-shift-h = [ - "join-with left" - "mode main" - ]; - alt-shift-j = [ - "join-with down" - "mode main" - ]; - alt-shift-k = [ - "join-with up" - "mode main" - ]; - alt-shift-l = [ - "join-with right" - "mode main" - ]; - }; - - workspace-to-monitor-force-assignment = { - # "workspace" = "monitor" - "1" = ["secondary" "main"]; - "2" = ["secondary" "main"]; - "3" = ["secondary" "main"]; - "4" = ["secondary" "main"]; - "5" = ["secondary" "main"]; - "6" = "main"; - "7" = "main"; - "8" = "main"; - "9" = "main"; - }; - - on-window-detected = [ - { - "if" = { - app-id = "com.apple.finder"; - }; - check-further-callbacks = true; - run = ["layout floating"]; - } - { - "if" = { - app-id = "com.apple.Notes"; - }; - check-further-callbacks = true; - run = ["layout floating"]; - } - { - "if" = { - app-id = "com.daymore.Across"; - }; - check-further-callbacks = true; - run = ["layout floating"]; - } - { - "if" = { - app-id = "com.bitwarden.desktop"; - }; - check-further-callbacks = true; - run = ["layout floating"]; - } - { - "if" = { - app-id = "org.hammerspoon.Hammerspoon"; - }; - check-further-callbacks = true; - run = ["layout floating"]; - } - { - "if" = { - app-id = "com.utmapp.UTM"; - }; - check-further-callbacks = true; - run = ["layout floating"]; - } - ]; - }; - }; -} diff --git a/home/default.nix b/home/default.nix deleted file mode 100755 index af130af..0000000 --- a/home/default.nix +++ /dev/null @@ -1,37 +0,0 @@ -{ - pkgs, - username, - ... -}: { - imports = [ - ./fd.nix - ./fzf.nix - ./gh.nix - ./git.nix - ./nvf - ./ripgrep.nix - ./starship.nix - ./zoxide.nix - ./zsh.nix - ./eza.nix - ./jq.nix - ./lazygit.nix - ./mise.nix - ./terminal.nix - ./bat.nix - ./aerospace.nix - ./sops.nix - ./ssh.nix - ]; - - home = { - inherit username; - homeDirectory = "/Users/${username}"; - stateVersion = "25.11"; - - # packages that are not available via programs and does not need regular updates - packages = with pkgs; []; - }; - - programs.home-manager.enable = true; -} diff --git a/hosts/apps.nix b/hosts/apps.nix deleted file mode 100644 index 27c0277..0000000 --- a/hosts/apps.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ - pkgs, - config, - username, - homebrew-core, - homebrew-cask, - ... -}: { - nixpkgs.config.allowUnfree = true; - - environment.systemPackages = with pkgs; [ - git - neovim - just # use Justfile to simplify nix-darwin's commands - tree - fastfetchMinimal - ]; - environment.variables.EDITOR = "nvim"; - - nix-homebrew = { - enable = true; - enableRosetta = true; - user = username; - taps = { - "homebrew/homebrew-core" = homebrew-core; - "homebrew/homebrew-cask" = homebrew-cask; - }; - mutableTaps = false; - }; - - homebrew = { - enable = true; - - onActivation = { - autoUpdate = true; - cleanup = "zap"; - }; - - # Applications to install from Mac App Store using mas. - masApps = { - KakaoTalk = 869223134; - Across = 6444851827; - Bitwarden = 1352778147; - }; - - taps = builtins.attrNames config.nix-homebrew.taps; - - # WARNING only include those not in nixpkgs - brews = [ - "gemini-cli" - ]; - - casks = [ - "batfi" - "hammerspoon" - "shottr" # stable version dmg link not found - "arc" - "codex" - "claude-code" - "telegram" - "raycast" - "jordanbaird-ice" - "keka" - "kekaexternalhelper" - "stats" - "iina" - "utm" - ]; - }; -} diff --git a/hosts/default.nix b/hosts/default.nix deleted file mode 100644 index 2c9da03..0000000 --- a/hosts/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{...}: { - imports = [ - ./apps.nix - ./host-users.nix - ./nix-core.nix - ./system.nix - ]; -} diff --git a/hosts/fenrir.nix b/hosts/fenrir.nix new file mode 100644 index 0000000..7c56bfb --- /dev/null +++ b/hosts/fenrir.nix @@ -0,0 +1,24 @@ +{...}: { + repo.hosts.fenrir = { + system = "aarch64-darwin"; + features = [ + "base" + "nix-core" + "system-packages" + "homebrew" + "macos-defaults" + "activation" + "fonts" + "sudo-auth" + "shell" + "cli-tools" + "git" + "ssh" + "secrets" + "terminal" + "editor" + "desktop" + "fenrir" + ]; + }; +} diff --git a/hosts/host-users.nix b/hosts/host-users.nix deleted file mode 100644 index 9df535e..0000000 --- a/hosts/host-users.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ - username, - hostname, - ... -}: { - networking = { - hostName = hostname; - computerName = hostname; - localHostName = hostname; - }; - - users.users."${username}" = { - home = "/Users/${username}"; - description = username; - }; - - nix.settings.trusted-users = [username]; -} diff --git a/hosts/nix-core.nix b/hosts/nix-core.nix deleted file mode 100644 index cee556b..0000000 --- a/hosts/nix-core.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - pkgs, - lib, - ... -}: { - nix = { - enable = true; - package = pkgs.nix; - - settings = { - experimental-features = [ - "nix-command" - "flakes" - ]; - substituters = ["https://nix-community.cachix.org"]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - builders-use-substitutes = true; - auto-optimise-store = false; # issue https://github.com/NixOS/nix/issues/7273 - }; - - gc = { - automatic = lib.mkDefault true; - options = lib.mkDefault "--delete-older-than 7d"; - }; - }; -} diff --git a/hosts/system.nix b/hosts/system.nix deleted file mode 100644 index 081d2e5..0000000 --- a/hosts/system.nix +++ /dev/null @@ -1,208 +0,0 @@ -{ - pkgs, - config, - username, - hostname, - ... -}: { - time.timeZone = "Asia/Seoul"; - - system = { - primaryUser = username; - stateVersion = 6; - - # symlink /Applications/Nix Apps to /Applications for Spotlight - activationScripts.extraActivation.text = '' - # activateSettings -u will reload the settings from the database and apply them to the current session, - # so we do not need to logout and login again to make the changes take effect. - sudo -u ${username} /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u - ''; - - activationScripts.applications.text = let - env = pkgs.buildEnv { - name = "system-applications"; - paths = config.environment.systemPackages; - pathsToLink = ["/Applications"]; - }; - in - pkgs.lib.mkForce '' - # Set up applications. - echo "setting up /Applications..." >&2 - rm -rf /Applications/Nix\ Apps - mkdir -p /Applications/Nix\ Apps - find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + | - while read -r src; do - app_name=$(basename "$src") - echo "copying $src" >&2 - ${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name" - done - ''; - - defaults = { - loginwindow = { - GuestEnabled = false; - }; - - controlcenter = { - AirDrop = false; - BatteryShowPercentage = false; - Bluetooth = false; - Display = false; - FocusModes = false; - NowPlaying = false; - Sound = false; - }; - - menuExtraClock = { - Show24Hour = true; - ShowDayOfWeek = false; - }; - - dock = { - autohide = true; - autohide-delay = 0.01; - autohide-time-modifier = 0.1; - mineffect = "suck"; - show-recents = false; - tilesize = 50; - magnification = true; - largesize = 70; - showMissionControlGestureEnabled = true; - }; - - finder = { - AppleShowAllFiles = true; - AppleShowAllExtensions = true; - ShowStatusBar = true; - ShowPathbar = true; - FXPreferredViewStyle = "clmv"; - FXRemoveOldTrashItems = true; - _FXEnableColumnAutoSizing = true; - _FXShowPosixPathInTitle = true; - _FXSortFoldersFirst = true; - _FXSortFoldersFirstOnDesktop = true; - FXEnableExtensionChangeWarning = false; - FXDefaultSearchScope = "SCcf"; - NewWindowTarget = "Other"; - NewWindowTargetPath = "/Users/${username}/Downloads"; - ShowExternalHardDrivesOnDesktop = true; - ShowHardDrivesOnDesktop = true; - ShowMountedServersOnDesktop = true; - ShowRemovableMediaOnDesktop = true; - QuitMenuItem = true; - }; - - trackpad = { - Clicking = true; - TrackpadRightClick = true; # two finger right click - TrackpadThreeFingerDrag = true; - TrackpadFourFingerHorizSwipeGesture = 2; # swipe between full-screen applications - TrackpadFourFingerVertSwipeGesture = 2; # down for Mission Control, up for App Expose - TrackpadPinch = true; - TrackpadThreeFingerHorizSwipeGesture = 0; # disable for three finger drag - TrackpadThreeFingerVertSwipeGesture = 0; # disable for three finger drag - TrackpadTwoFingerDoubleTapGesture = true; # smart zoom - TrackpadTwoFingerFromRightEdgeSwipeGesture = 0; - }; - - screensaver = { - askForPassword = true; - askForPasswordDelay = 0; - }; - - smb = { - NetBIOSName = hostname; - ServerDescription = hostname; - }; - - WindowManager = { - AppWindowGroupingBehavior = true; - EnableStandardClickToShowDesktop = false; - EnableTilingByEdgeDrag = false; - EnableTilingOptionAccelerator = false; - EnableTopTilingByEdgeDrag = false; - StandardHideDesktopIcons = true; - StandardHideWidgets = true; - }; - - # Customize settings that not supported by nix-darwin directly - # source: https://github.com/yannbertrand/macos-defaults - NSGlobalDomain = { - AppleInterfaceStyle = "Dark"; - AppleKeyboardUIMode = 2; - ApplePressAndHoldEnabled = false; - InitialKeyRepeat = 15; - KeyRepeat = 2; - - AppleShowScrollBars = "WhenScrolling"; - AppleScrollerPagingBehavior = true; - AppleEnableMouseSwipeNavigateWithScrolls = true; - AppleEnableSwipeNavigateWithScrolls = true; - AppleSpacesSwitchOnActivate = true; - - NSAutomaticCapitalizationEnabled = false; - NSAutomaticDashSubstitutionEnabled = false; - NSAutomaticPeriodSubstitutionEnabled = false; - NSAutomaticQuoteSubstitutionEnabled = false; - NSAutomaticSpellingCorrectionEnabled = false; - NSNavPanelExpandedStateForSaveMode = true; - NSNavPanelExpandedStateForSaveMode2 = true; - NSTableViewDefaultSizeMode = 2; - - "com.apple.keyboard.fnState" = true; - "com.apple.sound.beep.feedback" = 0; - }; - - # Customize settings that not supported by nix-darwin directly - CustomSystemPreferences = { - "com.apple.desktopservices" = { - DSDontWriteNetworkStores = true; - DSDontWriteUSBStores = true; - }; - "com.apple.AdLib" = { - allowApplePersonalizedAdvertising = false; - }; - # Prevent Photos from opening automatically when devices are plugged in - "com.apple.ImageCapture".disableHotPlug = true; - "com.apple.dock" = { - springboard-columns = 10; - springboard-rows = 10; - ResetLaunchPad = true; - }; - }; - }; - - keyboard = { - enableKeyMapping = true; # enable key mapping so that we can use `option` as `control` - }; - }; - - # Add ability to used TouchID for sudo authentication - security.pam.services.sudo_local = { - touchIdAuth = true; - watchIdAuth = true; - }; - - programs.zsh = { - enable = true; - }; - - environment = { - shells = [ - pkgs.zsh - ]; - }; - - fonts = { - packages = with pkgs; [ - material-design-icons - font-awesome - pretendard - nerd-fonts.symbols-only - nerd-fonts.jetbrains-mono - nerd-fonts.d2coding - nerd-fonts.iosevka - nerd-fonts.meslo-lg - ]; - }; -} diff --git a/home/bat.nix b/modules/aspects/_cli-tools/bat.nix similarity index 100% rename from home/bat.nix rename to modules/aspects/_cli-tools/bat.nix diff --git a/modules/aspects/_cli-tools/default.nix b/modules/aspects/_cli-tools/default.nix new file mode 100644 index 0000000..981d339 --- /dev/null +++ b/modules/aspects/_cli-tools/default.nix @@ -0,0 +1,13 @@ +{...}: { + imports = [ + ./zoxide.nix + ./bat.nix + ./eza.nix + ./fd.nix + ./fzf.nix + ./jq.nix + ./lazygit.nix + ./mise.nix + ./ripgrep.nix + ]; +} diff --git a/home/eza.nix b/modules/aspects/_cli-tools/eza.nix similarity index 100% rename from home/eza.nix rename to modules/aspects/_cli-tools/eza.nix diff --git a/home/fd.nix b/modules/aspects/_cli-tools/fd.nix similarity index 100% rename from home/fd.nix rename to modules/aspects/_cli-tools/fd.nix diff --git a/home/fzf.nix b/modules/aspects/_cli-tools/fzf.nix similarity index 100% rename from home/fzf.nix rename to modules/aspects/_cli-tools/fzf.nix diff --git a/home/jq.nix b/modules/aspects/_cli-tools/jq.nix similarity index 100% rename from home/jq.nix rename to modules/aspects/_cli-tools/jq.nix diff --git a/home/lazygit.nix b/modules/aspects/_cli-tools/lazygit.nix similarity index 100% rename from home/lazygit.nix rename to modules/aspects/_cli-tools/lazygit.nix diff --git a/home/mise.nix b/modules/aspects/_cli-tools/mise.nix similarity index 100% rename from home/mise.nix rename to modules/aspects/_cli-tools/mise.nix diff --git a/home/ripgrep.nix b/modules/aspects/_cli-tools/ripgrep.nix similarity index 100% rename from home/ripgrep.nix rename to modules/aspects/_cli-tools/ripgrep.nix diff --git a/home/zoxide.nix b/modules/aspects/_cli-tools/zoxide.nix similarity index 100% rename from home/zoxide.nix rename to modules/aspects/_cli-tools/zoxide.nix diff --git a/home/nvf/appearance/theme.nix b/modules/aspects/_editor/nvf/appearance/theme.nix similarity index 100% rename from home/nvf/appearance/theme.nix rename to modules/aspects/_editor/nvf/appearance/theme.nix diff --git a/home/nvf/core/augroups.nix b/modules/aspects/_editor/nvf/core/augroups.nix similarity index 100% rename from home/nvf/core/augroups.nix rename to modules/aspects/_editor/nvf/core/augroups.nix diff --git a/home/nvf/core/autocmds.nix b/modules/aspects/_editor/nvf/core/autocmds.nix similarity index 100% rename from home/nvf/core/autocmds.nix rename to modules/aspects/_editor/nvf/core/autocmds.nix diff --git a/home/nvf/core/clipboard.nix b/modules/aspects/_editor/nvf/core/clipboard.nix similarity index 100% rename from home/nvf/core/clipboard.nix rename to modules/aspects/_editor/nvf/core/clipboard.nix diff --git a/home/nvf/core/keymaps.nix b/modules/aspects/_editor/nvf/core/keymaps.nix similarity index 100% rename from home/nvf/core/keymaps.nix rename to modules/aspects/_editor/nvf/core/keymaps.nix diff --git a/home/nvf/core/options.nix b/modules/aspects/_editor/nvf/core/options.nix similarity index 100% rename from home/nvf/core/options.nix rename to modules/aspects/_editor/nvf/core/options.nix diff --git a/home/nvf/core/spellcheck.nix b/modules/aspects/_editor/nvf/core/spellcheck.nix similarity index 100% rename from home/nvf/core/spellcheck.nix rename to modules/aspects/_editor/nvf/core/spellcheck.nix diff --git a/home/nvf/core/undoFile.nix b/modules/aspects/_editor/nvf/core/undoFile.nix similarity index 100% rename from home/nvf/core/undoFile.nix rename to modules/aspects/_editor/nvf/core/undoFile.nix diff --git a/home/nvf/default.nix b/modules/aspects/_editor/nvf/default.nix similarity index 100% rename from home/nvf/default.nix rename to modules/aspects/_editor/nvf/default.nix diff --git a/home/nvf/lsp/autocomplete.nix b/modules/aspects/_editor/nvf/lsp/autocomplete.nix similarity index 100% rename from home/nvf/lsp/autocomplete.nix rename to modules/aspects/_editor/nvf/lsp/autocomplete.nix diff --git a/home/nvf/lsp/languages/bash.nix b/modules/aspects/_editor/nvf/lsp/languages/bash.nix similarity index 100% rename from home/nvf/lsp/languages/bash.nix rename to modules/aspects/_editor/nvf/lsp/languages/bash.nix diff --git a/home/nvf/lsp/languages/default.nix b/modules/aspects/_editor/nvf/lsp/languages/default.nix similarity index 80% rename from home/nvf/lsp/languages/default.nix rename to modules/aspects/_editor/nvf/lsp/languages/default.nix index b67cb8b..55264e3 100755 --- a/home/nvf/lsp/languages/default.nix +++ b/modules/aspects/_editor/nvf/lsp/languages/default.nix @@ -6,6 +6,8 @@ let markdown = import ./markdown.nix; html = import ./html.nix; yaml = import ./yaml.nix; + toml = import ./toml.nix; + just = import ./just.nix; in { inherit nix @@ -15,5 +17,7 @@ in { markdown html yaml + toml + just ; } diff --git a/home/nvf/lsp/languages/html.nix b/modules/aspects/_editor/nvf/lsp/languages/html.nix similarity index 100% rename from home/nvf/lsp/languages/html.nix rename to modules/aspects/_editor/nvf/lsp/languages/html.nix diff --git a/modules/aspects/_editor/nvf/lsp/languages/just.nix b/modules/aspects/_editor/nvf/lsp/languages/just.nix new file mode 100644 index 0000000..425b6cc --- /dev/null +++ b/modules/aspects/_editor/nvf/lsp/languages/just.nix @@ -0,0 +1,9 @@ +{ + # just + enable = true; + lsp = { + enable = true; + servers = ["just-lsp"]; + }; + treesitter.enable = true; +} diff --git a/home/nvf/lsp/languages/lua.nix b/modules/aspects/_editor/nvf/lsp/languages/lua.nix similarity index 100% rename from home/nvf/lsp/languages/lua.nix rename to modules/aspects/_editor/nvf/lsp/languages/lua.nix diff --git a/home/nvf/lsp/languages/markdown.nix b/modules/aspects/_editor/nvf/lsp/languages/markdown.nix similarity index 100% rename from home/nvf/lsp/languages/markdown.nix rename to modules/aspects/_editor/nvf/lsp/languages/markdown.nix diff --git a/home/nvf/lsp/languages/nix.nix b/modules/aspects/_editor/nvf/lsp/languages/nix.nix similarity index 100% rename from home/nvf/lsp/languages/nix.nix rename to modules/aspects/_editor/nvf/lsp/languages/nix.nix diff --git a/home/nvf/lsp/languages/python.nix b/modules/aspects/_editor/nvf/lsp/languages/python.nix similarity index 100% rename from home/nvf/lsp/languages/python.nix rename to modules/aspects/_editor/nvf/lsp/languages/python.nix diff --git a/modules/aspects/_editor/nvf/lsp/languages/toml.nix b/modules/aspects/_editor/nvf/lsp/languages/toml.nix new file mode 100644 index 0000000..5be27e4 --- /dev/null +++ b/modules/aspects/_editor/nvf/lsp/languages/toml.nix @@ -0,0 +1,13 @@ +{ + # toml + enable = true; + lsp = { + enable = true; + servers = ["taplo"]; + }; + format = { + enable = true; + type = ["taplo"]; + }; + treesitter.enable = true; +} diff --git a/home/nvf/lsp/languages/yaml.nix b/modules/aspects/_editor/nvf/lsp/languages/yaml.nix similarity index 100% rename from home/nvf/lsp/languages/yaml.nix rename to modules/aspects/_editor/nvf/lsp/languages/yaml.nix diff --git a/home/nvf/lsp/lsp.nix b/modules/aspects/_editor/nvf/lsp/lsp.nix similarity index 100% rename from home/nvf/lsp/lsp.nix rename to modules/aspects/_editor/nvf/lsp/lsp.nix diff --git a/home/nvf/lsp/treesitter.nix b/modules/aspects/_editor/nvf/lsp/treesitter.nix similarity index 83% rename from home/nvf/lsp/treesitter.nix rename to modules/aspects/_editor/nvf/lsp/treesitter.nix index da824a3..cab2b59 100755 --- a/home/nvf/lsp/treesitter.nix +++ b/modules/aspects/_editor/nvf/lsp/treesitter.nix @@ -5,7 +5,12 @@ grammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [ nix lua + markdown + html + python yaml + toml + just ]; fold = true; highlight = { diff --git a/home/nvf/plugins/binds.nix b/modules/aspects/_editor/nvf/plugins/binds.nix similarity index 100% rename from home/nvf/plugins/binds.nix rename to modules/aspects/_editor/nvf/plugins/binds.nix diff --git a/home/nvf/plugins/fzf-lua.nix b/modules/aspects/_editor/nvf/plugins/fzf-lua.nix similarity index 100% rename from home/nvf/plugins/fzf-lua.nix rename to modules/aspects/_editor/nvf/plugins/fzf-lua.nix diff --git a/home/nvf/plugins/mini.nix b/modules/aspects/_editor/nvf/plugins/mini.nix similarity index 100% rename from home/nvf/plugins/mini.nix rename to modules/aspects/_editor/nvf/plugins/mini.nix diff --git a/home/nvf/plugins/terminal.nix b/modules/aspects/_editor/nvf/plugins/terminal.nix similarity index 100% rename from home/nvf/plugins/terminal.nix rename to modules/aspects/_editor/nvf/plugins/terminal.nix diff --git a/home/nvf/plugins/utility.nix b/modules/aspects/_editor/nvf/plugins/utility.nix similarity index 100% rename from home/nvf/plugins/utility.nix rename to modules/aspects/_editor/nvf/plugins/utility.nix diff --git a/modules/aspects/_git/default.nix b/modules/aspects/_git/default.nix new file mode 100644 index 0000000..6cf7459 --- /dev/null +++ b/modules/aspects/_git/default.nix @@ -0,0 +1,6 @@ +{...}: { + imports = [ + ./git.nix + ./gh.nix + ]; +} diff --git a/home/gh.nix b/modules/aspects/_git/gh.nix similarity index 100% rename from home/gh.nix rename to modules/aspects/_git/gh.nix diff --git a/home/git.nix b/modules/aspects/_git/git.nix similarity index 100% rename from home/git.nix rename to modules/aspects/_git/git.nix diff --git a/modules/aspects/_secrets/default.nix b/modules/aspects/_secrets/default.nix new file mode 100644 index 0000000..4e14ab5 --- /dev/null +++ b/modules/aspects/_secrets/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./sops.nix + ]; +} diff --git a/home/sops.nix b/modules/aspects/_secrets/sops.nix similarity index 79% rename from home/sops.nix rename to modules/aspects/_secrets/sops.nix index c8b52cf..62bf4d7 100644 --- a/home/sops.nix +++ b/modules/aspects/_secrets/sops.nix @@ -2,7 +2,7 @@ sops = { age.keyFile = "${config.home.homeDirectory}/.config/sops/age/keys.txt"; - defaultSopsFile = ../secrets/poby.yaml; + defaultSopsFile = config.repo.user.secretFile; secrets = { "github_ssh_key" = {}; diff --git a/modules/aspects/_shell/default.nix b/modules/aspects/_shell/default.nix new file mode 100644 index 0000000..fe364e7 --- /dev/null +++ b/modules/aspects/_shell/default.nix @@ -0,0 +1,6 @@ +{...}: { + imports = [ + ./zsh.nix + ./starship.nix + ]; +} diff --git a/home/starship.nix b/modules/aspects/_shell/starship.nix similarity index 100% rename from home/starship.nix rename to modules/aspects/_shell/starship.nix diff --git a/home/zsh.nix b/modules/aspects/_shell/zsh.nix similarity index 100% rename from home/zsh.nix rename to modules/aspects/_shell/zsh.nix diff --git a/modules/aspects/_ssh/default.nix b/modules/aspects/_ssh/default.nix new file mode 100644 index 0000000..f2202aa --- /dev/null +++ b/modules/aspects/_ssh/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./ssh.nix + ]; +} diff --git a/home/ssh.nix b/modules/aspects/_ssh/ssh.nix similarity index 100% rename from home/ssh.nix rename to modules/aspects/_ssh/ssh.nix diff --git a/modules/aspects/_terminal/default.nix b/modules/aspects/_terminal/default.nix new file mode 100644 index 0000000..af93534 --- /dev/null +++ b/modules/aspects/_terminal/default.nix @@ -0,0 +1,5 @@ +{...}: { + imports = [ + ./terminal.nix + ]; +} diff --git a/home/terminal.nix b/modules/aspects/_terminal/terminal.nix similarity index 100% rename from home/terminal.nix rename to modules/aspects/_terminal/terminal.nix diff --git a/home/wezterm.lua b/modules/aspects/_terminal/wezterm.lua similarity index 100% rename from home/wezterm.lua rename to modules/aspects/_terminal/wezterm.lua diff --git a/modules/aspects/activation.nix b/modules/aspects/activation.nix new file mode 100644 index 0000000..8bdda82 --- /dev/null +++ b/modules/aspects/activation.nix @@ -0,0 +1,31 @@ +{...}: { + flake.modules.darwin.activation = { + config, + lib, + pkgs, + ... + }: { + system.activationScripts.extraActivation.text = '' + sudo -u ${config.repo.user.name} /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u + ''; + + system.activationScripts.applications.text = let + env = pkgs.buildEnv { + name = "system-applications"; + paths = config.environment.systemPackages; + pathsToLink = ["/Applications"]; + }; + in + lib.mkForce '' + echo "setting up /Applications..." >&2 + rm -rf /Applications/Nix\ Apps + mkdir -p /Applications/Nix\ Apps + find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + | + while read -r src; do + app_name=$(basename "$src") + echo "copying $src" >&2 + ${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name" + done + ''; + }; +} diff --git a/modules/aspects/base.nix b/modules/aspects/base.nix new file mode 100644 index 0000000..8d43763 --- /dev/null +++ b/modules/aspects/base.nix @@ -0,0 +1,33 @@ +{lib, ...}: { + flake.modules.darwin.base = {config, ...}: { + time.timeZone = "Asia/Seoul"; + + networking = { + hostName = config.repo.host.name; + computerName = config.repo.host.name; + localHostName = config.repo.host.name; + }; + + users.users."${config.repo.user.name}" = { + home = config.repo.user.homeDirectory; + description = config.repo.user.name; + }; + + nix.settings.trusted-users = [config.repo.user.name]; + + system = { + primaryUser = config.repo.user.name; + stateVersion = config.repo.user.darwinStateVersion; + }; + }; + + repo.homeModules.base = {config, ...}: { + home = { + username = lib.mkDefault config.repo.user.name; + homeDirectory = lib.mkDefault config.repo.user.homeDirectory; + stateVersion = lib.mkDefault config.repo.user.homeStateVersion; + }; + + programs.home-manager.enable = true; + }; +} diff --git a/modules/aspects/cli-tools.nix b/modules/aspects/cli-tools.nix new file mode 100644 index 0000000..235f0c9 --- /dev/null +++ b/modules/aspects/cli-tools.nix @@ -0,0 +1,7 @@ +{...}: { + repo.homeModules.cli-tools = { + imports = [ + ./_cli-tools + ]; + }; +} diff --git a/modules/aspects/desktop.nix b/modules/aspects/desktop.nix new file mode 100644 index 0000000..d2c1a1d --- /dev/null +++ b/modules/aspects/desktop.nix @@ -0,0 +1,159 @@ +{...}: { + repo.homeModules.desktop = { + programs.aerospace = { + enable = true; + userSettings = { + start-at-login = true; + accordion-padding = 10; + default-root-container-layout = "tiles"; + default-root-container-orientation = "auto"; + on-focused-monitor-changed = ["move-mouse monitor-lazy-center"]; + automatically-unhide-macos-hidden-apps = false; + + key-mapping = { + preset = "qwerty"; + }; + + gaps = { + inner.horizontal = 3; + inner.vertical = 3; + outer.left = 3; + outer.bottom = 3; + outer.top = 3; + outer.right = 3; + }; + + mode.main.binding = { + alt-slash = "layout tiles horizontal vertical"; + alt-comma = "layout accordion horizontal vertical"; + alt-h = "focus left"; + alt-j = "focus down"; + alt-k = "focus up"; + alt-l = "focus right"; + alt-shift-h = "move left"; + alt-shift-j = "move down"; + alt-shift-k = "move up"; + alt-shift-l = "move right"; + alt-minus = "resize smart -50"; + alt-equal = "resize smart +50"; + alt-1 = "workspace 1"; + alt-2 = "workspace 2"; + alt-3 = "workspace 3"; + alt-4 = "workspace 4"; + alt-5 = "workspace 5"; + alt-6 = "workspace 6"; + alt-7 = "workspace 7"; + alt-8 = "workspace 8"; + alt-9 = "workspace 9"; + alt-shift-1 = [ + "move-node-to-workspace 1" + "workspace 1" + ]; + alt-shift-2 = [ + "move-node-to-workspace 2" + "workspace 2" + ]; + alt-shift-3 = [ + "move-node-to-workspace 3" + "workspace 3" + ]; + alt-shift-4 = [ + "move-node-to-workspace 4" + "workspace 4" + ]; + alt-shift-5 = [ + "move-node-to-workspace 5" + "workspace 5" + ]; + alt-shift-6 = [ + "move-node-to-workspace 6" + "workspace 6" + ]; + alt-shift-7 = [ + "move-node-to-workspace 7" + "workspace 7" + ]; + alt-shift-8 = [ + "move-node-to-workspace 8" + "workspace 8" + ]; + alt-shift-9 = [ + "move-node-to-workspace 9" + "workspace 9" + ]; + alt-tab = "workspace-back-and-forth"; + alt-shift-tab = "move-node-to-monitor --wrap-around next"; + alt-shift-semicolon = "mode service"; + }; + + mode.service.binding = { + esc = [ + "reload-config" + "mode main" + ]; + r = [ + "flatten-workspace-tree" + "mode main" + ]; + f = [ + "layout floating tiling" + "mode main" + ]; + backspace = [ + "close-all-windows-but-current" + "mode main" + ]; + alt-shift-h = [ + "join-with left" + "mode main" + ]; + alt-shift-j = [ + "join-with down" + "mode main" + ]; + alt-shift-k = [ + "join-with up" + "mode main" + ]; + alt-shift-l = [ + "join-with right" + "mode main" + ]; + }; + + on-window-detected = [ + { + "if".app-id = "com.apple.finder"; + check-further-callbacks = true; + run = ["layout floating"]; + } + { + "if".app-id = "com.apple.Notes"; + check-further-callbacks = true; + run = ["layout floating"]; + } + { + "if".app-id = "com.daymore.Across"; + check-further-callbacks = true; + run = ["layout floating"]; + } + { + "if".app-id = "com.bitwarden.desktop"; + check-further-callbacks = true; + run = ["layout floating"]; + } + { + "if".app-id = "org.hammerspoon.Hammerspoon"; + check-further-callbacks = true; + run = ["layout floating"]; + } + { + "if".app-id = "com.utmapp.UTM"; + check-further-callbacks = true; + run = ["layout floating"]; + } + ]; + }; + }; + }; +} diff --git a/modules/aspects/editor.nix b/modules/aspects/editor.nix new file mode 100644 index 0000000..cc0b59c --- /dev/null +++ b/modules/aspects/editor.nix @@ -0,0 +1,7 @@ +{...}: { + repo.homeModules.editor = { + imports = [ + ./_editor/nvf + ]; + }; +} diff --git a/modules/aspects/fenrir.nix b/modules/aspects/fenrir.nix new file mode 100644 index 0000000..5585365 --- /dev/null +++ b/modules/aspects/fenrir.nix @@ -0,0 +1,17 @@ +{...}: { + repo.homeModules.fenrir = { + programs = { + aerospace.userSettings.workspace-to-monitor-force-assignment = { + "1" = ["secondary" "main"]; + "2" = ["secondary" "main"]; + "3" = ["secondary" "main"]; + "4" = ["secondary" "main"]; + "5" = ["secondary" "main"]; + "6" = "main"; + "7" = "main"; + "8" = "main"; + "9" = "main"; + }; + }; + }; +} diff --git a/modules/aspects/fonts.nix b/modules/aspects/fonts.nix new file mode 100644 index 0000000..96e05a7 --- /dev/null +++ b/modules/aspects/fonts.nix @@ -0,0 +1,14 @@ +{...}: { + flake.modules.darwin.fonts = {pkgs, ...}: { + fonts.packages = with pkgs; [ + material-design-icons + font-awesome + pretendard + nerd-fonts.symbols-only + nerd-fonts.jetbrains-mono + nerd-fonts.d2coding + nerd-fonts.iosevka + nerd-fonts.meslo-lg + ]; + }; +} diff --git a/modules/aspects/git.nix b/modules/aspects/git.nix new file mode 100644 index 0000000..94ea2c2 --- /dev/null +++ b/modules/aspects/git.nix @@ -0,0 +1,7 @@ +{...}: { + repo.homeModules.git = { + imports = [ + ./_git + ]; + }; +} diff --git a/modules/aspects/homebrew.nix b/modules/aspects/homebrew.nix new file mode 100644 index 0000000..8f2b98e --- /dev/null +++ b/modules/aspects/homebrew.nix @@ -0,0 +1,52 @@ +{inputs, ...}: { + flake.modules.darwin.homebrew = {config, ...}: { + nix-homebrew = { + enable = true; + enableRosetta = true; + user = config.repo.user.name; + taps = { + "homebrew/homebrew-core" = inputs.homebrew-core; + "homebrew/homebrew-cask" = inputs.homebrew-cask; + }; + mutableTaps = false; + }; + + homebrew = { + enable = true; + + onActivation = { + autoUpdate = true; + cleanup = "zap"; + }; + + masApps = { + KakaoTalk = 869223134; + Across = 6444851827; + Bitwarden = 1352778147; + }; + + taps = builtins.attrNames config.nix-homebrew.taps; + + brews = [ + "gemini-cli" + ]; + + casks = [ + "batfi" + "hammerspoon" + "shottr" + "arc" + "codex" + "claude-code" + "telegram" + "raycast" + "jordanbaird-ice" + "keka" + "kekaexternalhelper" + "stats" + "iina" + "utm" + ]; + }; + }; +} diff --git a/modules/aspects/macos-defaults.nix b/modules/aspects/macos-defaults.nix new file mode 100644 index 0000000..ef5e92f --- /dev/null +++ b/modules/aspects/macos-defaults.nix @@ -0,0 +1,136 @@ +{...}: { + flake.modules.darwin.macos-defaults = {config, ...}: { + system = { + defaults = { + loginwindow = { + GuestEnabled = false; + }; + + controlcenter = { + AirDrop = false; + BatteryShowPercentage = false; + Bluetooth = false; + Display = false; + FocusModes = false; + NowPlaying = false; + Sound = false; + }; + + menuExtraClock = { + Show24Hour = true; + ShowDayOfWeek = false; + }; + + dock = { + autohide = true; + autohide-delay = 0.01; + autohide-time-modifier = 0.1; + mineffect = "suck"; + show-recents = false; + tilesize = 50; + magnification = true; + largesize = 70; + showMissionControlGestureEnabled = true; + }; + + finder = { + AppleShowAllFiles = true; + AppleShowAllExtensions = true; + ShowStatusBar = true; + ShowPathbar = true; + FXPreferredViewStyle = "clmv"; + FXRemoveOldTrashItems = true; + _FXEnableColumnAutoSizing = true; + _FXShowPosixPathInTitle = true; + _FXSortFoldersFirst = true; + _FXSortFoldersFirstOnDesktop = true; + FXEnableExtensionChangeWarning = false; + FXDefaultSearchScope = "SCcf"; + NewWindowTarget = "Other"; + NewWindowTargetPath = "${config.repo.user.homeDirectory}/Downloads"; + ShowExternalHardDrivesOnDesktop = true; + ShowHardDrivesOnDesktop = true; + ShowMountedServersOnDesktop = true; + ShowRemovableMediaOnDesktop = true; + QuitMenuItem = true; + }; + + trackpad = { + Clicking = true; + TrackpadRightClick = true; + TrackpadThreeFingerDrag = true; + TrackpadFourFingerHorizSwipeGesture = 2; + TrackpadFourFingerVertSwipeGesture = 2; + TrackpadPinch = true; + TrackpadThreeFingerHorizSwipeGesture = 0; + TrackpadThreeFingerVertSwipeGesture = 0; + TrackpadTwoFingerDoubleTapGesture = true; + TrackpadTwoFingerFromRightEdgeSwipeGesture = 0; + }; + + screensaver = { + askForPassword = true; + askForPasswordDelay = 0; + }; + + smb = { + NetBIOSName = config.repo.host.name; + ServerDescription = config.repo.host.name; + }; + + WindowManager = { + AppWindowGroupingBehavior = true; + EnableStandardClickToShowDesktop = false; + EnableTilingByEdgeDrag = false; + EnableTilingOptionAccelerator = false; + EnableTopTilingByEdgeDrag = false; + StandardHideDesktopIcons = true; + StandardHideWidgets = true; + }; + + NSGlobalDomain = { + AppleInterfaceStyle = "Dark"; + AppleKeyboardUIMode = 2; + ApplePressAndHoldEnabled = false; + InitialKeyRepeat = 15; + KeyRepeat = 2; + AppleShowScrollBars = "WhenScrolling"; + AppleScrollerPagingBehavior = true; + AppleEnableMouseSwipeNavigateWithScrolls = true; + AppleEnableSwipeNavigateWithScrolls = true; + AppleSpacesSwitchOnActivate = true; + NSAutomaticCapitalizationEnabled = false; + NSAutomaticDashSubstitutionEnabled = false; + NSAutomaticPeriodSubstitutionEnabled = false; + NSAutomaticQuoteSubstitutionEnabled = false; + NSAutomaticSpellingCorrectionEnabled = false; + NSNavPanelExpandedStateForSaveMode = true; + NSNavPanelExpandedStateForSaveMode2 = true; + NSTableViewDefaultSizeMode = 2; + "com.apple.keyboard.fnState" = true; + "com.apple.sound.beep.feedback" = 0; + }; + + CustomSystemPreferences = { + "com.apple.desktopservices" = { + DSDontWriteNetworkStores = true; + DSDontWriteUSBStores = true; + }; + "com.apple.AdLib" = { + allowApplePersonalizedAdvertising = false; + }; + "com.apple.ImageCapture".disableHotPlug = true; + "com.apple.dock" = { + springboard-columns = 10; + springboard-rows = 10; + ResetLaunchPad = true; + }; + }; + }; + + keyboard = { + enableKeyMapping = true; + }; + }; + }; +} diff --git a/modules/aspects/nix-core.nix b/modules/aspects/nix-core.nix new file mode 100644 index 0000000..99fbd91 --- /dev/null +++ b/modules/aspects/nix-core.nix @@ -0,0 +1,30 @@ +{...}: { + flake.modules.darwin.nix-core = { + pkgs, + lib, + ... + }: { + nix = { + enable = true; + package = pkgs.nix; + + settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + substituters = ["https://nix-community.cachix.org"]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + builders-use-substitutes = true; + auto-optimise-store = false; + }; + + gc = { + automatic = lib.mkDefault true; + options = lib.mkDefault "--delete-older-than 7d"; + }; + }; + }; +} diff --git a/modules/aspects/secrets.nix b/modules/aspects/secrets.nix new file mode 100644 index 0000000..4709aea --- /dev/null +++ b/modules/aspects/secrets.nix @@ -0,0 +1,7 @@ +{...}: { + repo.homeModules.secrets = { + imports = [ + ./_secrets + ]; + }; +} diff --git a/modules/aspects/shell.nix b/modules/aspects/shell.nix new file mode 100644 index 0000000..0070ae2 --- /dev/null +++ b/modules/aspects/shell.nix @@ -0,0 +1,15 @@ +{...}: { + flake.modules.darwin.shell = {pkgs, ...}: { + programs.zsh.enable = true; + + environment.shells = [ + pkgs.zsh + ]; + }; + + repo.homeModules.shell = { + imports = [ + ./_shell + ]; + }; +} diff --git a/modules/aspects/ssh.nix b/modules/aspects/ssh.nix new file mode 100644 index 0000000..f3fba3a --- /dev/null +++ b/modules/aspects/ssh.nix @@ -0,0 +1,7 @@ +{...}: { + repo.homeModules.ssh = { + imports = [ + ./_ssh + ]; + }; +} diff --git a/modules/aspects/sudo-auth.nix b/modules/aspects/sudo-auth.nix new file mode 100644 index 0000000..61e3d99 --- /dev/null +++ b/modules/aspects/sudo-auth.nix @@ -0,0 +1,8 @@ +{...}: { + flake.modules.darwin.sudo-auth = { + security.pam.services.sudo_local = { + touchIdAuth = true; + watchIdAuth = true; + }; + }; +} diff --git a/modules/aspects/system-packages.nix b/modules/aspects/system-packages.nix new file mode 100644 index 0000000..8e21148 --- /dev/null +++ b/modules/aspects/system-packages.nix @@ -0,0 +1,16 @@ +{...}: { + flake.modules.darwin.system-packages = {pkgs, ...}: { + nixpkgs.config.allowUnfree = true; + + environment = { + systemPackages = with pkgs; [ + git + neovim + just + tree + fastfetchMinimal + ]; + variables.EDITOR = "nvim"; + }; + }; +} diff --git a/modules/aspects/terminal.nix b/modules/aspects/terminal.nix new file mode 100644 index 0000000..bd79f00 --- /dev/null +++ b/modules/aspects/terminal.nix @@ -0,0 +1,7 @@ +{...}: { + repo.homeModules.terminal = { + imports = [ + ./_terminal + ]; + }; +} diff --git a/modules/flake/darwin-configurations.nix b/modules/flake/darwin-configurations.nix new file mode 100644 index 0000000..bc0532f --- /dev/null +++ b/modules/flake/darwin-configurations.nix @@ -0,0 +1,70 @@ +{ + config, + inputs, + lib, + ... +}: let + userName = config.repo.user.name; + + mkDarwinConfiguration = hostName: hostConfig: let + hostContext = { + name = hostName; + system = hostConfig.system; + features = hostConfig.features; + }; + + darwinModules = builtins.map (feature: config.flake.modules.darwin.${feature} or {}) hostConfig.features; + homeModules = builtins.map (feature: config.repo.homeModules.${feature} or {}) hostConfig.features; + in + inputs.darwin.lib.darwinSystem { + system = hostConfig.system; + modules = + [ + ./darwin-context.nix + { + repo = { + user = config.repo.user; + host = hostContext; + }; + } + ] + ++ darwinModules + ++ [ + inputs.nix-homebrew.darwinModules.nix-homebrew + inputs.home-manager.darwinModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + backupFileExtension = "backup"; + sharedModules = [ + inputs.nvf.homeManagerModules.nvf + inputs.sops-nix.homeManagerModules.sops + ./home-context.nix + ]; + users.${userName}.imports = + [ + { + repo = { + user = { + inherit + (config.repo.user) + name + email + homeDirectory + homeStateVersion + secretFile + ; + }; + host = hostContext; + }; + } + ] + ++ homeModules; + }; + } + ]; + }; +in { + flake.darwinConfigurations = lib.mapAttrs mkDarwinConfiguration config.repo.hosts; +} diff --git a/modules/flake/darwin-context.nix b/modules/flake/darwin-context.nix new file mode 100644 index 0000000..862ea09 --- /dev/null +++ b/modules/flake/darwin-context.nix @@ -0,0 +1,39 @@ +{lib, ...}: let + inherit (lib) mkOption; + types = lib.types; +in { + options.repo = { + user = { + name = mkOption { + type = types.str; + }; + email = mkOption { + type = types.str; + }; + homeDirectory = mkOption { + type = types.str; + }; + homeStateVersion = mkOption { + type = types.str; + }; + darwinStateVersion = mkOption { + type = types.int; + }; + secretFile = mkOption { + type = types.path; + }; + }; + + host = { + name = mkOption { + type = types.str; + }; + system = mkOption { + type = types.str; + }; + features = mkOption { + type = types.listOf types.str; + }; + }; + }; +} diff --git a/modules/flake/default.nix b/modules/flake/default.nix new file mode 100644 index 0000000..834a81a --- /dev/null +++ b/modules/flake/default.nix @@ -0,0 +1,6 @@ +{...}: { + imports = [ + ./options.nix + ./darwin-configurations.nix + ]; +} diff --git a/modules/flake/home-context.nix b/modules/flake/home-context.nix new file mode 100644 index 0000000..1227969 --- /dev/null +++ b/modules/flake/home-context.nix @@ -0,0 +1,36 @@ +{lib, ...}: let + inherit (lib) mkOption; + types = lib.types; +in { + options.repo = { + user = { + name = mkOption { + type = types.str; + }; + email = mkOption { + type = types.str; + }; + homeDirectory = mkOption { + type = types.str; + }; + homeStateVersion = mkOption { + type = types.str; + }; + secretFile = mkOption { + type = types.path; + }; + }; + + host = { + name = mkOption { + type = types.str; + }; + system = mkOption { + type = types.str; + }; + features = mkOption { + type = types.listOf types.str; + }; + }; + }; +} diff --git a/modules/flake/options.nix b/modules/flake/options.nix new file mode 100644 index 0000000..466cc86 --- /dev/null +++ b/modules/flake/options.nix @@ -0,0 +1,60 @@ +{ + config, + lib, + ... +}: let + inherit (lib) mkDefault mkOption; + types = lib.types; +in { + options.repo = { + user = { + name = mkOption { + type = types.str; + }; + email = mkOption { + type = types.str; + }; + homeDirectory = mkOption { + type = types.str; + }; + homeStateVersion = mkOption { + type = types.str; + }; + darwinStateVersion = mkOption { + type = types.int; + }; + secretFile = mkOption { + type = types.path; + }; + }; + + hosts = mkOption { + type = types.attrsOf (types.submodule { + options = { + system = mkOption { + type = types.str; + }; + features = mkOption { + type = types.listOf types.str; + default = []; + }; + }; + }); + default = {}; + }; + + homeModules = mkOption { + type = types.lazyAttrsOf types.deferredModule; + default = {}; + }; + }; + + config.repo.user = { + name = mkDefault "poby"; + email = mkDefault "smg981024@gmail.com"; + homeDirectory = mkDefault "/Users/${config.repo.user.name}"; + homeStateVersion = mkDefault "25.11"; + darwinStateVersion = mkDefault 6; + secretFile = mkDefault ../../secrets/poby.yaml; + }; +}