feat: redesign the project structure

This commit is contained in:
ryan4yin
2023-05-26 19:25:44 +08:00
parent ab11958597
commit f971ec030d
124 changed files with 711 additions and 540 deletions

117
home/common/core.nix Normal file
View 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
View 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
];
}

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

44
home/darwin/core.nix Normal file
View File

@@ -0,0 +1,44 @@
{pkgs, ...}:
{
# MacOS specific configuration
home.packages = with pkgs; [
];
programs.ssh = {
enable = true;
# all my ssh private key are generated by `ssh-keygen -t ed25519 -C "ryan@nickname"`
# the config's format:
# Host — given the pattern used to match against the host name given on the command line.
# HostName — specify nickname or abbreviation for host
# IdentityFile — the location of your SSH key authentication file for the account.
# format in details:
# https://www.ssh.com/academy/ssh/config
extraConfig = ''
Host 192.168.*
# allow to securely use local SSH agent to authenticate on the remote machine.
# It has the same effect as adding cli option `ssh -A user@host`
ForwardAgent yes
# romantic holds my homelab~
IdentityFile ~/.ssh/romantic
# Specifies that ssh should only use the identity file explicitly configured above
# required to prevent sending default identity files first.
IdentitiesOnly yes
Host github.com
Hostname github.com
# github is controlled by gluttony~
IdentityFile ~/.ssh/harmonica
# Specifies that ssh should only use the identity file explicitly configured above
# required to prevent sending default identity files first.
IdentitiesOnly yes
'';
# use ssh-agent so we only need to input passphrase once
# run `ssh-add /path/to/key` for every identity file
# check imported keys by `ssh-add -l`
# TODO `ssh-add` can only add keys temporary, use gnome-keyring to unlock all keys after login.
};
}

View File

@@ -1,10 +1,33 @@
{pkgs, ...}:
{ pkgs, ... }:
{
home.packages = with pkgs; [
docker-compose
kubectl
kubernetes-helm
terraform
pulumi
imports = [
../common/core.nix
../common/alacritty.nix
../common/git.nix
../common/starship.nix
./core.nix
];
# Home Manager needs a bit of information about you and the
# paths it should manage.
home = {
username = "admin";
# set homeDirectory make build fail
# homeDirectory = "/Users/admin";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
stateVersion = "22.11";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

View File

@@ -1,28 +0,0 @@
{ pkgs, ... }:
{
imports = [
./darwin
];
# Home Manager needs a bit of information about you and the
# paths it should manage.
home = {
username = "admin";
# set homeDirectory make build fail
# homeDirectory = "/Users/admin";
# This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new Home Manager release introduces backwards
# incompatible changes.
#
# You can update Home Manager without changing this value. See
# the Home Manager release notes for a list of state version
# changes in each release.
stateVersion = "22.11";
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
}

View File

@@ -2,9 +2,6 @@
pkgs,
...
}: {
# home.packages = [
# ];
programs.ssh = {
enable = true;
@@ -39,35 +36,4 @@
# check imported keys by `ssh-add -l`
# TODO `ssh-add` can only add keys temporary, use gnome-keyring to unlock all keys after login.
};
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";
};
};
};
# GitHub CLI tool
programs.gh = {
enable = true;
};
}

View File

@@ -0,0 +1,39 @@
{pkgs, config, ...}:
{
# Linux Only Packages, not available on Darwin
home.packages = with pkgs; [
btop # replacement of htop/nmon
htop
iotop
nmon
## networking tools
wireguard-tools # manage wireguard vpn manually, via wg-quick
iftop
# misc
libnotify
# system call monitoring
strace
ltrace # library call monitoring
lsof
# system tools
ethtool
sysstat
lm_sensors # for `sensors` command
cifs-utils # for mounting windows shares
];
# auto mount usb drives
services = {
udiskie.enable = true;
};
services = {
playerctld.enable = true;
};
}

View File

@@ -1,3 +1,7 @@
# XDG stands for "Cross-Desktop Group", with X used to mean "cross".
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and
# other GUI applications on various systems (primarily Unix-like) to be interoperable:
# https://www.freedesktop.org/wiki/Specifications/
{config, pkgs, ...}: let
browser = ["firefox.desktop"];
@@ -25,6 +29,11 @@
"x-scheme-handler/tg" = ["telegramdesktop.desktop"];
};
in {
home.packages = with pkgs; [
xdg-utils
xdg-user-dirs
];
xdg = {
enable = true;
cacheHome = config.home.homeDirectory + "/.local/cache";

View File

@@ -0,0 +1,21 @@
{
pkgs,
config,
...
}:
{
home.packages = with pkgs; [
# creative
# blender # 3d modeling
# gimp # image editing, I prefer using figma in browser instead of this one
inkscape # vector graphics
krita # digital painting
kicad # 3d printing, eletrical engineering
musescore # music notation
reaper # audio production
];
programs = {
obs-studio.enable = true;
};
}

View File

@@ -0,0 +1,21 @@
{ pkgs, ... }:
{
imports = [
./creative.nix
./media.nix
];
home.packages = with pkgs; [
# networking
wireshark
# instant messaging
telegram-desktop
discord
qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq
# remote desktop(rdp connect)
remmina
freerdp # required by remmina
];
}

View File

@@ -0,0 +1,32 @@
{
pkgs,
config,
...
}:
# media - control and enjoy audio/video
{
home.packages = with pkgs; [
# audio control
pavucontrol
playerctl
pulsemixer
nvtop
# video/audio tools
libva-utils
vdpauinfo
vulkan-tools
glxinfo
];
programs = {
mpv = {
enable = true;
defaultProfiles = ["gpu-hq"];
scripts = [pkgs.mpvScripts.mpris];
};
obs-studio.enable = true;
};
}

View File

@@ -29,6 +29,5 @@
XMODIFIERS = "@im=fcitx";
INPUT_METHOD = "fcitx";
IMSETTINGS_MODULE = "fcitx";
};
}

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -23,6 +23,13 @@
executable = true; # make all scripts executable
};
# rofi is a application launcher and dmenu replacement
home.file.".config/rofi" = {
source = ./rofi-conf;
# copy the scripts directory recursively
recursive = true;
};
# allow fontconfig to discover fonts and configurations installed through home.packages
fonts.fontconfig.enable = true;

Some files were not shown because too many files have changed in this diff Show More