refactor: migrate nix-darwin config to a flake-parts dendritic layout

This commit is contained in:
Poby 2026-03-26 09:03:35 +09:00
parent f80b0b0d4f
commit 09801ac429
No known key found for this signature in database
84 changed files with 1029 additions and 687 deletions

View file

@ -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.<host>`를 만들고, 사용자 `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/<hostname>.nix` 파일을 만듭니다.
- `repo.hosts.<hostname>.system`을 등록합니다.
- `repo.hosts.<hostname>.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 <hostname>`을 사용하세요.
- 특정 호스트 평가가 실패하면 해당 호스트가 `darwinConfigurations`에 정의됐는지
확인하세요.
- 의존성 그래프만 확인하고 싶다면
`nix build .#darwinConfigurations.<host>.system --dry-run`을 먼저 실행하세요.
- 빌드 성공 후에도 설정 반영이 이상하면 switch를 다시 실행하고 활성
hostname/config를 확인하세요.

View file

@ -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 hosts
`darwinConfigurations.<host>` 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 repos
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/<hostname>.nix`.
- Register `repo.hosts.<hostname>.system`.
- Register `repo.hosts.<hostname>.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 <hostname>` for detailed evaluation/build output.
- If evaluation fails for a host, verify it exists under `darwinConfigurations`.
- Dry-run evaluation with
`nix build .#darwinConfigurations.<host>.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

82
flake.lock generated
View file

@ -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": {

View file

@ -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
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)
];
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
systems = [
"aarch64-darwin"
];
users.${username} = import ./home;
perSystem = {pkgs, ...}: {
formatter = pkgs.alejandra;
};
}
];
};
formatter.${system} = nixpkgs.legacyPackages.${system}.alejandra;
};
}

View file

@ -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"];
}
];
};
};
}

View file

@ -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;
}

View file

@ -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"
];
};
}

View file

@ -1,8 +0,0 @@
{...}: {
imports = [
./apps.nix
./host-users.nix
./nix-core.nix
./system.nix
];
}

24
hosts/fenrir.nix Normal file
View file

@ -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"
];
};
}

View file

@ -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];
}

View file

@ -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";
};
};
}

View file

@ -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
];
};
}

View file

@ -0,0 +1,13 @@
{...}: {
imports = [
./zoxide.nix
./bat.nix
./eza.nix
./fd.nix
./fzf.nix
./jq.nix
./lazygit.nix
./mise.nix
./ripgrep.nix
];
}

View file

@ -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
;
}

View file

@ -0,0 +1,9 @@
{
# just
enable = true;
lsp = {
enable = true;
servers = ["just-lsp"];
};
treesitter.enable = true;
}

View file

@ -0,0 +1,13 @@
{
# toml
enable = true;
lsp = {
enable = true;
servers = ["taplo"];
};
format = {
enable = true;
type = ["taplo"];
};
treesitter.enable = true;
}

View file

@ -5,7 +5,12 @@
grammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
nix
lua
markdown
html
python
yaml
toml
just
];
fold = true;
highlight = {

View file

@ -0,0 +1,6 @@
{...}: {
imports = [
./git.nix
./gh.nix
];
}

View file

@ -0,0 +1,5 @@
{...}: {
imports = [
./sops.nix
];
}

View file

@ -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" = {};

View file

@ -0,0 +1,6 @@
{...}: {
imports = [
./zsh.nix
./starship.nix
];
}

View file

@ -0,0 +1,5 @@
{...}: {
imports = [
./ssh.nix
];
}

View file

@ -0,0 +1,5 @@
{...}: {
imports = [
./terminal.nix
];
}

View file

@ -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
'';
};
}

33
modules/aspects/base.nix Normal file
View file

@ -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;
};
}

View file

@ -0,0 +1,7 @@
{...}: {
repo.homeModules.cli-tools = {
imports = [
./_cli-tools
];
};
}

159
modules/aspects/desktop.nix Normal file
View file

@ -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"];
}
];
};
};
};
}

View file

@ -0,0 +1,7 @@
{...}: {
repo.homeModules.editor = {
imports = [
./_editor/nvf
];
};
}

View file

@ -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";
};
};
};
}

14
modules/aspects/fonts.nix Normal file
View file

@ -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
];
};
}

7
modules/aspects/git.nix Normal file
View file

@ -0,0 +1,7 @@
{...}: {
repo.homeModules.git = {
imports = [
./_git
];
};
}

View file

@ -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"
];
};
};
}

View file

@ -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;
};
};
};
}

View file

@ -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";
};
};
};
}

View file

@ -0,0 +1,7 @@
{...}: {
repo.homeModules.secrets = {
imports = [
./_secrets
];
};
}

15
modules/aspects/shell.nix Normal file
View file

@ -0,0 +1,15 @@
{...}: {
flake.modules.darwin.shell = {pkgs, ...}: {
programs.zsh.enable = true;
environment.shells = [
pkgs.zsh
];
};
repo.homeModules.shell = {
imports = [
./_shell
];
};
}

7
modules/aspects/ssh.nix Normal file
View file

@ -0,0 +1,7 @@
{...}: {
repo.homeModules.ssh = {
imports = [
./_ssh
];
};
}

View file

@ -0,0 +1,8 @@
{...}: {
flake.modules.darwin.sudo-auth = {
security.pam.services.sudo_local = {
touchIdAuth = true;
watchIdAuth = true;
};
};
}

View file

@ -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";
};
};
}

View file

@ -0,0 +1,7 @@
{...}: {
repo.homeModules.terminal = {
imports = [
./_terminal
];
};
}

View file

@ -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;
}

View file

@ -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;
};
};
};
}

View file

@ -0,0 +1,6 @@
{...}: {
imports = [
./options.nix
./darwin-configurations.nix
];
}

View file

@ -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;
};
};
};
}

60
modules/flake/options.nix Normal file
View file

@ -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;
};
}