mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-26 11:21:34 +01:00
feat: redesign the project structure
This commit is contained in:
29
home/common/alacritty.nix
Normal file
29
home/common/alacritty.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
# terminals
|
||||
|
||||
let
|
||||
font = "JetBrainsMono Nerd Font";
|
||||
in
|
||||
{
|
||||
programs.alacritty = {
|
||||
enable = true;
|
||||
settings = {
|
||||
window.opacity = 0.95;
|
||||
window.dynamic_padding = true;
|
||||
window.padding = {
|
||||
x = 5;
|
||||
y = 5;
|
||||
};
|
||||
scrolling.history = 10000;
|
||||
|
||||
font = {
|
||||
normal.family = font;
|
||||
bold.family = font;
|
||||
italic.family = font;
|
||||
size = 11;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
117
home/common/core.nix
Normal file
117
home/common/core.nix
Normal file
@@ -0,0 +1,117 @@
|
||||
{config, pkgs, ...}: let
|
||||
d = config.xdg.dataHome;
|
||||
c = config.xdg.configHome;
|
||||
cache = config.xdg.cacheHome;
|
||||
in rec {
|
||||
home.packages = with pkgs; [
|
||||
neofetch
|
||||
nnn # terminal file manager
|
||||
|
||||
# archives
|
||||
zip
|
||||
xz
|
||||
unzip
|
||||
p7zip
|
||||
|
||||
# utils
|
||||
ripgrep # recursively searches directories for a regex pattern
|
||||
jq # A lightweight and flexible command-line JSON processor
|
||||
yq-go # yaml processer https://github.com/mikefarah/yq
|
||||
exa # A modern replacement for ‘ls’
|
||||
|
||||
# networking tools
|
||||
mtr # A network diagnostic tool
|
||||
iperf3
|
||||
nmap
|
||||
socat
|
||||
ldns # replacement of dig, it provide the command `drill`
|
||||
aria2 # A lightweight multi-protocol & multi-source command-line download utility
|
||||
socat # replacement of openbsd-netcat
|
||||
|
||||
# misc
|
||||
file
|
||||
which
|
||||
tree
|
||||
gnused
|
||||
gnutar
|
||||
gawk
|
||||
p7zip
|
||||
xz
|
||||
zstd
|
||||
|
||||
# productivity
|
||||
hugo
|
||||
];
|
||||
|
||||
programs = {
|
||||
# A terminal multiplexer
|
||||
tmux = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
# a cat(1) clone with syntax highlighting and Git integration.
|
||||
bat = {
|
||||
enable = true;
|
||||
config = {
|
||||
pager = "less -FR";
|
||||
theme = "Catppuccin-mocha";
|
||||
};
|
||||
themes = {
|
||||
Catppuccin-mocha = builtins.readFile (pkgs.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/catppuccin/bat/main/Catppuccin-mocha.tmTheme";
|
||||
hash = "sha256-qMQNJGZImmjrqzy7IiEkY5IhvPAMZpq0W6skLLsng/w=";
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
# skim provides a single executable: sk.
|
||||
# Basically anywhere you would want to use grep, try sk instead.
|
||||
skim = {
|
||||
enable = true;
|
||||
enableBashIntegration = true;
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
# syncthing.enable = true;
|
||||
};
|
||||
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
enableCompletion = true;
|
||||
bashrcExtra = ''
|
||||
export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin"
|
||||
'';
|
||||
};
|
||||
|
||||
# add environment variables
|
||||
systemd.user.sessionVariables = {
|
||||
# clean up ~
|
||||
LESSHISTFILE = cache + "/less/history";
|
||||
LESSKEY = c + "/less/lesskey";
|
||||
WINEPREFIX = d + "/wine";
|
||||
|
||||
# set this variable make i3 failed to start
|
||||
# related issue:
|
||||
# https://github.com/sddm/sddm/issues/871
|
||||
# XAUTHORITY = "$XDG_RUNTIME_DIR/Xauthority";
|
||||
|
||||
# set default applications
|
||||
BROWSER = "firefox";
|
||||
TERMINAL = "alacritty";
|
||||
|
||||
# enable scrolling in git diff
|
||||
DELTA_PAGER = "less -R";
|
||||
|
||||
MANPAGER = "sh -c 'col -bx | bat -l man -p'";
|
||||
};
|
||||
|
||||
home.sessionVariables = systemd.user.sessionVariables;
|
||||
|
||||
home.shellAliases = {
|
||||
k = "kubectl";
|
||||
|
||||
urldecode = "python3 -c 'import sys, urllib.parse as ul; print(ul.unquote_plus(sys.stdin.read()))'";
|
||||
urlencode = "python3 -c 'import sys, urllib.parse as ul; print(ul.quote_plus(sys.stdin.read()))'";
|
||||
};
|
||||
}
|
||||
17
home/common/default.nix
Normal file
17
home/common/default.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
{config, pkgs, ...}: let
|
||||
d = config.xdg.dataHome;
|
||||
c = config.xdg.configHome;
|
||||
cache = config.xdg.cacheHome;
|
||||
in rec {
|
||||
imports = [
|
||||
./nushell
|
||||
|
||||
./alacritty.nix
|
||||
./core.nix
|
||||
./development.nix
|
||||
./git.nix
|
||||
./media.nix
|
||||
./starship.nix
|
||||
];
|
||||
|
||||
}
|
||||
97
home/common/development.nix
Normal file
97
home/common/development.nix
Normal file
@@ -0,0 +1,97 @@
|
||||
{config, pkgs, nil, ...}:
|
||||
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
nil.packages."${pkgs.system}".default # nix language server
|
||||
|
||||
# IDE
|
||||
insomnia
|
||||
jetbrains.pycharm-community
|
||||
# jetbrains.idea-community
|
||||
|
||||
# cloud native
|
||||
docker-compose
|
||||
kubectl
|
||||
kubernetes-helm
|
||||
terraform
|
||||
pulumi
|
||||
|
||||
# cloud provider
|
||||
awscli
|
||||
|
||||
# DO NOT install build tools for C/C++, set it per project by devShell instead
|
||||
gnumake # used by this repo, to simplify the deployment
|
||||
clang-tools
|
||||
clang-analyzer
|
||||
# lldb
|
||||
# cmake
|
||||
# autoconf
|
||||
# automake
|
||||
# bison
|
||||
# cppcheck
|
||||
# fakeroot
|
||||
# flex
|
||||
# gettext
|
||||
# groff
|
||||
# libtool
|
||||
# m4
|
||||
# patch
|
||||
# pkgconf
|
||||
# texinfo
|
||||
# binutils
|
||||
|
||||
# Golang
|
||||
delve
|
||||
go
|
||||
go-outline
|
||||
go-tools
|
||||
go2nix
|
||||
gomodifytags
|
||||
gopls
|
||||
gotests
|
||||
impl
|
||||
|
||||
# Rust
|
||||
rustup
|
||||
|
||||
# python
|
||||
(python3.withPackages(ps: with ps; [
|
||||
ipython
|
||||
pandas
|
||||
requests
|
||||
pyquery
|
||||
]))
|
||||
# need to run `conda-install` before using it
|
||||
# need to run `conda-shell` before using command `conda`
|
||||
conda
|
||||
|
||||
# db related
|
||||
dbeaver
|
||||
mycli
|
||||
pgcli
|
||||
|
||||
# embedded development
|
||||
minicom
|
||||
];
|
||||
|
||||
programs = {
|
||||
# modern vim
|
||||
neovim = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
set number relativenumber
|
||||
'';
|
||||
};
|
||||
|
||||
direnv = {
|
||||
enable = true;
|
||||
nix-direnv.enable = true;
|
||||
enableZshIntegration = true;
|
||||
};
|
||||
};
|
||||
|
||||
# GitHub CLI tool
|
||||
programs.gh = {
|
||||
enable = true;
|
||||
};
|
||||
}
|
||||
30
home/common/git.nix
Normal file
30
home/common/git.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
programs.git = {
|
||||
enable = true;
|
||||
lfs.enable = true;
|
||||
|
||||
userName = "Ryan Yin";
|
||||
userEmail = "xiaoyin_c@qq.com";
|
||||
|
||||
extraConfig = {
|
||||
pull = {
|
||||
rebase = true;
|
||||
};
|
||||
};
|
||||
|
||||
# signing = {
|
||||
# key = "xxx";
|
||||
# signByDefault = true;
|
||||
# };
|
||||
|
||||
delta = {
|
||||
enable = true;
|
||||
options = {
|
||||
features = "side-by-side";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
17
home/common/media.nix
Normal file
17
home/common/media.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
# processing audio/video
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
ffmpeg-full
|
||||
|
||||
# images
|
||||
viu # terminal image viewer
|
||||
imv # simple image viewer
|
||||
imagemagick
|
||||
graphviz
|
||||
];
|
||||
}
|
||||
0
home/common/nushell/config.nu
Normal file
0
home/common/nushell/config.nu
Normal file
7
home/common/nushell/default.nix
Normal file
7
home/common/nushell/default.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
programs.nushell = {
|
||||
enable = true;
|
||||
configFile.source = ./config.nu;
|
||||
envFile.source = ./env.nu;
|
||||
};
|
||||
}
|
||||
36
home/common/nushell/env.nu
Normal file
36
home/common/nushell/env.nu
Normal file
@@ -0,0 +1,36 @@
|
||||
# Nushell Environment Config File
|
||||
|
||||
# Specifies how environment variables are:
|
||||
# - converted from a string to a value on Nushell startup (from_string)
|
||||
# - converted from a value back to a string when running external commands (to_string)
|
||||
# Note: The conversions happen *after* config.nu is loaded
|
||||
let-env ENV_CONVERSIONS = {
|
||||
"PATH": {
|
||||
from_string: { |s| $s | split row (char esep) | path expand -n }
|
||||
to_string: { |v| $v | path expand -n | str join (char esep) }
|
||||
}
|
||||
"Path": {
|
||||
from_string: { |s| $s | split row (char esep) | path expand -n }
|
||||
to_string: { |v| $v | path expand -n | str join (char esep) }
|
||||
}
|
||||
}
|
||||
|
||||
# Directories to search for scripts when calling source or use
|
||||
#
|
||||
# By default, <nushell-config-dir>/scripts is added
|
||||
let-env NU_LIB_DIRS = [
|
||||
($nu.config-path | path dirname | path join 'scripts')
|
||||
]
|
||||
|
||||
# Directories to search for plugin binaries when calling register
|
||||
#
|
||||
# By default, <nushell-config-dir>/plugins is added
|
||||
let-env NU_PLUGIN_DIRS = [
|
||||
($nu.config-path | path dirname | path join 'plugins')
|
||||
]
|
||||
|
||||
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
|
||||
# let-env PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
|
||||
|
||||
mkdir ~/.cache/starship
|
||||
starship init nu | sed "s/size -c/size/" | save ~/.cache/starship/init.nu
|
||||
11
home/common/starship.nix
Normal file
11
home/common/starship.nix
Normal file
@@ -0,0 +1,11 @@
|
||||
{config, ...}: {
|
||||
programs.starship = {
|
||||
enable = true;
|
||||
settings = {
|
||||
character = {
|
||||
success_symbol = "[›](bold green)";
|
||||
error_symbol = "[›](bold red)";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user