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

@ -0,0 +1,5 @@
{
programs.bat = {
enable = true;
};
}

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

@ -0,0 +1,10 @@
{
programs.eza = {
enable = true;
colors = "auto";
git = true;
icons = "auto";
enableZshIntegration = true;
enableBashIntegration = true;
};
}

View file

@ -0,0 +1,7 @@
{
programs.fd = {
enable = true;
ignores = [".git/"];
hidden = true;
};
}

View file

@ -0,0 +1,7 @@
{
programs.fzf = {
enable = true;
enableZshIntegration = true;
enableBashIntegration = true;
};
}

View file

@ -0,0 +1,3 @@
{
programs.jq.enable = true;
}

View file

@ -0,0 +1,7 @@
{
programs.lazygit = {
enable = true;
enableZshIntegration = true;
enableBashIntegration = true;
};
}

View file

@ -0,0 +1,17 @@
{
programs.mise = {
enable = true;
globalConfig = {
tools = {
node = "lts";
uv = "latest";
python = "3.13";
};
settings = {
experimental = true;
env_file = ".env";
};
};
};
}

View file

@ -0,0 +1,3 @@
{
programs.ripgrep.enable = true;
}

View file

@ -0,0 +1,8 @@
{
programs.zoxide = {
enable = true;
enableZshIntegration = true;
enableBashIntegration = true;
options = ["--cmd j"];
};
}

View file

@ -0,0 +1,6 @@
{
# theme
enable = true;
name = "tokyonight";
style = "night";
}

View file

@ -0,0 +1,11 @@
[
# augroups
{
enable = true;
name = "LastCursorGroup";
}
{
enable = true;
name = "HighlightYank";
}
]

View file

@ -0,0 +1,33 @@
{lib, ...}: [
# autocmds
{
enable = true;
event = ["BufReadPost"];
desc = "Return to last cursor position";
group = "LastCursorGroup";
callback = lib.generators.mkLuaInline ''
function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local line_count = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= line_count then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end
'';
}
{
enable = true;
event = ["TextYankPost"];
desc = "Highlight yanks on copy";
group = "HighlightYank";
pattern = ["*"];
callback = lib.generators.mkLuaInline ''
function()
vim.hl.on_yank({
higroup = "IncSearch",
timeout = 250,
})
end
'';
}
]

View file

@ -0,0 +1,8 @@
{
# clipboard
enable = true;
registers = "unnamedplus";
providers = {
wl-copy.enable = true;
};
}

View file

@ -0,0 +1,81 @@
[
# Keymaps
{
key = "<leader>ff";
mode = "n";
action = "<Cmd>FzfLua files<CR>";
desc = "[F]ind files";
}
{
key = "<leader>fg";
mode = "n";
action = "<Cmd>FzfLua live_grep_native<CR>";
desc = "Live [G]rep";
}
{
key = "<leader><leader>";
mode = "n";
action = "<Cmd>FzfLua buffers<CR>";
desc = "Buffers";
}
{
key = "<leader>fh";
mode = "n";
action = "<Cmd>FzfLua help_tags<CR>";
desc = "[H]elp Tags";
}
{
key = "<leader>fx";
mode = "n";
action = "<Cmd>FzfLua diagnostics_document<CR>";
desc = "Diagnostics Document";
}
{
key = "<leader>fX";
mode = "n";
action = "<Cmd>FzfLua diagnostics_workspace<CR>";
desc = "Diagnostics Workspace";
}
{
key = "<leader>fs";
mode = "n";
action = "<Cmd>FzfLua lsp_document_symbols<CR>";
desc = "Document [S]ymbols";
}
{
key = "<leader>fS";
mode = "n";
action = "<Cmd>FzfLua lsp_workspace_symbols<CR>";
desc = "Workspace [S]ymbols";
}
{
key = "<leader>fk";
mode = "n";
action = "<Cmd>FzfLua keymaps<CR>";
desc = "[K]eymaps";
}
{
key = "<leader>fb";
mode = "n";
action = "<Cmd>FzfLua builtin<CR>";
desc = "[B]uiltin FZF";
}
{
key = "<leader>fr";
mode = "n";
action = "<Cmd>FzfLua resume<CR>";
desc = "[R]esume";
}
{
key = "<leader>fo";
mode = "n";
action = "<Cmd>FzfLua oldfiles<CR>";
desc = "[O]ld Files";
}
{
key = "<leader>-";
mode = "n";
action = "<Cmd>Oil --float<CR>";
desc = "Open Current Directory";
}
]

View file

@ -0,0 +1,12 @@
{
# options
cursorlineopt = "line";
wrap = false;
cmdheight = 1;
tabstop = 2;
shiftwidth = 2;
autoindent = true;
termguicolors = true;
splitbelow = true;
splitright = true;
}

View file

@ -0,0 +1,5 @@
{
# spellcheck
enable = true;
languages = ["en"];
}

View file

@ -0,0 +1,4 @@
{
# undoFile
enable = true;
}

View file

@ -0,0 +1,47 @@
{
lib,
pkgs,
...
}: let
options = import ./core/options.nix;
autocmds = import ./core/autocmds.nix {inherit lib;};
augroups = import ./core/augroups.nix;
keymaps = import ./core/keymaps.nix;
fzf-lua = import ./plugins/fzf-lua.nix;
mini = import ./plugins/mini.nix;
utility = import ./plugins/utility.nix;
binds = import ./plugins/binds.nix;
terminal = import ./plugins/terminal.nix;
theme = import ./appearance/theme.nix;
lsp = import ./lsp/lsp.nix;
treesitter = import ./lsp/treesitter.nix {inherit pkgs;};
autocomplete = import ./lsp/autocomplete.nix;
languages = import ./lsp/languages;
in {
programs.nvf = {
enable = true;
settings = {
vim = {
inherit
options
autocmds
augroups
keymaps
fzf-lua
mini
utility
binds
terminal
theme
lsp
treesitter
autocomplete
languages
;
searchCase = "smart";
hideSearchHighlight = true;
};
};
};
}

View file

@ -0,0 +1,22 @@
{
# autocomplete
blink-cmp = {
enable = true;
friendly-snippets.enable = true;
setupOpts = {
keymap.preset = "default";
cmdline = {
keymap.preset = "default";
};
completion = {
documentation = {
auto_show = true;
auto_show_delay_ms = 1000;
};
};
};
sourcePlugins = {
emoji.enable = true;
};
};
}

View file

@ -0,0 +1,17 @@
{
# bash
enable = true;
extraDiagnostics = {
enable = true;
types = ["shellcheck"];
};
format = {
enable = true;
type = ["shfmt"];
};
lsp = {
enable = true;
servers = ["bash-ls"];
};
treesitter.enable = true;
}

View file

@ -0,0 +1,23 @@
let
nix = import ./nix.nix;
python = import ./python.nix;
lua = import ./lua.nix;
bash = import ./bash.nix;
markdown = import ./markdown.nix;
html = import ./html.nix;
yaml = import ./yaml.nix;
toml = import ./toml.nix;
just = import ./just.nix;
in {
inherit
nix
python
lua
bash
markdown
html
yaml
toml
just
;
}

View file

@ -0,0 +1,23 @@
{
# html
enable = true;
extraDiagnostics = {
enable = true;
types = ["htmlhint"];
};
format = {
enable = true;
type = [
"superhtml"
"prettierd"
];
};
lsp = {
enable = true;
servers = ["superhtml"];
};
treesitter = {
enable = true;
autotagHtml = true;
};
}

View file

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

View file

@ -0,0 +1,17 @@
{
# lua
enable = true;
extraDiagnostics = {
enable = true;
types = ["luacheck"];
};
format = {
enable = true;
type = ["stylua"];
};
lsp = {
enable = true;
servers = ["lua-language-server"];
};
treesitter.enable = true;
}

View file

@ -0,0 +1,30 @@
{
# markdown
enable = true;
extensions = {
render-markdown-nvim = {
enable = true;
setupOpts = {
checkbox = {
checked.scope_highlight = "@markup.strikethrough";
};
};
};
};
extraDiagnostics = {
enable = true;
types = ["markdownlint-cli2"];
};
format = {
enable = true;
type = [
"prettierd"
"deno_fmt"
];
};
lsp = {
enable = true;
servers = ["marksman"];
};
treesitter.enable = true;
}

View file

@ -0,0 +1,20 @@
{
# nix
enable = true;
extraDiagnostics = {
enable = true;
types = [
"deadnix"
"statix"
];
};
format = {
enable = true;
type = ["alejandra"];
};
lsp = {
enable = true;
servers = ["nil"];
};
treesitter.enable = true;
}

View file

@ -0,0 +1,13 @@
{
# python
enable = true;
format = {
enable = true;
type = ["ruff"];
};
lsp = {
enable = true;
servers = ["pyright"];
};
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

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

View file

@ -0,0 +1,7 @@
{
# lsp
enable = true;
inlayHints.enable = true;
lspconfig.enable = true;
formatOnSave = true;
}

View file

@ -0,0 +1,20 @@
{pkgs, ...}: {
# treesitter
enable = true;
addDefaultGrammars = true;
grammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
nix
lua
markdown
html
python
yaml
toml
just
];
fold = true;
highlight = {
enable = true;
};
indent.enable = true;
}

View file

@ -0,0 +1,10 @@
{
# binds
whichKey = {
enable = true;
register = {
"<leader>f" = "+FZF";
"<leader>l" = "+Language";
};
};
}

View file

@ -0,0 +1,6 @@
{
# fzf-lua
enable = true;
profile = "default";
setupOpts = {};
}

View file

@ -0,0 +1,14 @@
{
# mini
statusline.enable = true;
ai.enable = true;
bufremove.enable = true;
comment.enable = true;
pairs.enable = true;
cursorword.enable = true;
icons.enable = true;
move.enable = true;
surround.enable = true;
indentscope.enable = true;
trailspace.enable = true;
}

View file

@ -0,0 +1,21 @@
{
# terminal
toggleterm = {
enable = true;
setupOpts = {
direction = "horizontal";
size = 6;
};
mappings = {
open = "<leader>tt";
};
# lazygit
lazygit = {
enable = true;
mappings = {
open = "<leader>gg";
};
};
};
}

View file

@ -0,0 +1,11 @@
{
# utility
oil-nvim = {
enable = true;
gitStatus.enable = true;
setupOpts = {
view_options.show_hidden = true;
};
};
sleuth.enable = true;
}

View file

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

8
modules/aspects/_git/gh.nix Executable file
View file

@ -0,0 +1,8 @@
{
programs.gh = {
enable = true;
settings = {
git_protocol = "ssh";
};
};
}

35
modules/aspects/_git/git.nix Executable file
View file

@ -0,0 +1,35 @@
{config, ...}: let
signingPrincipal = "87608318+smg1024@users.noreply.github.com";
signingPublicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFuQ4STNnixjNDo38AyI0yABKAVfF3hupo66613IgfC7";
signingKeyPath = "${config.home.homeDirectory}/.config/sops-nix/secrets/github_ssh_key";
allowedSignersPath = "${config.home.homeDirectory}/.config/git/allowed_signers";
in {
home.file.".config/git/allowed_signers".text = ''
${signingPrincipal} ${signingPublicKey}
'';
programs.git = {
enable = true;
signing = {
format = "ssh";
key = signingKeyPath;
signByDefault = true;
signer = "ssh-keygen";
};
settings = {
user = {
name = "Poby";
email = signingPrincipal;
};
gpg = {
ssh = {
allowedSignersFile = allowedSignersPath;
};
};
init.defaultBranch = "master";
push = {
autoSetupRemote = true;
};
};
};
}

View file

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

View file

@ -0,0 +1,12 @@
{config, ...}: {
sops = {
age.keyFile = "${config.home.homeDirectory}/.config/sops/age/keys.txt";
defaultSopsFile = config.repo.user.secretFile;
secrets = {
"github_ssh_key" = {};
"github_cli_token" = {};
};
};
}

View file

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

View file

@ -0,0 +1,227 @@
{lib, ...}: {
programs.starship = {
enable = true;
enableZshIntegration = true;
enableBashIntegration = true;
settings = {
add_newline = true;
continuation_prompt = "[ ](dimmed white)";
format = lib.concatStrings [
"($nix_shell$container$fill\n)$cmd_duration"
"$hostname"
"$localip"
"$shell"
"$env_var"
"$jobs"
"$sudo"
"$username"
"$character"
];
right_format = lib.concatStrings [
"$directory"
"$git_branch"
"$git_commit"
"$git_state"
"$git_status"
"$docker_context"
"$c"
"$cpp"
"$deno"
"$helm"
"$java"
"$kotlin"
"$gradle"
"$lua"
"$nodejs"
"$python"
"$ruby"
"$rust"
"$terraform"
"$conda"
"$pixi"
];
fill = {
symbol = " ";
};
line_break = {
disabled = false;
};
character = {
format = "$symbol ";
success_symbol = "[](bold italic bright-yellow)";
error_symbol = "[](italic purple)";
vimcmd_symbol = "[](italic dimmed green)";
};
env_var.VIMSHELL = {
format = "[$env_value]($style)";
style = "green italic";
};
sudo = {
format = "[$symbol]($style)";
style = "bold italic bright-purple";
symbol = "";
disabled = false;
};
username = {
style_user = "bright-yellow bold italic";
style_root = "purple bold italic";
format = "[ $user]($style) ";
disabled = false;
show_always = false;
};
directory = {
home_symbol = "";
truncation_length = 2;
truncation_symbol = " ";
read_only = " ";
use_os_path_sep = true;
style = "italic blue";
format = "[$path]($style)[$read_only]($read_only_style)";
repo_root_style = "bold blue";
repo_root_format = "[$before_root_path]($before_repo_root_style)[$repo_root]($repo_root_style)[$path]($style)[$read_only]($read_only_style) [](bold bright-blue)";
};
cmd_duration = {
format = "[ $duration ](italic white)";
};
jobs = {
format = "[$symbol$number]($style) ";
style = "white";
symbol = "[](blue italic)";
};
localip = {
ssh_only = true;
format = " [$localipv4](bold magenta)";
disabled = false;
};
git_branch = {
format = " [$branch(:$remote_branch)]($style)";
symbol = "[](bold italic bright-blue)";
style = "italic bright-blue";
truncation_symbol = "";
truncation_length = 11;
ignore_branches = [];
only_attached = true;
};
git_metrics = {
format = "([$added]($added_style))([$deleted]($deleted_style))";
added_style = "italic dimmed green";
deleted_style = "italic dimmed red";
ignore_submodules = true;
disabled = false;
};
git_status = {
style = "bold italic bright-blue";
format = "([$ahead_behind$staged$modified$untracked$renamed$deleted$conflicted$stashed]($style))";
conflicted = "[](italic bright-magenta)";
ahead = "[[\${count}](bold white)](italic green)";
behind = "[[\${count}](bold white)](italic red)";
diverged = "[ [\${ahead_count}](regular white)[\${behind_count}](regular white)](italic bright-magenta)";
untracked = "[](italic bright-yellow)";
stashed = "[](italic white)";
modified = "[](italic yellow)";
staged = "[[$count](bold white)](italic bright-cyan)";
renamed = "[](italic bright-blue)";
deleted = "[](italic red)";
};
deno = {
format = " [deno](italic) [ $version](green bold)";
version_format = "\${raw}";
};
lua = {
format = " [lua](italic) [\${symbol}\${version}]($style)";
version_format = "\${raw}";
symbol = " ";
style = "bold bright-yellow";
};
nodejs = {
format = " [node](italic) [ ($version)](bold bright-green)";
version_format = "\${raw}";
detect_files = [
"package-lock.json"
"yarn.lock"
];
detect_folders = ["node_modules"];
detect_extensions = [];
};
python = {
format = " [py](italic) [\${symbol}\${version}]($style)";
symbol = "[](bold bright-blue) ";
version_format = "\${raw}";
style = "bold bright-yellow";
};
ruby = {
format = " [rb](italic) [\${symbol}\${version}]($style)";
symbol = " ";
version_format = "\${raw}";
style = "bold red";
};
rust = {
format = " [rs](italic) [$symbol$version]($style)";
symbol = " ";
version_format = "\${raw}";
style = "bold red";
};
c = {
symbol = " ";
format = " [$symbol($version(-$name))]($style)";
};
cpp = {
symbol = " ";
format = " [$symbol($version(-$name))]($style)";
};
conda = {
symbol = " ";
format = " conda [$symbol$environment]($style)";
};
pixi = {
symbol = " ";
format = " pixi [$symbol$version ($environment )]($style)";
};
docker_context = {
symbol = " ";
format = " docker [$symbol$context]($style)";
};
java = {
symbol = " ";
format = " java [\${symbol}(\${version} )]($style)";
};
nix_shell = {
style = "bold italic dimmed blue";
symbol = "";
format = "[$symbol nix$state]($style) [$name](italic dimmed white)";
impure_msg = "[](bold dimmed red)";
pure_msg = "[](bold dimmed green)";
unknown_msg = "[](bold dimmed yellow)";
};
};
};
}

49
modules/aspects/_shell/zsh.nix Executable file
View file

@ -0,0 +1,49 @@
{config, ...}: {
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
defaultKeymap = "viins";
history = {
size = 10000;
save = 10000;
share = true;
ignoreAllDups = true;
ignoreDups = true;
ignoreSpace = true;
};
shellAliases = {
poby = "echo my name is poby";
nixconfig = "cd ~/nix-darwin && vim flake.nix";
just-darwin = "cd ~/nix-darwin && just darwin $(hostname)";
};
sessionVariables = {
EDITOR = "nvim";
};
initContent = ''
export GH_TOKEN="$(cat ${config.sops.secrets."github_cli_token".path})"
'';
oh-my-zsh = {
enable = true;
theme = "robbyrussell";
plugins = [
"git"
"gitignore"
"history"
"sudo"
"vi-mode"
"zoxide"
"eza"
"mise"
];
};
};
}

View file

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

View file

@ -0,0 +1,22 @@
{config, ...}: {
programs.ssh = {
enable = true;
enableDefaultConfig = false;
matchBlocks = {
"*" = {};
"Github" = {
hostname = "github.com";
user = "git";
identitiesOnly = true;
identityFile = [config.sops.secrets."github_ssh_key".path];
};
"Valkyrie-Ubuntu_Server" = {
hostname = "192.168.64.2";
user = "poby";
port = 22;
identitiesOnly = true;
identityFile = [config.sops.secrets."github_ssh_key".path];
};
};
};
}

View file

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

View file

@ -0,0 +1,9 @@
{
programs.wezterm = {
enable = true;
enableZshIntegration = true;
enableBashIntegration = true;
# TODO wezterm config
extraConfig = builtins.readFile ./wezterm.lua;
};
}

View file

@ -0,0 +1,43 @@
local wezterm = require("wezterm")
config = wezterm.config_builder()
config = {
-- Windows
automatically_reload_config = true,
use_fancy_tab_bar = true,
hide_tab_bar_if_only_one_tab = true,
window_close_confirmation = "NeverPrompt",
window_decorations = "RESIZE", -- disable title bar, enable resize
default_cursor_style = "BlinkingBar",
-- Appearance
color_scheme = "Tokyo Night",
font = wezterm.font("D2CodingLigature Nerd Font"),
font_size = 18,
background = {
{
source = { Color = "#282c35" },
width = "100%",
height = "100%",
opacity = 0.95,
},
},
window_padding = {
left = 0,
right = 0,
top = 0,
bottom = 0,
},
-- Keymappings
keys = {
{
key = "P",
mods = "SUPER",
action = wezterm.action.ActivateCommandPalette,
},
},
}
return config

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