This commit is contained in:
2025-11-15 23:17:12 +08:00
parent 6f3ea7bb47
commit 389e780660
18 changed files with 1597 additions and 90 deletions
+59
View File
@@ -0,0 +1,59 @@
# Common configuration shared across all platforms
{
inputs,
lib,
config,
pkgs,
...
}: {
nixpkgs = {
# You can add overlays here
overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
inputs.self.overlays.additions
inputs.self.overlays.modifications
inputs.self.overlays.unstable-packages
];
# Configure your nixpkgs instance
config = {
# Disable if you don't want unfree packages
allowUnfree = true;
};
};
# Enable home-manager
programs.home-manager.enable = true;
# Basic packages everyone should have
home.packages = with pkgs; [
# Archives
zip
unzip
# Utils
ripgrep # Better grep
fd # Better find
jq # JSON processor
yq-go # YAML processor
# System tools
htop
tree
wget
curl
];
# Basic git configuration
programs.git = {
enable = true;
extraConfig = {
init.defaultBranch = "main";
pull.rebase = true;
push.autoSetupRemote = true;
};
};
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
home.stateVersion = "24.05";
}
+54
View File
@@ -0,0 +1,54 @@
# macOS-specific home-manager configuration
{
inputs,
lib,
config,
pkgs,
...
}: lib.mkIf pkgs.stdenv.isDarwin {
# macOS-specific packages
home.packages = with pkgs; [
# macOS CLI tools
# m-cli # Swiss Army Knife for macOS
# GUI applications (if you want to manage them with nix)
# Note: Many prefer to use homebrew for GUI apps on macOS
];
# macOS-specific configurations
home.sessionVariables = {
# Fix for Nix on macOS
NIX_PATH = "nixpkgs=${inputs.nixpkgs}:darwin=${inputs.darwin}";
};
# Fish shell configuration for macOS
programs.fish = lib.mkIf config.programs.fish.enable {
shellInit = ''
# Add Homebrew to PATH if it exists
if test -d /opt/homebrew/bin
fish_add_path /opt/homebrew/bin
end
'';
};
# Zsh configuration for macOS
programs.zsh = lib.mkIf config.programs.zsh.enable {
initExtra = ''
# Add Homebrew to PATH if it exists
if [[ -d /opt/homebrew/bin ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
'';
};
# Bash configuration for macOS
programs.bash = lib.mkIf config.programs.bash.enable {
initExtra = ''
# Add Homebrew to PATH if it exists
if [[ -d /opt/homebrew/bin ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
'';
};
}
+76
View File
@@ -0,0 +1,76 @@
# Development tools and environment
{
inputs,
lib,
config,
pkgs,
...
}: {
home.packages = with pkgs; [
# Version control
git
gh # GitHub CLI
lazygit # Terminal UI for git
# Languages and runtimes (add what you need)
# python311
# nodejs_20
# go
# rustc
# cargo
# Build tools
gnumake
cmake
# Text editors / IDEs
# neovim
# vscode
# Docker and containers (Linux only, macOS uses Docker Desktop)
] ++ lib.optionals pkgs.stdenv.isLinux [
# docker
# docker-compose
];
# Git configuration for development
programs.git = {
enable = true;
# TODO: Configure your git identity
# userName = "Your Name";
# userEmail = "your.email@example.com";
extraConfig = {
core.editor = "vim";
merge.conflictstyle = "diff3";
diff.algorithm = "histogram";
};
# Git aliases
aliases = {
st = "status";
co = "checkout";
br = "branch";
ci = "commit";
unstage = "reset HEAD --";
last = "log -1 HEAD";
lg = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit";
};
};
# GitHub CLI
programs.gh = {
enable = true;
settings = {
git_protocol = "ssh";
prompt = "enabled";
};
};
# Direnv for per-directory environments
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
}
+28 -47
View File
@@ -7,60 +7,41 @@
pkgs,
...
}: {
# You can import other home-manager modules here
# Import modular configurations
imports = [
# Base configuration shared across all platforms
./common.nix
# Feature modules
./development.nix
./shell.nix
./terminal.nix
# Platform-specific configurations
./linux.nix
./darwin.nix
# If you want to use modules your own flake exports (from modules/home-manager):
# inputs.self.homeManagerModules.example
# Or modules exported from other flakes (such as nix-colors):
# inputs.nix-colors.homeManagerModules.default
# You can also split up your configuration and import pieces of it here:
# ./nvim.nix
];
nixpkgs = {
# You can add overlays here
overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
inputs.self.overlays.additions
inputs.self.overlays.modifications
inputs.self.overlays.unstable-packages
# You can also add overlays exported from other flakes:
# neovim-nightly-overlay.overlays.default
# Or define it inline, for example:
# (final: prev: {
# hi = final.hello.overrideAttrs (oldAttrs: {
# patches = [ ./change-hello-to-hi.patch ];
# });
# })
];
# Configure your nixpkgs instance
config = {
# Disable if you don't want unfree packages
allowUnfree = true;
};
};
# TODO: Set your username
home = {
username = "your-username";
homeDirectory = "/home/your-username";
username = lib.mkDefault "your-username";
homeDirectory = lib.mkDefault (
if pkgs.stdenv.isDarwin
then "/Users/${config.home.username}"
else "/home/${config.home.username}"
);
};
# Add stuff for your user as you see fit:
# programs.neovim.enable = true;
# home.packages = with pkgs; [ steam ];
# Enable home-manager and git
programs.home-manager.enable = true;
programs.git.enable = true;
# Nicely reload system units when changing configs
systemd.user.startServices = "sd-switch";
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
home.stateVersion = "23.05";
# Platform-aware session variables
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
} // lib.optionalAttrs pkgs.stdenv.isDarwin {
# macOS-specific environment variables
} // lib.optionalAttrs pkgs.stdenv.isLinux {
# Linux-specific environment variables
};
}
+51
View File
@@ -0,0 +1,51 @@
# Linux-specific home-manager configuration
{
inputs,
lib,
config,
pkgs,
...
}: lib.mkIf pkgs.stdenv.isLinux {
# Linux-specific packages
home.packages = with pkgs; [
# GUI applications (if you use a desktop environment)
# firefox
# chromium
# Linux-specific CLI tools
# xclip
# xsel
];
# Systemd user services (Linux only)
systemd.user.startServices = "sd-switch";
# X11/Wayland specific configurations
# xsession.enable = true;
# wayland.windowManager.sway.enable = true;
# GTK theme configuration
gtk = {
enable = true;
# theme = {
# name = "Adwaita-dark";
# package = pkgs.gnome.gnome-themes-extra;
# };
};
# Qt theme configuration
qt = {
enable = true;
platformTheme.name = "gtk";
};
# Services
services = {
# Clipboard manager
# clipmenu.enable = true;
# Notification daemon
# dunst.enable = true;
};
}
+117
View File
@@ -0,0 +1,117 @@
# Shell configuration (bash, zsh, fish, etc.)
{
inputs,
lib,
config,
pkgs,
...
}: {
# Bash configuration
programs.bash = {
enable = true;
enableCompletion = true;
shellAliases = {
ll = "ls -la";
".." = "cd ..";
"..." = "cd ../..";
gs = "git status";
gd = "git diff";
};
};
# Zsh configuration
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
ll = "ls -la";
".." = "cd ..";
"..." = "cd ../..";
gs = "git status";
gd = "git diff";
nix-gc = "nix-collect-garbage -d";
};
history = {
size = 10000;
path = "${config.home.homeDirectory}/.zsh_history";
};
initExtra = ''
# Custom prompt or additional configuration
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_FIND_NO_DUPS
setopt HIST_REDUCE_BLANKS
'';
};
# Fish configuration
programs.fish = {
enable = true;
shellAliases = {
ll = "ls -la";
".." = "cd ..";
"..." = "cd ../..";
gs = "git status";
gd = "git diff";
};
functions = {
mkcd = "mkdir -p $argv[1]; and cd $argv[1]";
};
};
# Starship prompt (works with all shells)
programs.starship = {
enable = true;
settings = {
add_newline = true;
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
package.disabled = true;
};
};
# Zoxide (better cd)
programs.zoxide = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableFishIntegration = true;
};
# fzf (fuzzy finder)
programs.fzf = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableFishIntegration = true;
};
# Eza (modern ls replacement)
programs.eza = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
enableFishIntegration = true;
git = true;
icons = true;
};
# Bat (better cat)
programs.bat = {
enable = true;
config = {
theme = "TwoDark";
pager = "less -FR";
};
};
}
+110
View File
@@ -0,0 +1,110 @@
# Terminal applications and utilities
{
inputs,
lib,
config,
pkgs,
...
}: {
home.packages = with pkgs; [
# Modern CLI tools
ripgrep # Better grep
fd # Better find
sd # Better sed
du-dust # Better du
duf # Better df
procs # Better ps
bottom # Better top/htop
# File managers
# ranger
# nnn
# lf
# Multiplexers
# tmux
# zellij
];
# Tmux configuration
programs.tmux = {
enable = true;
terminal = "tmux-256color";
historyLimit = 10000;
baseIndex = 1;
keyMode = "vi";
mouse = true;
plugins = with pkgs.tmuxPlugins; [
sensible
yank
vim-tmux-navigator
];
extraConfig = ''
# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# Reload config
bind r source-file ~/.config/tmux/tmux.conf
# Easy pane switching
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
'';
};
# Neovim (optional, can be expanded)
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
extraConfig = ''
set number
set relativenumber
set expandtab
set tabstop=2
set shiftwidth=2
set smartindent
set clipboard=unnamedplus
'';
};
# Alacritty terminal emulator configuration
programs.alacritty = {
enable = true;
settings = {
window = {
padding = {
x = 10;
y = 10;
};
decorations = "full";
opacity = 0.95;
};
font = {
size = 13.0;
normal = {
family = "JetBrainsMono Nerd Font";
style = "Regular";
};
};
colors = {
primary = {
background = "0x1e1e1e";
foreground = "0xd4d4d4";
};
};
};
};
}