diff --git a/.gitignore b/.gitignore index 18ff239b0..b8b76e288 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,7 @@ lazy-lock.json perf.data perf.data.old +.bash_history +*.qcow2 +__pycache__ +kernel/module/.gdb_history diff --git a/config/.gitconfig b/config/.gitconfig new file mode 100644 index 000000000..3e1cd43ea --- /dev/null +++ b/config/.gitconfig @@ -0,0 +1,51 @@ +[alias] + adog = "log --all --decorate --oneline --graph" + bug = "log -n 1 --pretty=fixes" + kernel = "log -n 1 --pretty=commit" + log-merge = "!f() { git log --oneline --graph --stat \"$1^..$1\"; }; f" + +[core] + abbrev = 12 + editor = "nvim" + pager = "delta" + +[credential] + helper = "store" + +[delta] + light = "false" + navigate = "true" + +[diff] + colorMoved = "default" + +[http] + proxy = "http://127.0.0.1:8889" + +[https] + proxy = "http://127.0.0.1:8889" + +[interactive] + diffFilter = "delta --color-only" + +[merge] + conflictstyle = "diff3" + +[pretty] + commit = "commit %h (\"%s\")" + fixes = "Fixes: %h (\"%s\")" + +[sendemail] + smtpencryption = "tls" + smtpserver = "smtp.googlemail.com" + smtpserverport = 587 + smtpuser = "xueshi.hu@smartx.com" + +[sendemail "linux"] + cccmd = "/home/martins3/core/linux/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nom" + tocmd = "/home/martins3/core/linux/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nol" + +[user] + email = "xueshi.hu@smartx.com" + name = "Xueshi Hu" + diff --git a/config/alacritty.toml b/config/alacritty.toml new file mode 100644 index 000000000..c344e4b1c --- /dev/null +++ b/config/alacritty.toml @@ -0,0 +1,37 @@ +[colors.bright] +black = "0x002b36" +blue = "0x839496" +cyan = "0x93a1a1" +green = "0x586e75" +magenta = "0x6c71c4" +red = "0xcb4b16" +white = "0xfdf6e3" +yellow = "0x657b83" + +[colors.normal] +black = "0x073642" +blue = "0x268bd2" +cyan = "0x2aa198" +green = "0x859900" +magenta = "0xd33682" +red = "0xdc322f" +white = "0xeee8d5" +yellow = "0xb58900" + +[colors.primary] +background = "0x002b36" +foreground = "0x839496" + +[font] +size = 9.0 + +[font.normal] +family = "FiraCode Nerd Font" + +[shell] +program = "zsh" + +[window] +decorations = "none" +opacity = 0.98 +startup_mode = "Maximized" diff --git a/config/alacritty.yml b/config/alacritty.yml index c35d8c919..5ca206550 100644 --- a/config/alacritty.yml +++ b/config/alacritty.yml @@ -67,7 +67,7 @@ window: # # Window opacity as a floating point number from `0.0` to `1.0`. # The value `0.0` is completely transparent and `1.0` is opaque. - opacity: 0.9 + opacity: 0.98 # Startup Mode (changes require restart) # diff --git a/config/gdbinit b/config/gdbinit index cbf0ff5ec..c198da596 100644 --- a/config/gdbinit +++ b/config/gdbinit @@ -15,6 +15,7 @@ dashboard -style prompt_running "\\[\\e[1;32m\\]$\\[\\e[0m\\]" add-auto-load-safe-path /home/martins3/core/qemu/.gdbinit add-auto-load-safe-path /home/martins3/core/linux/scripts/gdb/vmlinux-gdb.py +add-auto-load-safe-path /home/martins3/core/linux-build/scripts/gdb/vmlinux-gdb.py # @todo 有趣 define my-source-profile diff --git a/config/nix.conf b/config/nix.conf index 6ad882b3c..c7d7291eb 100644 --- a/config/nix.conf +++ b/config/nix.conf @@ -1,2 +1 @@ experimental-features = nix-command flakes -substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/ diff --git a/config/npmrc b/config/npmrc index cd9540b8c..cce00e70a 100644 --- a/config/npmrc +++ b/config/npmrc @@ -1,2 +1,2 @@ prefix=~/.npm-packages -registry=https://registry.npm.taobao.org/ +# registry=https://registry.npm.taobao.org/ diff --git a/config/pueue.yml b/config/pueue.yml new file mode 100644 index 000000000..ae2ef4088 --- /dev/null +++ b/config/pueue.yml @@ -0,0 +1,30 @@ +--- +shared: + pueue_directory: ~/.local/share/pueue + use_unix_socket: true + runtime_directory: null + unix_socket_path: ~/.local/share/pueue/pueue_your_user.socket + host: "localhost" + port: "6924" + daemon_cert: ~/.local/share/pueue/certs/daemon.cert + daemon_key: ~/.local/share/pueue/certs/daemon.key + shared_secret_path: ~/.local/share/pueue/shared_secret + +client: + restart_in_place: false + read_local_logs: true + show_confirmation_questions: false + show_expanded_aliases: false + dark_mode: false + max_status_height: null + status_time_format: "%H:%M:%S" + status_datetime_format: "%Y-%m-%d\n%H:%M:%S" + +daemon: + default_parallel_tasks: 1 + pause_group_on_failure: false + pause_all_on_failure: false + callback: "Task {{ id }}\nCommand: {{ command }}\nPath: {{ path }}\nFinished with status '{{ result }}'\"" + callback_log_lines: 10 + groups: + default: 1 diff --git a/config/sh/bpftrace.sh b/config/sh/bpftrace.sh index 6df5fdc4a..a0fa6000f 100755 --- a/config/sh/bpftrace.sh +++ b/config/sh/bpftrace.sh @@ -85,7 +85,7 @@ case "$action" in scripts="$entry { @[kstack] = count(); }" ;; realtime) - scripts="$entry { print(\"hit $entry \n\") }" + scripts="$entry { print(\"hit $entry\") }" ;; *) exit 1 @@ -93,3 +93,4 @@ case "$action" in esac echo "sudo bpftrace -e \"$scripts\"" sudo bpftrace -e "$scripts" +# XXX 这里使用 bcc 工具集其实会更加简单,新的测试项目用 bcc 实现吧 diff --git a/config/sh/build-linux.sh b/config/sh/build-linux.sh index 29ff480fe..c06dd40ff 100755 --- a/config/sh/build-linux.sh +++ b/config/sh/build-linux.sh @@ -7,6 +7,9 @@ target=~/core/linux-build A=/tmp/martins3/source_build_unstage.diff B=/tmp/martins3/source_build_staged.diff +if ! cd $target; then + git clone $source $target +fi cd $source git diff >$A git diff --cached >$B @@ -20,8 +23,13 @@ git diff --cached >$B1 function update() { git reset --hard - [[ -s $A ]] && git apply $A - [[ -s $B ]] && git apply $B + if [[ -s $A ]]; then + git apply $A || true + fi + + if [[ -s $B ]]; then + git apply $B || true + fi } if diff $A $A1 &>/dev/null; then diff --git a/config/sh/funcgraph.sh b/config/sh/funcgraph.sh index 4c0c4ae77..9dfff37eb 100755 --- a/config/sh/funcgraph.sh +++ b/config/sh/funcgraph.sh @@ -8,16 +8,6 @@ if [[ ! -s $bpftrace_cache ]]; then sudo cat /sys/kernel/debug/tracing/available_filter_functions | tee $bpftrace_cache fi -trap finish EXIT - -function finish { - echo nop | sudo tee /sys/kernel/debug/tracing/current_tracer - echo | sudo tee /sys/kernel/debug/tracing/set_event - echo | sudo tee /sys/kernel/debug/tracing/trace -} - -finish - if [[ $# -eq 0 ]]; then entry=$(fzf <"$bpftrace_cache") else @@ -25,7 +15,6 @@ else entry=$(fzf --query="$*" <"$bpftrace_cache") fi -echo function_graph | sudo tee /sys/kernel/debug/tracing/current_tracer -echo "${entry%\[*\]}" | sudo tee /sys/kernel/debug/tracing/set_graph_function -echo | sudo tee /sys/kernel/debug/tracing/set_ftrace_filter # 有点奇葩,为什么不清空会影响输出的内容 -sudo cat /sys/kernel/debug/tracing/trace_pipe +set -x +# 可以指定 CPU +sudo perf ftrace -G "${entry% \[*\]}" -g 'smp_*' -g irq_enter_rcu -g __sysvec_irq_work -g irq_exit_rcu diff --git a/config/sh/tracepoint.sh b/config/sh/tracepoint.sh index 9dc1c4917..7fb348650 100755 --- a/config/sh/tracepoint.sh +++ b/config/sh/tracepoint.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash set -E -e -u -o pipefail -set -x mkdir -p /tmp/martins3 tracepoint_cache=/tmp/martins3/tracepoint_cache @@ -8,17 +7,7 @@ if [[ ! -s $tracepoint_cache ]]; then sudo cat /sys/kernel/debug/tracing/available_events | tee $tracepoint_cache fi -trap finish EXIT - -function finish { - # TODO 才知道,不是清理掉 current_tracer ,而是清理掉 set_event 才对 - echo nop | sudo tee /sys/kernel/debug/tracing/current_tracer - echo | sudo tee /sys/kernel/debug/tracing/set_event - echo | sudo tee /sys/kernel/debug/tracing/trace -} - -finish - +# sudo 和 fzf 使用有一个问题,例如 sudo perf list tracepoint | fzf ,没有办法输密码 if [[ $# -eq 0 ]]; then entry=$(fzf <"$tracepoint_cache") else @@ -26,6 +15,5 @@ else entry=$(fzf --query="$*" <"$tracepoint_cache") fi -echo "${entry}" | sudo tee /sys/kernel/debug/tracing/set_event -# TODO 这个模式有个问题,都是直接输出到屏幕的,需要输出一些到持久的位置 -sudo cat /sys/kernel/debug/tracing/trace_pipe +set -x +sudo perf trace -e "${entry}" diff --git a/config/tmux-note-private.yaml b/config/tmux-note-private.yaml index 146f86d2f..39f03b883 100644 --- a/config/tmux-note-private.yaml +++ b/config/tmux-note-private.yaml @@ -5,15 +5,8 @@ windows: shell_command_before: - cd ~/core/vn - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) - - window_name: .dotfiles + - window_name: module layout: tiled shell_command_before: - - cd ~/.dotfiles + - cd ~/core/vn/code/module/ - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) - # - window_name: dmesg - # layout: tiled - # shell_command_before: - # - cd ~/core/amd-crash - # panes: - # - dmesg -w - # - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) diff --git a/config/tmux-note.yaml b/config/tmux-note.yaml index a86a442f6..6be42228d 100644 --- a/config/tmux-note.yaml +++ b/config/tmux-note.yaml @@ -5,10 +5,10 @@ windows: shell_command_before: - cd ~/core/vn - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) - - window_name: .dotfiles + - window_name: module layout: tiled shell_command_before: - - cd ~/.dotfiles + - cd ~/core/vn/code/module/ - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) - window_name: draft layout: tiled diff --git a/config/wezterm.lua b/config/wezterm.lua index a4dee7631..59eeaa7dd 100644 --- a/config/wezterm.lua +++ b/config/wezterm.lua @@ -134,14 +134,22 @@ return { -- action = wezterm.action.ShowLauncher }, { - key = "m", - mods = "CTRL", + key = "t", + mods = "CTRL|SHIFT", + action = wezterm.action.SpawnCommandInNewTab({ + args = { "bash", "-l", "-c", "zellij attach || zellij" }, + }), + -- action = wezterm.action.ShowLauncher + }, + { + key = "i", + mods = "CTRL|SHIFT", action = wezterm.action.SpawnCommandInNewTab({ - args = { "ssh", "-t", "-p5556", "root@localhost", "zellij attach || zellij" }, + args = { "ssh", "-t", "martins3@192.168.19.55", "tmux attach || tmux" }, }), -- action = wezterm.action.ShowLauncher }, - { key = "F2", mods = "", action = wezterm.action.ShowLauncher }, + { key = "F8", mods = "", action = wezterm.action.ShowLauncher }, }, adjust_window_size_when_changing_font_size = false, default_prog = { "bash", "-l", "-c", "/usr/bin/env tmux attach || /usr/bin/env tmux" }, diff --git a/config/zsh b/config/zsh index 5c118f5dc..728f43f20 100644 --- a/config/zsh +++ b/config/zsh @@ -22,12 +22,16 @@ fi # 参考 https://gist.github.com/iansu/1ad9fc5db90aafbf14ce58e99d5940ef # prompt 中通过不同的 emoji 来标识架构 -if grep "GenuineIntel" /proc/cpuinfo >/dev/null; then - export SHELL_ARCH="🐙" -elif grep "AuthenticAMD" /proc/cpuinfo >/dev/null; then - export SHELL_ARCH="🐉" +if [[ -f ~/core/id ]]; then + export SHELL_ARCH=$(cat ~/core/id) else - export SHELL_ARCH="ARM" + if grep "GenuineIntel" /proc/cpuinfo >/dev/null; then + export SHELL_ARCH="🐙" + elif grep "AuthenticAMD" /proc/cpuinfo >/dev/null; then + export SHELL_ARCH="🐉" + else + export SHELL_ARCH="ARM" + fi fi eval "$(starship init zsh)" @@ -112,17 +116,16 @@ function zj() { } alias px="proxychains4 -f /home/martins3/.dotfiles/config/proxychain.conf" -alias mutt="proxychains4 -f /home/martins3/.dotfiles/config/proxychain.conf neomutt" -# alias mutt="proxychains4 -f /home/martins3/.dotfiles/config/proxychain.conf mutt -f" # 快速打开 QEMU alias dk="/home/martins3/.dotfiles/scripts/qemu/launch.sh -d" +alias qt="/home/martins3/.dotfiles/scripts/qemu/launch.sh -t" alias rk=/home/martins3/core/vn/docs/qemu/sh/alpine.sh -alias k=/home/martins3/.dotfiles/scripts/qemu/launch.sh alias kk="/home/martins3/.dotfiles/scripts/qemu/launch.sh -k" +alias rkk="/home/martins3/.dotfiles/scripts/qemu/choose_launch.sh" # 这里将 $ 转义,从而是执行 ge 命令的时候加载端口而非在 -# @todo 似乎我的 tmux 配置有问题导致 ssh 前需要设置一下环境变量 -alias ge="TERM=xterm-256color ssh -p\$(cat /tmp/martins3/guest-ssh) root@localhost" -alias gege="TERM=xterm-256color ssh-copy-id -p\$(cat /tmp/martins3/guest-ssh) root@localhost" +alias ge="/home/martins3/.dotfiles/scripts/qemu/launch.sh -s" +alias vnc="/home/martins3/.dotfiles/scripts/qemu/launch.sh -v" +alias gege="/home/martins3/.dotfiles/scripts/qemu/launch.sh -c" # 打开工作区间并且构建 alias b="/home/martins3/.dotfiles/config/sh/tmux.sh && exit" alias c="clear" @@ -136,7 +139,7 @@ alias kernel_version="git describe --contains" # https://unix.stackexchange.com/questions/45120/given-a-git-commit-hash-how-to-find-out-which-kernel-release-contains-it alias knews="/home/martins3/.dotfiles/scripts/systemd/news.sh kernel" alias ldc="lazydocker" -alias ls="exa --icons" +alias ls="eza --icons" alias m="chrt -i 0 make CC='ccache gcc' -j$(getconf _NPROCESSORS_ONLN)" alias bu="/home/martins3/.dotfiles/config/sh/build-linux.sh && cd ~/core/linux-build && m" alias mc="make clean" @@ -151,6 +154,7 @@ alias kvm_stat="sudo /home/martins3/core/linux/tools/kvm/kvm_stat/kvm_stat" alias p="python -m venv .venv && source .venv/bin/activate" alias i="ipython" alias t="/home/martins3/.dotfiles/config/sh/bpftrace.sh" +alias f="xclip -o >> /home/martins3/core/vn/fun.md && echo '' >> /home/martins3/core/vn/fun.md && cat /home/martins3/core/vn/fun.md" alias tracepoint="/home/martins3/.dotfiles/config/sh/tracepoint.sh" alias funcgraph="/home/martins3/.dotfiles/config/sh/funcgraph.sh" alias cloc="tokei . -f --sort lines" @@ -165,4 +169,10 @@ function config_repo(){ git config user.name martins3 git config user.email hubachelar@gmail.com } +function check(){ + cd ~/core/linux + tig --author="$*" +} +alias weather="curl wttr.in/beijin" alias drop_cache="echo 3 | sudo tee /proc/sys/vm/drop_caches" +alias wifi="nmcli dev wifi show-password" diff --git a/docs/anki.md b/docs/anki.md new file mode 100644 index 000000000..7af1e8647 --- /dev/null +++ b/docs/anki.md @@ -0,0 +1,25 @@ +## 参考 +- https://github.com/badlydrawnrob/anki +- https://news.ycombinator.com/item?id=39163094 + + +## anki-connect : 将 anki 变为可以编程的项目 +- https://git.foosoft.net/alex/anki-connect + +## 似乎很接近了 +https://github.com/Mochitto/Markdown2Anki + +## ankidroid app +https://github.com/ankidroid/Anki-Android + +## 还活这的项目 +https://github.com/kerrickstaley/genanki + +## 自己的基本尝试 +1. 安装 anki-connect +2. 使用 anki.sh + +## 代办 +1. 将 baidu.fanyi.com 中的生词全部都导入 +2. 常见的 trace 技术 +3. 完善脚本,支持更新 diff --git a/docs/monitor.md b/docs/monitor.md deleted file mode 100644 index 5a826bf93..000000000 --- a/docs/monitor.md +++ /dev/null @@ -1,39 +0,0 @@ -# 观测 - -## grafana -```sh -# 验证: grafana 的默认刷新时间是 1 分钟的 -for((i=0; i < 10000; i++)); do - curl -d "test,tag=1111 time=12,this=$i" -X POST 'http://127.0.0.1:8428/write' - sleep 1 -done -``` - -初始化 -```sh -cd ~/core -git clone https://github.com/VictoriaMetrics/VictoriaMetrics -cd ~/core/VictoriaMetrics/deployment/docker -docker compose up -d -``` -登录 127.0.0.1:3000 - -## 需要统计的 -- 启动 qemu 次数 -- 启动 shell 次数 -- ls 次数 -- nvim 次数 - -## page fault 次数 - -## 内存的碎片化程度 - -## buddy 的状态之类的 - -## kvm 的状态,利用 kvm_stat 长期监测 - -## io 和 网络流量,就是使用 sar 之类的观测就可以了 - -## 到底是谁在使用 shared memory - -## 记录下一天共启动 qemu 多少次 diff --git a/docs/nix-kernel-dev.md b/docs/nix-kernel-dev.md index 7c6d078cd..1e0c0fa46 100644 --- a/docs/nix-kernel-dev.md +++ b/docs/nix-kernel-dev.md @@ -54,3 +54,13 @@ sudo ./io_uring /dev/nvme0n1p1 ## linuxHeaders 不知道这个包是做啥的 + +## 为什么构建模块还需要额外的 kernel.dev 包,这里到底包含了什么 + +```txt +nix-shell '' -A linuxPackages_latest.kernel.dev --command " make -C $(nix-build -E '(import {}).linuxPackages_latest.kernel.dev' --no-out-link)/lib/modules/*/build M=""$(pwd)"" modules" +``` + +## 太牛了,这个人几乎将 nix 上构建内核所有问题都解决了? + +- https://github.com/jordanisaacs/kernel-module-flake diff --git a/docs/nix.md b/docs/nix.md index dc61d0ec2..0b4a74639 100644 --- a/docs/nix.md +++ b/docs/nix.md @@ -10,22 +10,13 @@ 之所以坚持使用 NixOS ,是因为我感觉 NixOS 非常符合计算机的思维, 那就是**相同的问题仅仅解决一次**,而这个问题是 环境配置。 -## 优缺点对比 - -### 优点 - -1. escape 和 Caps 之间互相切换更加简单 - -### 缺点 - -1. crash 无法安装 - ## 安装 -### 安装系统 +### 手动安装 + +#### 手动分区 参考[官方教程](https://nixos.org/manual/nixos/stable/index.html#sec-installation) 以及 -[这个解释](https://www.cs.fsu.edu/~langley/CNT4603/2019-Fall/assignment-nixos-2019-fall.html) 创建分区,安装操作系统,并且初始化 nixos @@ -43,16 +34,24 @@ swapon /dev/vda2 nixos-generate-config --root /mnt ``` -打开配置,需要进行两个简单的修改 - -```sh -vim /mnt/etc/nixos/configuration.nix -``` - -1. 取消掉这行的注释,从而有 grub +打开配置 /mnt/etc/nixos/configuration.nix 中实现 uefi 启动,并且含有 grub -```sh -# boot.loader.grub.device = "/dev/vda"; +```nix + # 将这行注释掉 + # boot.loader.systemd-boot.enable = true; + # 增加下如下内容 + boot = { + loader = { + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot"; + }; + grub = { + devices = [ "nodev" ]; + efiSupport = true; + }; + }; + }; ``` 2. 添加基本的工具方便之后使用 @@ -70,24 +69,17 @@ environment.systemPackages = with pkgs; [ 我在这里踩的坑 -- 以上使用的是 vda , 具体是什么,以 lsblk 为例子 - 在 QEMU 中 UEFI 暂时没有成功过,使用 legacy bios - QEMU 的参数中不要增加 `-kernel`,否则无法正确启动,因为 Nix 对于内核版本也是存在管理的,所以不能随意指定 -- 可以使用 ssh 远程链接安装的机器,这样就会有曾经熟悉的环境 -### 初始化环境 +#### 安装系统 使用 root 用户登录进去: -1. 创建用户和密码 +1. 创建 martins 用户,主要是为了创建 /home/martins3 目录出来 ```sh useradd -c 'martins three' -m martins3 -``` - -2. 切换到普通用户 - -```sh su -l martins3 ``` @@ -95,21 +87,15 @@ su -l martins3 ```sh git clone https://github.com/Martins3/My-Linux-Config +git checkout feat ``` 执行 ./scripts/install.sh 将本配置的文件软链接的位置。 -4. exit 到 root 执行,然后 ./scripts/nix-channel.sh 切换源 - -5. 修改 `/etc/nixos/configuration.nix`,让其 import `/home/martins3/.config/nixpkgs/system.nix`。**注意 martins3 改成你的用户名** +4. su +5. 执行 ./scripts/nixos-install.sh -6. 初始化配置 - -```sh -nixos-rebuild switch # 仅NixOS,其实在 root 状态下 -``` - -7. 切换为 martins3,开始部署 home-manager 配置 +6. 切换为 martins3,开始部署 home-manager 配置 ```sh # 安装home-manager @@ -117,16 +103,16 @@ nix-shell '' -A install home-manager switch ``` -## 图形界面的安装 +### 在图形界面的安装 1. [2.2. Graphical Installation](https://nixos.org/manual/nixos/stable/index.html#sec-installation-graphical) : 建议图形化安装 - 1.1 其中必然遇到网络问题 + 遇到网络问题,执行如下内容 ```sh sudo chmod +w /etc/nixos/configuration.nix sudo vim /etc/nixos/configuration.nix # 在配置中增加上 -# networking.proxy.default = "http://192.167.64.62:8889"; # 需要提前搭梯子 +# networking.proxy.default = "http://192.168.64.62:8889"; # 需要提前搭梯子 sudo nixos rebuild ``` @@ -142,11 +128,17 @@ sudo /home/martins3/.dotfiles/scripts/nixos-install.sh /home/martins3/.dotfiles/scripts/install.sh ``` -## kernel 本身是不可 reproducible 的 +最开始的时候无法 ssh ,所以以上操作都需要在图形界面中操作。 + +## 高级 -https://docs.kernel.org/kbuild/reproducible-builds.html +### 关于 reproducible build -## 基础知识 +- https://docs.kernel.org/kbuild/reproducible-builds.html +- https://news.ycombinator.com/item?id=19310638 +- https://tests.reproducible-builds.org/archlinux/archlinux.html + +## 常见操作 - nix-prefetch-url 同时下载和获取 hash 数值 @@ -156,17 +148,11 @@ nix-prefetch-url https://github.com/Aloxaf/fzf-tab - nixos 默认是打开防火墙的 - https://nixos.org/manual/nixos/unstable/options.html#opt-networking.firewall.enable -- 更新 Nixos 和设置源相同,更新 NixOS 之后可能发现某些配置开始报错,但是问题不大,查询一下社区的相关文档一一调整即可。 -- 查询是否存在一个包 - - 在命令行中查询 - -```sh -nix-env -qaP | grep 'gcc[0-9]\>' -nix-env -qaP elfutils -``` - -- 使用网站: https://search.nixos.org/packages +- NixOS 半年更新一次,更新 Nixos 和设置源相同,更新 NixOS 之后可能发现某些配置开始报错,但是问题不大,查询一下社区的相关文档一一调整即可。 +- 查询 nixos 的包和 options : https://search.nixos.org/packages - 安装特定版本,使用这个网站: https://lazamar.co.uk/nix-versions/ +- 如何升级 (update / upgrade) + - https://superuser.com/questions/1604694/how-to-update-every-package-on-nixos ## 自动环境加载 @@ -177,38 +163,8 @@ echo "use nix" >> .envrc direnv allow ``` -## 无法代理的解决 - -- 注意 export https_proxy 和 export HTTPS_PROXY 都是需要设置的 -- 可以使用 nload 检查一下网速,也许已经开始下载了,只是没有输出而已。 - -wget 可以,但是 nerdfont 安装的过程中,github 中资源无法正确下载。 - -因为下载是使用 curl 的,但是如果不添加 -L 似乎是不可以的 - -## syncthing - -强烈推荐,相当于一个自动触发的 rsync ,配置也很容易: - -- https://wes.today/nixos-syncthing/ -- https://nixos.wiki/wiki/Syncthing - -使用注意项,可以在两个机器中编辑同一个文件夹中的文件,但是注意不要同时多个机器上编辑同一个文件,否则存在冲突。 - ## npm 包管理 -支持的不是很好,需要手动安装 - -使用这个来搜索包[^1]: - -```sh -nix-env -qaPA nixos.nodePackages -``` - -但是只有非常少的包。 - -但是可以通过这个方法来使用传统方法安装: - - https://stackoverflow.com/questions/56813273/how-to-install-npm-end-user-packages-on-nixos 之后,安装无需使用 sudo 了 @@ -221,17 +177,7 @@ npm install -g prettier # npm install -g @microsoft/inshellisense ``` -设置代理现在可以在 nixos 中配置了: -```sh -npm config set registry https://registry.npm.taobao.org/ # 设置 npm 镜像源为淘宝镜像 -yarn config set registry https://registry.npm.taobao.org/ # 设置 yarn 镜像源为淘宝镜像 -``` - -## windows 虚拟机 - -### 性能优化 - -virtio +## 共享 ### 使用 samba 实现目录共享 @@ -246,11 +192,22 @@ sudo smbpasswd -a martins3 在 windows 虚拟机中,打开文件浏览器, 右键 `网络`,选择 `映射网络驱动器`,在文件夹中填写路径 `\\10.0.2.2\public` 即可。 如果遇到需要密码的时候,但是密码不对 + ```txt sudo smbpasswd -a martins3 ``` + 在 windows 那一侧使用 martins3 和新设置的密码来登录。 +### syncthing + +强烈推荐,相当于一个自动触发的 rsync ,配置也很容易: + +- https://wes.today/nixos-syncthing/ +- https://nixos.wiki/wiki/Syncthing + +使用注意项,可以在两个机器中编辑同一个文件夹中的文件,但是注意不要同时多个机器上编辑同一个文件,否则存在冲突。 + ## python ```txt @@ -267,6 +224,7 @@ pip install setuptools # 结果 readonly 文件系统 ``` 正确的解决办法是,之后,就按照正常的系统中使用 python: + ```txt python -m venv .venv source .venv/bin/activate @@ -298,45 +256,13 @@ nix-shell '' -A lua --command zsh ## kernel - https://nixos.wiki/wiki/Linux_kernel +- https://nixos.wiki/wiki/Kernel_Debugging_with_QEMU +- https://nixos.org/manual/nixos/stable/#sec-kernel-config -### 编译内核 - -目前的方法是使用 linux.nix 操作的,其中注意: - -- 内核的依赖是: elfutils - - 参考: https://github.com/NixOS/nixpkgs/issues/91609 - -另一种方法是直接复用 nixpkgs 中的配置: - -- https://ryantm.github.io/nixpkgs/using/overrides/ -- https://ryantm.github.io/nixpkgs/builders/packages/linux/#sec-linux-kernel - -```nix -with import { }; -linux.overrideAttrs (o: { - nativeBuildInputs = o.nativeBuildInputs ++ [ pkgconfig ncurses ]; -}) -``` - -## [ ] 如何增加模块 - -或者说,这个配置是做什么的 -/_ boot.extraModulePackages = with config.boot.kernelPackages; [ mce-inject ]; _/ +总体来说,构建 -### [ ] 编译内核模块 - -### 编译老内核 - -使用 docker 吧 - -### 安装自定义的内核 - -参考 https://nixos.wiki/wiki/Linux_kernel 中 Booting a kernel from a custom source 的,以及其他的章节, 使用自定义内核,不难的。 - -### [ ] crash - -- [ ] 对于一下 redhat 的工具,似乎当 kernel 挂掉之后难以正确的处理 - - [ ] https://github.com/crash-utility/crash 无法正确安装 +- 从哪里获取到 debuginfo ,如果可以获取,那么就可以使用 crash 来实现实时系统的分析 +- drgn 无法安装,使用也是未知 ## pkgs.stdenv.mkDerivation 和 pkgs.mkShell 的区别是什么 @@ -350,9 +276,9 @@ linux.overrideAttrs (o: { > pkgs.mkShell is a specialized stdenv.mkDerivation that removes some repetition when using it with nix-shell (or nix develop). -## 在 nix 中搭建内核调试的环境 +## 代理 -参考 https://nixos.wiki/wiki/Kernel_Debugging_with_QEMU +https://yacd.metacubex.one/#/proxies ## 交叉编译 @@ -361,29 +287,6 @@ linux.overrideAttrs (o: { - https://xieby1.github.io/Distro/Nix/cross.html - https://ianthehenry.com/posts/how-to-learn-nix/cross-compilation/ -但是不要妄想交叉编译老版本的内核,是一个时间黑洞。 - -在 :broom: remove cross-compile nix config 的提交中删除两个配置。 - -## 如何编译 kernel module - -- 参考这个操作: https://github.com/fghibellini/nixos-kernel-module -- 然后阅读一下: https://blog.prag.dev/building-kernel-modules-on-nixos - -没必要那么复杂,参考这个,中的 : Developing out-of-tree kernel modules - -- https://nixos.wiki/wiki/Linux_kernel - -```sh -nix-shell '' -A linuxPackages_latest.kernel.dev -make -C $(nix-build -E '(import {}).linuxPackages_latest.kernel.dev' --no-out-link)/lib/modules/*/build M=$(pwd) modules - -make SYSSRC=$(nix-build -E '(import {}).linuxPackages_latest.kernel.dev' --no-out-link)/lib/modules/$(uname -r)/source -``` - -- [ ] 搞清楚 kbuild 也许会让问题容易很多吧 -- [ ] 似乎现在是没有办法手动编译的 - ## tmux 为了让 tmux 配置的兼容其他的 distribution ,所以 tpm 让 nixos 安装,而剩下的 tmux 插件由 tmp 安装。 @@ -392,7 +295,7 @@ make SYSSRC=$(nix-build -E '(import {}).linuxPackages_latest.kernel.de 虽然暂时没有 gui 的需求,但是还是收集一下,以后在搞: -- [reddit : i3, polybar rofi](https://www.reddit.com/r/NixOS/comments/wih19c/ive_been_using_nix_for_a_little_over_a_month_and/) +- [reddit : i3, polybar rofi](https://www.reddit.com/r/NixOS/comments/wih19c/ive_been_using_nix_for_a_little_over_a_month_and/) ## 安装 unstable 的包 @@ -418,33 +321,6 @@ make SYSSRC=$(nix-build -E '(import {}).linuxPackages_latest.kernel.de 的提示, rnix-lsp 可以,但是 x86-manpages 不可以 -## 常用 lib - -```nix -readline.dev -SDL2.dev -``` - -## 学习 nix 语言 - -搭建环境: - -需要在 system.nix 中设置 - -```nix - nix.settings.experimental-features = "nix-command flakes"; -``` - -然后就可以使用 - -```sh -nix eval -f begin.nix -``` - -主要参考语言: - -- https://nixos.wiki/wiki/Overview_of_the_Nix_Language - ## gcc 和 clang 是冲突的 - https://github.com/nix-community/home-manager/issues/1668 @@ -457,14 +333,6 @@ nix eval -f begin.nix [打个包吧](https://unix.stackexchange.com/questions/717168/how-to-package-my-software-in-nix-or-write-my-own-package-derivation-for-nixpkgs) -## MAC 中使用 nix - -存在很多麻烦的地方: - -- https://github.com/mitchellh/nixos-config : 主要运行 mac ,而在虚拟机中使用 - - https://nixos.wiki/wiki/NixOS_on_ARM - - https://www.sevarg.net/2021/01/09/arm-mac-mini-and-boinc/ - ## tutorial ### nix pill @@ -519,26 +387,19 @@ in { - https://stackoverflow.com/questions/44088192/when-and-how-should-default-nix-shell-nix-and-release-nix-be-used -## 有趣的项目 - -### [ ] nixos-shell +## 虚拟化 - https://github.com/Mic92/nixos-shell - -### [ ] microvm.nix - + - https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/qemu-vm.nix - https://github.com/astro/microvm.nix - -### nixos-generators - -- [ ] 可以测试一下 nixos-generators,这个可以通过 configuration.nix 直接打包出来 iso,这不就免除了每次手动安装 iso 的吗? - - 这个项目提供的好几种方法安装,我是有点看不懂是什么意思的 https://github.com/nix-community/nixos-generators - -### nixpacks - -使用 nix 创建 OCI images - -- https://news.ycombinator.com/item?id=32501448 + - 是配置了文档的: https://astro.github.io/microvm.nix/intro.html +- https://github.com/nix-community/nixos-generators + - nixos-generate -f iso -c /etc/nixos/configuration.nix : 利用 squashfs 直接构建出来安装用 iso + - 可以通过 configuration.nix 直接打包出来 iso,这不就免除了每次手动安装 iso 的时候还要下载 + - 而且可以还可以构建 qcow2 + - 当然还是有点小问题,qcow2 构建直接报错,iso 的使用 qemu-system-x86_64 -cdrom /nix/store/ff5fcyx1ka3kmiw8bxl29l377d4xwn3i-nixos.iso/iso/nixos.iso --enable-kvm 启动,因为目前是含有 mount 的 ,systemd 无法正常启动的 +- nixpacks + - https://news.ycombinator.com/item?id=32501448 ## 其他有趣的 Linux Distribution @@ -553,27 +414,9 @@ in { ## [ ] flake.nix 实验特性 - - https://nixos.wiki/wiki/Flakes - https://news.ycombinator.com/item?id=36362225 -## [ ] rpm 构建的出来的 rpmbuild 权限不对 - -## [ ] 无法使用 libvirt 正确实现热迁移 - -```txt - virtualisation.libvirtd = { - enable = true; - # https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/virtualization_host_configuration_and_guest_installation_guide/app_tcp_ports - extraConfig = " - listen_tls = 1 - listen_tcp = 1 - listen_addr = \"0.0.0.0\" - "; - extraOptions = [ "LIBVIRTD_ARGS=\"--listen\"" ]; - }; -``` - ## switch caps 和 escape https://unix.stackexchange.com/questions/377600/in-nixos-how-to-remap-caps-lock-to-control @@ -585,9 +428,8 @@ gsettings reset org.gnome.desktop.input-sources xkb-options gsettings reset org.gnome.desktop.input-sources sources ``` -## nix - -- https://nixos.org/manual/nixos/stable/index.html#ch-file-systems +也许也需要执行下: +setxkbmap -option caps:swapescape ## 问题 @@ -596,8 +438,6 @@ gsettings reset org.gnome.desktop.input-sources sources - [ ] making a PR to nixpkgs : https://johns.codes/blog/updating-a-package-in-nixpkgs - https://ejpcmac.net/blog/about-using-nix-in-my-development-workflow/ - https://www.ertt.ca/nix/shell-scripts/ -- 测试一下,到底放不方便修改内核 - - 如果想要一份本地的源码,来安装,如何 ? - [ ] 挂载磁盘 https://nixos.org/manual/nixos/stable/index.html#ch-file-systems ## 需要验证的问题 @@ -612,15 +452,14 @@ gsettings reset org.gnome.desktop.input-sources sources - [Will Nix Overtake Docker?](https://news.ycombinator.com/item?id=29387137) - https://news.ycombinator.com/item?id=34119868 -忽然对于 Nix 有点兴趣,感觉自从用了 Ubuntu 之后,被各种 Linux Distribution 毒打的记忆逐渐模糊,现在想去尝试一下, -但是 Ian Henry 的[How to Learn Nix](https://ianthehenry.com/posts/how-to-learn-nix/) 写的好长啊, - -我发现,在 Ubuntu 安装我现在的 nvim 配置很麻烦,虽然可以写脚本,但是更多的时候是 -忘记了曾经安装过的软件。 +Ian Henry 的[How to Learn Nix](https://ianthehenry.com/posts/how-to-learn-nix/) 写的好长啊, ## 问题 -nix-env -i git 和 nix-env -iA nixpkgs.git 的区别是什么? +这三个命令的区别是什么: +- nix-env -i git +- nix-env -iA nixpkgs.git +- nix profile install nixpkgs#git ## 文档 @@ -671,15 +510,7 @@ Profiles and user environments are Nix’s mechanism for implementing the abilit ### manual : https://nixos.org/manual/nixpkgs/unstable/ -## 这个操作几乎完美符合要求啊 - -- https://github.com/gvolpe/nix-config : 这个也非常不错 -## TODO - -- [ ] https://nixos.org/learn.html#learn-guides -- [ ] https://nixos.org/ 包含了一堆 examples -- [ ] https://github.com/digitalocean/nginxconfig.io : Nginx 到底是做啥的 ## 你需要认真学习一波 @@ -763,7 +594,7 @@ Then try activating your Home Manager configuration again. - [ ] 理解一下什么叫做 overriding 啊 ```sh -$ nix-shell -E 'with import {}; linux.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkgconfig ncurses ];})' +$ nix-shell -E 'with import {}; linux.overrideAttrs (o: {nativeBuildInputs=o.nativeBuildInputs ++ [ pkg-config ncurses ];})' [nix-shell] $ unpackPhase && cd linux-* [nix-shell] $ make menuconfig ``` @@ -834,7 +665,6 @@ https://discourse.nixos.org/t/what-to-do-with-a-full-boot-partition/2049/13 ## 包搜索 -nix search nixpkgs markdown | fzf ## 静态编译 @@ -843,9 +673,9 @@ nix search nixpkgs markdown | fzf 应该使用这种方法: nix-shell -p gcc glibc.static -## 如何安装 nixos 主题 +## devenv -- https://github.com/NixOS/nixpkgs/blob/master/pkgs/data/icons/whitesur-icon-theme/default.nix +如何使用 ## 如何安装 steam @@ -869,42 +699,6 @@ programs.steam.enable = true; 但是不知道如何指定安装这个! -## [ ] openvpn - -- 直接使用是存在问题的 : https://github.com/OpenVPN/openvpn3-linux/issues/42 -- 之后修复了 - - https://github.com/NixOS/nixpkgs/pull/120352 - - https://github.com/NixOS/nixpkgs/pull/173937 - -从 pull request 中看,应该配置方法是: - -```nix - services.openvpn3.enable = true; -``` - -但是实际上应该是这样的: - -```nix - programs.openvpn3.enable = true; -``` - -最后,在 ubuntu 上可以正确执行的,结果在 nixos 上总是卡住的: - -```txt -🧀 openvpn3 log session-start --config client.ovpn -Waiting for session to start ... -``` - -有时间,我想直接切换为 wireguard 吧 - -## [ ] devenv - -- https://shyim.me/blog/devenv-compose-developer-environment-for-php-with-nix/ - -## [ ] 修改默认的 image 打开程序 - -默认是 microsoft-edge,但是我希望是 eog - ## 和各种 dotfile manager 的关系是什么 - https://www.chezmoi.io/ @@ -962,7 +756,6 @@ xfs_repair -L /dev/dm-1 参考 scripts/nix/pkg/static-qemu.nix - ## [ ] nixos 没有 centos 中对应的 kernel-tools 包 类似 kvm_stat 是没有现成的包,非常难受。nixmd @@ -1077,6 +870,7 @@ e=ttyS0,115200n8 console=tty0 $QEMU_KERNEL_PARAMS" \ - https://github.com/yaocccc/dwm : 看上去还不错,还有 bilibili 的介绍 启用 hyprland 的方法: + ```diff commit 6746b06b79275b160a433567b47d5e6c49445e77 Author: Martins3 @@ -1147,6 +941,7 @@ index 8490c95..c1c018b 100644 time.timeZone = "Asia/Shanghai"; time.hardwareClockInLocalTime = true; ``` + 还是感觉收益不大,而且启动之后 edge 无法使用。再度放弃。 ## 如何调试 host 内核 @@ -1229,21 +1024,6 @@ ulimit -c unlimited 其路径也是在 /var/lib/apport/coredump 中。 -## [ ] 想要安装一下 drgn 调试内核 - -https://drgn.readthedocs.io/en/latest/installation.html#id1 - -最后这个方法: - -```txt -python3 -m venv drgnenv -source drgnenv/bin/activate - python3 setup.py install - drgn --help -``` - -暂时在虚拟机中使用吧。 - ## [ ] infer 处理下 https://fbinfer.com/docs/getting-started/ @@ -1379,6 +1159,7 @@ sleep 34801 martins3 cwd DIR 259,2 4096 39060352 bus https://drakerossman.com/blog/wayland-on-nixos-confusion-conquest-triumph ## notification + 不知道为什么大家会专门的 notification 工具来 https://github.com/emersion/mako @@ -1403,6 +1184,7 @@ https://nixos.wiki/wiki/Bootloader 中最后提到如何增加 efi ```sh efibootmgr -c -d /dev/nvme0n1 -p 1 -L NixOS-boot -l '\EFI\NixOS-boot\grubx64.efi' ``` + 1. 注意,-p 1 来设置那个 partition 的。 2. 后面的那个路径需要将 boot 分区 mount 然后具体产看,还有一次是设置的 "\EFI\nixo\BOOTX64.efi" @@ -1416,8 +1198,8 @@ efiSysMountPoint = "/boot/efi"; # ← use the same mount point here. 不知道为什么 efibootmgr 在 home.cli 中无法安装。 - 删除一个: + ```txt sudo efibootmgr -B -b 3 # 3 是参数 ``` @@ -1425,33 +1207,18 @@ sudo efibootmgr -B -b 3 # 3 是参数 设置优先级 sudo efibootmgr -o 0,1,2 -## [ ] 如何下载 nixd - -看这里的文档: https://github.com/nix-community/nixd/blob/main/docs/user-guide.md - -nix profile install github:nixos/nixpkgs#nixd - -这个还很新,等到以后正式合并到 nixpkgs 中的时候再说吧! - - -## 感觉 nix 也是再快速发展,现在 nix-env -i 都不能用了 - -## amduperf 没有 -https://aur.archlinux.org/packages/amduprof - -但是 windows deb 和 rpm 都有 - -## 如何升级 - -sudo nix-env --upgrade -这个是做什么的 ## flakes book + - https://github.com/ryan4yin/nixos-and-flakes-book +作者的配置: +- https://github.com/ryan4yin/nix-config + 感觉写的相当不错。但是,问题是,我老版本的 nix channel 之类的还没掌握,怎么现在又切换了啊! ## nixos distribution + - https://github.com/exploitoverload/PwNixOS - 也可以作为参考 @@ -1461,25 +1228,21 @@ sudo nix-env --upgrade sudo proxychains4 -f /home/martins3/.dotfiles/config/proxychain.conf nixos-rebuild switch ``` -## noogλe : nix function exploring -- https://github.com/nix-community/noogle - -## 不知道做啥的 -https://mynixos.com/ - - -[^1]: https://unix.stackexchange.com/questions/379842/how-to-install-npm-packages-in-nixos ## 不知道如何调试代码,debug symbol 如何加载 + - https://nixos.wiki/wiki/Debug_Symbols ## [x] sar 无法正常使用 + ```txt 🧀 sar Cannot open /var/log/sa/sa21: No such file or directory Please check if data collecting is enabled ``` + 兄弟,是这个: + ```sh sar -n DEV 1 ``` @@ -1487,22 +1250,26 @@ sar -n DEV 1 ## 如何在 cgroup 中编译内核 可以采用这种方法: + ```sh sudo cgexec -g memory:mem3 nix-shell --command "make -j32" ``` 但是这种方法就不太妙了: + ```sh sudo cgexec -g memory:mem3 make -j32 ``` ## 文摘 + - [my first expression of nix](https://news.ycombinator.com/item?id=36387874_) - https://mtlynch.io/notes/nix-first-impressions/ -https://news.ycombinator.com/item?id=36387874 -https://news.ycombinator.com/item?id=32922901 + https://news.ycombinator.com/item?id=36387874 + https://news.ycombinator.com/item?id=32922901 ## 搞搞 cuda 吧 + https://nixos.org/community/teams/cuda ```nix @@ -1527,6 +1294,7 @@ pkgs.mkShell { ''; } ``` + 然后配合这个 : https://github.com/Tony-Tan/CUDA_Freshman https://news.ycombinator.com/item?id=37818570 @@ -1548,6 +1316,7 @@ https://news.ycombinator.com/item?id=37818570 ``` ## 又一个教程 + - https://gitlab.com/engmark/nix-start - https://github.com/Misterio77/nix-starter-configs @@ -1556,6 +1325,7 @@ https://news.ycombinator.com/item?id=37818570 此外,现在 systemd 中构建一次之后,在 zsh 中还是需要重新 make 一次 ## 如何在 nixpkgs 的基础上稍作修改制作自己的包 + git clone nixpkgs 跑到对应的路径下去: @@ -1563,3 +1333,163 @@ git clone nixpkgs nix-build -E 'with import {}; callPackage ./default.nix {}' https://elatov.github.io/2022/01/building-a-nix-package/ + +## 这个库 + +https://github.com/svanderburg/node2nix + +https://github.com/nix-community/NixOS-WSL + + +## 配置文件 + +```txt + fileSystems."/home/martins3/hack" = { + device = "/dev/disk/by-uuid/8eba61f5-5ed3-4221-ba7a-40b6ef3cbd62"; + fsType = "auto"; + options = [ "user"]; + }; +``` + +## 生成密码 + +mkpasswd -m sha-512 abc + +## 构建 github action + +```txt + services.github-runners = { + testrunner = { + enable = true; + user = "martins3"; + name = "test-runner"; + # token file is somewhere on local machine - in my case, it's not currently managed by nix + tokenFile = "/home/martins3/.github-runners"; + url = "https://github.com/Martins3/R9000P"; + }; + }; +``` + +tokenFile 只是需要包含 github 指导步骤中的 token 即可 + +```txt +./config.sh --url https://github.com/Martins3/R9000P --token xxx +``` + +## 需要将 username 变为可以定制化才可以,或者说 + +可以存在多个 username ,将 martins3 只是作为临时安装的一个名称,之后可以重新指向一个名称 + +有办法修改为 xueshi.hu 吗? + +## 常见命令 + +```sh +nix-env -qaPA nixos.nodePackages +``` + +## TODO : 真正的代办 + +参考这个文档,重新理解下到底如何优雅的构建内核驱动来着: +https://nixos.org/manual/nixos/stable/#sec-kernel-config + +> 如何编译 kernel module + +- 参考这个操作: https://github.com/fghibellini/nixos-kernel-module +- 然后阅读一下: https://blog.prag.dev/building-kernel-modules-on-nixos + +没必要那么复杂,参考这个,中的 : Developing out-of-tree kernel modules + +- https://nixos.wiki/wiki/Linux_kernel + +```sh +nix-shell '' -A linuxPackages_latest.kernel.dev +make -C $(nix-build -E '(import {}).linuxPackages_latest.kernel.dev' --no-out-link)/lib/modules/*/build M=$(pwd) modules + +make SYSSRC=$(nix-build -E '(import {}).linuxPackages_latest.kernel.dev' --no-out-link)/lib/modules/$(uname -r)/source +``` + +- [ ] 搞清楚 kbuild 也许会让问题容易很多吧 +- [ ] 似乎现在是没有办法手动编译的 + +> 学习 nix 语言 + +```sh +nix eval -f begin.nix +``` + +主要参考语言: + +- https://nixos.wiki/wiki/Overview_of_the_Nix_Language + +从 nixos virtualisation 中的实现直接 中开始入手吧 + +## 感受 +- arm 上安装 nixos 是很容易的,不要被 https://nixos.wiki/wiki/NixOS_on_ARM 骗了 +- nixos ui 主题 + - https://github.com/NixOS/nixpkgs/blob/master/pkgs/data/icons/whitesur-icon-theme/default.nix + +## 学习资料 + +- [ ] https://nixos.org/learn.html#learn-guides +- [ ] https://nixos.org/ 包含了一堆 examples +- [ ] https://github.com/digitalocean/nginxconfig.io : Nginx 到底是做啥的 + +## 工具 +- noogλe : nix function exploring + - https://github.com/nix-community/noogle + - https://noogle.dev/ +- https://mynixos.com/ + - 一个分享 nix 和 nixos 配置的网站 + - https://news.ycombinator.com/item?id=33762743 + + +## 缺陷 +- amduperf 没有 + - https://aur.archlinux.org/packages/amduprof + - 但是 windows deb 和 rpm 都有 + +## 材料 +nixos 在 sudo su 的情况下,基本没有什么命令可以执行,但是 nixos 之类的程序并不会如此 + +## 其他人的配置 +- https://github.com/gvolpe/nix-config : 这个也非常不错 + +## bpftool 和 bpftools 居然完全是同一个程序 +nixpkgs/home/cli.nix + +切换之后,居然是相同的,但是在 nixpkgs 无法搜索到 bpftool +```txt +lrwxrwxrwx - root 1 1月 1970  /home/martins3/.nix-profile/bin/bpftool -> /nix/store/md6qg2q7309xggbrjywcm5mjsiwiliv3-bpftools-6.5/bin/bpftool + +lrwxrwxrwx - root 1 1月 1970  /home/martins3/.nix-profile/bin/bpftool -> /nix/store/md6qg2q7309xggbrjywcm5mjsiwiliv3-bpftools-6.5/bin/bpftool +``` + + +## ps 都是从那里来的 + +```txt +🧀 l /home/martins3/.nix-profile/bin/ps + +Permissions Size User Date Modified Name +lrwxrwxrwx - root 1 1月 1970  /home/martins3/.nix-profile/bin/ps -> /nix/store/gb18gj7zpbhdavmsdr5090rx7lsvxvyk-procps-3.3.17/bin/ps +``` + +```txt +🧀 l /run/current-system/sw/bin/ps + +Permissions Size User Date Modified Name +lrwxrwxrwx - root 1 1月 1970  /run/current-system/sw/bin/ps -> /nix/store/gb18gj7zpbhdavmsdr5090rx7lsvxvyk-procps-3.3.17/bin/ps +``` +结论: 系统中本来就是自带了一份 + +## wps 的版本还是停留在 2019 +https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/office/wpsoffice/default.nix + +但是不知道怎么给他们更新。 + +## 基于 nix ? +https://github.com/flox/flox + +## 参考这个资源 +https://dotfiles.github.io/ diff --git a/docs/nvim-advantace.md b/docs/nvim-advantace.md index 27e9f7ed3..a0bb687d0 100644 --- a/docs/nvim-advantace.md +++ b/docs/nvim-advantace.md @@ -30,6 +30,60 @@ https://vi.stackexchange.com/questions/34454/how-does-smarttab-actually-works - [ ] Softtabstop : 既然是一个 tab 按下去的时候,产生多少个 space 的,那么只有允许 tab expand 的时候才有用吧 - [ ] 让 Softtabstop 和 Shiftwidth 不相等又什么好处吗? +- https://www.reddit.com/r/neovim/comments/17ak2eq/neovim_is_automatically_removing_trailing/ + +看后面的转义符,本来是对齐的,现在配置之后,似乎是 tab 装换为 space 了,变的不对齐了 +```c +#define __WAITQUEUE_INITIALIZER(name, tsk) { \ + .private = tsk, \ + .func = default_wake_function, \ + .entry = { NULL, NULL } } + +#define DECLARE_WAITQUEUE(name, tsk) \ + struct wait_queue_entry name = __WAITQUEUE_INITIALIZER(name, tsk) +``` + +### 从远程 server 上复制粘贴 + +在远程 server 复制,内容会进入到远程 server 的系统剪切板中,但是你往往是想复制本地的电脑的剪切板中。 + +使用插件 [ojroques/vim-oscyank](https://github.com/ojroques/vim-oscyank) 可以让在远程 server 的拷贝的内容直接进入到本地的系统剪切板上。 + +增加上如下命令到 init.vim ,可以实现自动拷贝到本地电脑中 +```vim +" "让远程的 server 内容拷贝到系统剪切板中,具体参考 https://github.com/ojroques/vim-oscyank +autocmd TextYankPost * + \ if v:event.operator is 'y' && v:event.regname is '+' | + \ execute 'OSCYankRegister +' | + \ endif + +autocmd TextYankPost * + \ if v:event.operator is 'd' && v:event.regname is '+' | + \ execute 'OSCYankRegister +' | + \ endif +``` + +使用方法,选中的内容之后,nvim 的命令行中执行: `OSCYankVisual` + +原理上参考: +- https://news.ycombinator.com/item?id=32037489 +- https://github.com/ojroques/vim-oscyank/issues/24 + +需要注意的是,这个功能依赖于 terminal 支持 OSC52 ,例如 Windows Terminal 就不支持,如果想在 Windows 中 +连接远程的 nvim,可以将 terminal 切换为 wezterm 等支持 OSC52 功能的终端。 + +不知道发生了什么,我现在无需安装任何插件,在 vim 中的任何操作都是直接从服务器拷贝到本地的: +这个原理太神奇了,现在看来只有两个小问题: +1. gx 打开本地的浏览器(需求比较小) +2. 输入法的自动切换 + +- 这是一个突破口 + - https://www.reddit.com/r/neovim/comments/13yw98e/how_can_i_switch_the_local_input_method_in_vim_on/ + +似乎有的机器可以这样,有的不可以,没太搞清楚差别。 + +从 amd 上连接 13900k 的机器的时候,似乎有时候会出现问题的。 + ## 黑魔法 - [`ctrl i`实际上等同于 tab 的](https://github.com/neoclide/coc.nvim/issues/1089), 重新映射为 `` `i`, 🤡 用了 5 年 vim 才知道这个。 - [vim 中 `` 和 `` 有什么区别](https://www.reddit.com/r/vim/comments/u2989c/what_is_the_difference_between_cr_and_enter/) @@ -46,23 +100,38 @@ https://vi.stackexchange.com/questions/34454/how-does-smarttab-actually-works 为 .dotfiles/nvim/debug/init.lua 和本配置 +## tree-sitter +- https://siraben.dev/2022/03/01/tree-sitter.html +- https://siraben.dev/2022/03/22/tree-sitter-linter.html + ## 参考 - https://blog.antoyo.xyz/vim-tips +- [ ] https://news.ycombinator.com/item?id=36312027 +- https://m4xshen.dev/posts/vim-command-workflow/ + +## 写这个插件的人水平一般啊 +- https://github.com/OscarCreator/rsync.nvim +- 完全没必要写这么复杂 + +## .h 默认启用的是 cpp ,但是 cpp 中没有 once +https://github.com/rafamadriz/friendly-snippets/blob/main/snippets/c/c.json + +## [ ] 此外,struct-> 补全的时候,会出现在第一个字母上 +- 是 ccls 的问题吗? + +## 插件开发 + + +https://zignar.net/2023/06/10/debugging-lua-in-neovim/ +## 问题 +- 极为细节的问题,但是折腾下应该还是可解的 + - ,s 的时候,正好匹配的那个总是不是第一个,检查一下 telescope + - https://www.trickster.dev/post/vim-is-touch-typing-on-steroids/ : 从后往前阅读 - - -本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 +- nvim 有待解决的问题,不是一时半会可以解决的: + 1. 编辑远程代码: 最佳状态是 vscode 的那种模式,收集一些替代,虽然都差的很远 + - https://github.com/jamestthompson3/nvim-remote-containers + - https://github.com/OscarCreator/rsync.nvim + - 但是 rsync 时间戳似乎维护的有问题,经常遇到这个问题: make: warning: Clock skew detected. Your build may be incomplete. + 2. [gcov](https://marketplace.visualstudio.com/items?itemName=JacquesLucke.gcov-viewer) diff --git a/docs/nvim.md b/docs/nvim.md index 21beb2721..aef25a01a 100644 --- a/docs/nvim.md +++ b/docs/nvim.md @@ -45,7 +45,6 @@ * [Session](#session) * [快速移动](#快速移动) * [输入法自动切换](#输入法自动切换) - * [从远程 server 上复制粘贴](#从远程-server-上复制粘贴) * [本配置源代码解释](#本配置源代码解释) * [FAQ](#faq) * [vim 的小技巧](#vim-的小技巧) @@ -54,7 +53,6 @@ * [有趣的插件](#有趣的插件) * [学习](#学习) * [找资源](#找资源) -* [问题](#问题) * [高级话题](#高级话题) * [衍生](#衍生) @@ -429,29 +427,28 @@ telescope 同样可以用于搜索文件使用 `,` `f` + 文件名 ### 导航 -利用 [vista](https://github.com/liuchengxu/vista.vim) 实现函数侧边栏导航(类似于 tagbar) ,打开关闭的快捷键 `c` `n`。 +利用 [aerial.nvim](stevearc/aerial.nvim) 实现函数侧边栏导航(类似于 tagbar) ,打开关闭的快捷键 `c` `n`。 -| 基于 liuchengxu/vista.vim 的导航栏 | +| 基于 stevearc/aerial.nvim 的导航栏 | | ---------------------------------- | | | ### 代码段 -基于[UltiSnips](https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt) 可以自己向 UltiSnips/c.snippets,UltiSnips/cpp.snippets 中间添加 C/C++ 的自己定义代码段。 以前刷 OJ 的时候每次都不知道要加入什么头文件,然后就写了一个自定义 snippet,一键加入所有常用的头文件。 +基于[friendly-snippets](https://github.com/rafamadriz/friendly-snippets/blob/main/snippets/c/c.json) 可以自己向 UltiSnips/c.snippets, +UltiSnips/cpp.snippets 中间添加 C/C++ 的自己定义代码段。 +以前刷 OJ 的时候每次都不知道要加入什么头文件,然后就写了一个自定义 snippet,一键加入所有常用的头文件。 ```snippets snippet import -#include -// 省略部分头文件,具体内容在下方的截图中间 -#include - -using namespace std; - -int main(){ - ${0} - return 0; -} -endsnippet + #include + // #include "../dbg.hpp" + using namespace std; + #define REOPEN_READ freopen("/home/maritns3/test/cpp/input.txt", "r", stdin); + int main(int argc, char *argv[]){https://github.com/rafamadriz/friendly-snippets/blob/main/snippets/c/c.json + ${0} + return 0; + } ``` | 输入 import 这些内容就自动补全 | @@ -464,7 +461,7 @@ endsnippet | ------------------------------------ | | | -使用 `enter` 来确认选择,使用 `tab` 移动。 +使用 `enter` 来确认选择,使用 `tab` 选择下一个。 ### Git 集成 @@ -626,35 +623,6 @@ vim 基本的移动技术,例如 e b w G gg 之类的就不说了, 下面简 当我在切换到 MacOS 的时候,发现输入法的自动切换不能正常工作,最后通过这个 [commit](https://github.com/Martins3/fcitx.nvim/commit/f1c97b6821a76263a84addfe5c6fdb4178e90ca9) 进行了修复。 -### 从远程 server 上复制粘贴 - -在远程 server 复制,内容会进入到远程 server 的系统剪切板中,但是你往往是想复制本地的电脑的剪切板中。 - -使用插件 [ojroques/vim-oscyank](https://github.com/ojroques/vim-oscyank) 可以让在远程 server 的拷贝的内容直接进入到本地的系统剪切板上。 - -增加上如下命令到 init.vim ,可以实现自动拷贝到本地电脑中 -```vim -" "让远程的 server 内容拷贝到系统剪切板中,具体参考 https://github.com/ojroques/vim-oscyank -autocmd TextYankPost * - \ if v:event.operator is 'y' && v:event.regname is '+' | - \ execute 'OSCYankRegister +' | - \ endif - -autocmd TextYankPost * - \ if v:event.operator is 'd' && v:event.regname is '+' | - \ execute 'OSCYankRegister +' | - \ endif -``` - -使用方法,选中的内容之后,nvim 的命令行中执行: `OSCYankVisual` - -原理上参考: -- https://news.ycombinator.com/item?id=32037489 -- https://github.com/ojroques/vim-oscyank/issues/24 - -需要注意的是,这个功能依赖于 terminal 支持 OSC52 ,例如 Windows Terminal 就不支持,如果想在 Windows 中 -连接远程的 nvim,可以将 terminal 切换为 wezterm 等支持 OSC52 功能的终端。 - ## 本配置源代码解释 总体来说,本配置的代码就是从上面介绍的各个项目提供的标准配置的组合,然后添加我的一些微调。 @@ -780,8 +748,6 @@ setxkbmap -option caps:swapescape - [neodev](https://github.com/folke/neodev.nvim) neovim 开发 lua 插件环境 - [conflict-marker.vim](https://github.com/rhysd/conflict-marker.vim) : 在 vim 中如何高效解决 git conflict - [nvim-ufo](https://github.com/kevinhwang91/nvim-ufo) 更加智能的折叠 -- [LuaSnip](https://github.com/L3MON4D3/LuaSnip) : snippet 管理器 - - [介绍从 UltiSnips 切换到 LuaSnip](https://www.reddit.com/r/neovim/comments/weonip/from_ultisnips_to_luasnip/) - [nvim-example-lua-plugin](https://github.com/jacobsimpson/nvim-example-lua-plugin) : 插件模板,打造你的第一个插件 - [codeium](https://github.com/Exafunction/codeium.vim) : Copilot 替代品 - [nvim-metals](https://github.com/scalameta/nvim-metals) : 芯片前端开发必备 @@ -789,6 +755,8 @@ setxkbmap -option caps:swapescape - [NeoComposer](https://github.com/ecthelionvi/NeoComposer.nvim) : 更好地使用 macro - [gesture.nvim](https://github.com/notomo/gesture.nvim) : nvim 中鼠标还可以这样用? - [legendary.nvim](https://github.com/mrjones2014/legendary.nvim) : 据说比 which-key 好用 +- [neodim](https://github.com/zbirenbaum/neodim) : 降低 没有引用的函数、变量亮度 (这个功能 coc.nvim 本来有,只可惜我换掉了 coc.nvim) +- [neotest](https://github.com/nvim-neotest/neotest) : 单元测试插件 ## 有趣的插件 @@ -807,24 +775,6 @@ setxkbmap -option caps:swapescape 1. [vimcolorschemes](https://vimcolorschemes.com/) vim 主题网站 2. [awesome neovim](https://github.com/rockerBOO/awesome-neovim) -## 问题 -- 极为细节的问题,但是折腾下应该还是可解的 - - shellcheck 无法处理 source 其他的文件的情况。 - - ,s 的时候,正好匹配的那个总是不是第一个,检查一下 telescope - - https://github.com/ranjithshegde/ccls.nvim : treesitter 跳转到函数头还是不精准 - - https://github.com/uga-rosa/cmp-dictionary/wiki/Examples-of-usage : 补全中没有 10K words 这种数据来源 - - https://github.com/koalaman/shellcheck/issues/1284 - - https://www.trickster.dev/post/vim-is-touch-typing-on-steroids/ : 从后往前阅读 - - leap.nvim 似乎特殊处理过 f/F 以及 t/T 的 - - [neodim](https://github.com/zbirenbaum/neodim) : 等待升级到 0.10 - - crusj/bookmarks.nvim 需要配置 virt_pattern,感觉多次一举 -- nvim 有待解决的问题,不是一时半会可以解决的: - 1. 编辑远程代码: 最佳状态是 vscode 的那种模式,收集一些替代,虽然都差的很远 - - https://github.com/jamestthompson3/nvim-remote-containers - - https://github.com/OscarCreator/rsync.nvim - - 但是 rsync 时间戳似乎维护的有问题,经常遇到这个问题: make: warning: Clock skew detected. Your build may be incomplete. - 2. [gcov](https://marketplace.visualstudio.com/items?itemName=JacquesLucke.gcov-viewer) - ## 高级话题 - [高级话题](./nvim-advantace.md),至少对于我来说比较高级 🤣 @@ -861,4 +811,5 @@ setxkbmap -option caps:swapescape async> + 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 diff --git a/docs/terminals.md b/docs/terminals.md index 7bfd12d5d..80f52ba6d 100644 --- a/docs/terminals.md +++ b/docs/terminals.md @@ -11,6 +11,7 @@ * [Kitty : 2022-2023](#kitty-2022-2023) * [Tabby : 几分钟](#tabby-几分钟) * [wezterm : 2023-现在](#wezterm-2023-现在) +* [其他的内容](#其他的内容) * [总结](#总结) @@ -75,6 +76,10 @@ Alacritty 的优点: 配置大约花费了半个小时,最后 tab 栏有点丑,其他还好。 + +## 其他的内容 +- [kernel terminal](https://news.ycombinator.com/item?id=39737810) + ## 总结 目前,我推荐的 terminal 是: - kitty diff --git a/docs/why.md b/docs/why.md index a5d08985a..a4878135d 100644 --- a/docs/why.md +++ b/docs/why.md @@ -1,10 +1,62 @@ -写代码要快乐的写,不要带着痛苦面具写,写代码的过程是让计算机完成之前不可能完成的挑战。 +# 为什么我要去折腾 Linux +这个问题需要分成两个部分回答: +1. 为什么是 Linux ; +2. 为什么要折腾。 +## Linux -## 其他资源 -https://dotfiles.github.io/ +就目前来说,我勉强算是一个 Linux 内核工程师,但是成为 Linux 内核工程师总体来说 +我刻意选择的结果。Linux 在我看来是一个有趣的项目: +1. 复杂,有挑战的乐趣[^1]。 +2. 有用,几乎无处不在,从 Android 到数据中心,从通讯基站到超级计算机,从洗衣机到汽车。 +3. 开源,你无需参加微软或者 Apple 的面试,只需要一个邮箱就可以参与内核开发。一分钱都用不付就可以定制自己的 Linux 内核。 +4. 社区,我大年 30 都不回家,这里各个都是人才,说话又好听,超喜欢在里面的。 -## 但是,不要 +## 折腾 +1. 看似慢,实则块。 -1. 过度 fashion : coc.nvim 的切换 +有的人写代码不写单元测试,项目不配置 ci ,代码风格随意,重复的代码不做抽象等。 +这些操作看似可以加快项目的推进速度,实际上最后会导致各种低级 bug 层出不穷,得不偿失。 + +折腾 Linux 操作也是类似的,看似折腾 neovim ,tmux 会浪费掉一些时间,但是如果你计划写 +几十年的代码[^2],平均下来这部分的开销很少。 + +2. [加快经常性事件](https://en.wikipedia.org/wiki/Amdahl%27s_law)。 + +如果一个事情你经常做,那么就应该想办法优化它的流程,最好是可以完全自动化。 +各种商业软硬件都是考虑到大多数用户的需求,如果你恰好有一些特殊的需求无法被覆盖到,那么你可能会比较难受。 + +例如我有一个需求是定期拉取最新的 Linux 内核,然后使用上我的配置构建出来,开始的时候我还是手动操作,搞了 +几次之后就把他变成了一个小脚本 + +3. 如何保证相同的错误不会犯两次。 + +手动操作存在引入错误的风险,因为人会困,会累,有情绪,会疏忽。 +但是程序不会,如果程序执行错误,那么我们可以继续优化,让程序不断进化。 + +## 最后 + +但是不要舍本逐末了,为了酷炫而酷炫,我现在有点后悔将 coc.vim 替换掉了。 + + +[^1]: 好吧,就我目前的水平而言,大多数时候是挑战的折磨。 +[^2]: 我知道有人会说程序员是青春饭,如果你也是这么想的,你可以关掉页面。 +[^3]: 参考本项目 scripts/systemd/sync-kernel.sh。 + + + +本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 diff --git a/kernel/guest-setup/asahi.sh b/kernel/guest-setup/asahi.sh deleted file mode 100644 index edfd88b43..000000000 --- a/kernel/guest-setup/asahi.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash -# trouble shooting -# 1. Flushed pacman's local mirror, now Hector Martin is not trusted -# - https://www.reddit.com/r/AsahiLinux/comments/uepj78/flushed_pacmans_local_mirror_now_hector_martin_is/ -# 2. 但是不是这个方法导致的,是 gpg 的问题,直接将所有内容清空 -# - https://unix.stackexchange.com/questions/364236/why-is-pacman-key-trying-to-download-the-public-key-for-the-pacman-keyring-maste - -## 更换镜像源 - -mirrorlist=/etc/pacman.d/mirrorlist -if ! grep tuna $mirrorlist; then - # arm 和 x86 的源是不一样的 - # https://mirrors.tuna.tsinghua.edu.cn/help/archlinuxarm/ - echo -e "Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxarm/\$arch/\$repo \n$(cat $mirrorlist)" >$mirrorlist - - # 不知道怎么搞的 - # 应该是更新镜像之后,需要立刻修改更新 GPG - # https://blog.csdn.net/weixin_36250058/article/details/112713233 - sudo pacman -Syy - sudo rm -r /etc/pacman.d/gnupg - sudo pacman-key --init - sudo pacman -S archlinux-keyring - sudo pacman-key --populate archlinux - sudo pacman-key --populate archlinuxarm - -fi - -sudo pacmna -S syncthing -sudo systemctl enable syncthing@martins3.service -sudo systemctl start syncthing@martins3.service -sudo systemctl status syncthing@martins3.service -echo "edit $HOME/.config/syncthing/config.xml" -echo "1. change 127.0.0.1 to 0.0.0.0 so that access the web ui in LAN" -echo "2. disable relay and global discovery" - -function setup_gitconfig() { - echo "copy it manually" -} - -sudo pacman -S neovim zoxide atuin starship exa tree-sitter -sudo pacman -S nodejs yarn clangd greenlet - -sudo pip3 install pynvim ripgrep tig -sudo pacman -Sy base-devel python-greenlet -sudo pacman -Sy wezterm ttf-firacode-nerd -sudo pacman -Sy kitty ttf-firacode-nerd docker - -sudo systemctl enable docker -sudo systemctl restart docker -sudo systemctl status docker -sudo usermod -aG docker "$USER" - -function setup_zsh() { - sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" - echo "source ~/.zsh/config/zsh" >>~/.zshrc -} - -function pip_mirror() { - python -m pip install --upgrade pip - pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple -} diff --git a/kernel/guest-setup/fedora.md b/kernel/guest-setup/fedora.md deleted file mode 100644 index 254e01bad..000000000 --- a/kernel/guest-setup/fedora.md +++ /dev/null @@ -1,43 +0,0 @@ -# 构建内核 - -https://rpmfusion.org/Howto/NVIDIA - -太惨了,居然被删除了 -https://src.fedoraproject.org/rpms/ccls - -https://fedoraproject.org/wiki/How_to_use_kdump_to_debug_kernel_crashes - -sudo kdumpctl reset-crashkernel -sudo systemctl enable kdump.service -sudo dnf install --enablerepo=fedora-debuginfo --enablerepo=updates-debuginfo kexec-tools crash kernel-debuginfo - -## 字体 -https://www.nerdfonts.com/font-downloads - -```sh -mkdir ~/.local/share/fonts -unzip *.zip -d ~/.local/share/fonts/ # -fc-cache ~/.local/share/fonts -``` - -## edge 浏览器 - -```txt -sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc -sudo dnf config-manager --add-repo https://packages.microsoft.com/yumrepos/edge -sudo mv /etc/yum.repos.d/packages.microsoft.com_yumrepos_edge.repo /etc/yum.repos.d/microsoft-edge-beta.repo -sudo dnf install microsoft-edge-beta -``` - -## 将默认的文件系统记得换一下 - -btrfs 感觉问题很大啊 - -## 切换内核 - - -sudo dnf copr enable kwizart/kernel-longterm-5.15 fedora-38-x86_64 - -https://copr.fedorainfracloud.org/coprs/kwizart/kernel-longterm-5.15/ - -这个方法不好用,还不如直接下载 rpm 来安装的 diff --git a/kernel/guest-setup/fedora.sh b/kernel/guest-setup/fedora.sh deleted file mode 100644 index cadf41b8a..000000000 --- a/kernel/guest-setup/fedora.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env bash -set -E -e -u -o pipefail - -sudo dnf install -y npm cargo clang-devel llvm-devel -sudo dnf install -y tig tmux cmake rsync ripgrep -sudo dnf install -y starship duf fastfetch - -git clone --depth=1 --recursive https://github.com/MaskRay/ccls -cd ccls -cmake . -make -j - -function setup_git() { - scp ... -} - -function setup_zellij() { - sudo dnf copr enable varlad/zellij - sudo dnf install zellij -} - -function setup_gum() { - echo '[charm] -name=Charm -baseurl=https://repo.charm.sh/yum/ -enabled=1 -gpgcheck=1 -gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo - sudo yum install gum -} - -function setup_fedora() { - sudo dnf copr enable wezfurlong/wezterm-nightly - sudo dnf -y install wezterm -} - -function setup_zsh() { - sudo dnf install zsh - sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)" - if [[ ! -d ~/.oh-my-zsh ]]; then - sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" - git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}"/plugins/zsh-autosuggestions - sed -i "s/plugins=(git)/plugins=(git zsh-autosuggestions)/g" ~/.zshrc - fi - - echo "source /home/martins3/.dotfiles/config/zsh" >>~/.zshrc - echo "source /home/martins3/core/zsh/zsh" >>~/.zshrc - - curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash - curl -sS https://starship.rs/install.sh | sh - cargo install exa - cargo install atuin - - # 跳转工具需要放到 .zshrc 的最前面 - # export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin:$HOME/.cargo/bin/:$PATH -} - -function setup_qemu() { - sudo dnf install sphinx ninja-build glib2-devel libiscsi-devel virglrenderer-devel gtk3-devel numactl-devel libusb1-devel -} - -sudo dnf install -y iperf3 btop perf libaio-devel liburing-devel -sudo dnf install -y ccache fzf - -# https://superuser.com/questions/1196241/how-to-remap-caps-lock-on-wayland -gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']" - -sudo dnf install openvswitch -sudo systemctl enable openvswitch.service -sudo systemctl start openvswitch.service -sudo ovs-vsctl show - -sudo dnf install bpftrace - -sudo dnf install fcitx5-rime - -sudo dnf install kernel-devel kernel-debug - -sudo dnf install python3-pip - -pip install pre-commit tmuxp - -sudo dnf install -y fd-find sysstat ipython - -# npm install @lint-md/cli@beta -# diff --git a/kernel/guest-setup/oe.md b/kernel/guest-setup/oe.md deleted file mode 100644 index 246772556..000000000 --- a/kernel/guest-setup/oe.md +++ /dev/null @@ -1,40 +0,0 @@ -# openEuler 虚拟机测试 - -## 安装配置 -将分区从 LVM 修改为普通配置。 - - -## 安装之后的手动配置 -1. 配置网络 -```sh -cd /etc/sysconfig/network-scripts/ -ip a -``` -检查下网卡名称 - -2. 拷贝公钥 -```sh -ssh-copy-id -p 5556 root@localhost -``` - -3. 删除密码 -```sh -passwd --delete root -``` - -4. 启动代理 -```sh -export https_proxy=http://10.0.2.2:8889 -export http_proxy=http://10.0.2.2:8889 -export HTTPS_PROXY=http://10.0.2.2:8889 -export HTTP_PROXY=http://10.0.2.2:8889 -export ftp_proxy=http://10.0.2.2:8889 -export FTP_PROXY=http://10.0.2.2:8889 -``` - -5. 将 initramfs 拷贝出来 - -进入到 guest 中: -```sh -scp initramfs-6.1.19-7.0.0.17.oe2303.x86_64.img martins3@10.0.2.2:/home/martins3/hack/vm/iso-name-initramfs.img -``` diff --git a/kernel/guest-setup/oe22.sh b/kernel/guest-setup/oe22.sh deleted file mode 100644 index b825469b2..000000000 --- a/kernel/guest-setup/oe22.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -set -E -e -u -o pipefail - -yum install -y audit-libs-devel binutils-devel bison \ - elfutils-devel elfutils-libelf-devel flex openssl-devel - -cd kernel -make -j32 && sudo make install -j32 && sudo make modules_install -j32 -dracut --regenerate-all -f -# sudo update-initramfs -c -k all - -grub2-mkconfig -o /etc/grub2-efi.cfg -# sudo update-grub - -# 如果只是一个模块 -make M=./arch/x86/kvm/ modules -j32 -make M=./arch/x86/kvm/ modules_install -sudo update-initramfs -c -k "$(uname -r)" # 当然如果这个如果是启动的时候需要的包 -reboot diff --git a/kernel/guest-setup/oe23.sh b/kernel/guest-setup/oe23.sh deleted file mode 100644 index 445a9ca79..000000000 --- a/kernel/guest-setup/oe23.sh +++ /dev/null @@ -1,188 +0,0 @@ -#!/usr/bin/env bash - -set -E -e -u -o pipefail -cd "$(dirname "$0")" - -function install() { - for i in "${@:1}"; do - yum install -y "$i" - done -} - -# on centos 7 -function legacy-stress-ng() { - wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/s/stress-ng-0.07.29-2.el7.x86_64.rpm - yum install stress-ng-0.13.00-5.el8.x86_64.rpm -} - -# no stress-ng in oe -function setup_stress-ng() { - wget http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/Packages/stress-ng-0.13.00-5.el8.x86_64.rpm -O /tmp/stress-ng.rpm - yum install -y /tmp/stress-ng.rpm -} - -function setup_libcgroup() { - if [[ ! -d libcgroup ]]; then - git clone https://github.com/libcgroup/libcgroup - fi - pushd libcgroup - - test -d m4 || mkdir m4 - autoreconf -fi - rm -fr autom4te.cache - - ./configure && make -j && make install - # 将会自动安装到 /usr/local/bin/cgexec 中 - popd -} - -# only zsh 安装 -# https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md#oh-my-zsh -function ohmyzsh() { - yum install -y zsh git - if [[ ! -d ~/.oh-my-zsh ]]; then - sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" - git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}"/plugins/zsh-autosuggestions - sed -i "s/plugins=(git)/plugins=(git zsh-autosuggestions)/g" ~/.zshrc - fi -} - -function setup_share() { - mkdir ~/share - cat <<'EOF' >/etc/systemd/system/share.service -[Unit] -Description=reboot - -[Service] -Type=oneshot -ExecStart=mount -t 9p -o trans=virtio,version=9p2000.L host0 /root/share - -[Install] -WantedBy=getty.target -EOF - - systemctl enable share -} - -# guest crash 太频繁,增加额外的命令 -function zsh_fix() { - if grep martins3 ~/.zshrc; then - return - fi - cat <<'EOF' >~/fix -#!/usr/bin/zsh - -set -e -cd ~ -mv .zsh_history .zsh_history_bad -strings -eS .zsh_history_bad > .zsh_history -fc -R .zsh_history -EOF - chmod +x ~/fix - - cat <<'EOF' >>~/.zshrc -# martins3 -alias f=/root/fix - -function px(){ - export https_proxy=http://10.0.2.2:8889 - export http_proxy=http://10.0.2.2:8889 - export HTTPS_PROXY=http://10.0.2.2:8889 - export HTTP_PROXY=http://10.0.2.2:8889 - export ftp_proxy=http://10.0.2.2:8889 - export FTP_PROXY=http://10.0.2.2:8889 -} - -alias q="exit" -alias gs="tig status" -alias ins="yum install -y" - -EOF - -} - -function setup_ncdu() { - version=2.2.1 - wget https://dev.yorhel.nl/download/ncdu-$version-linux-x86_64.tar.gz - tar -xvf ncdu-$version-linux-x86_64.tar.gz - mv ncdu /usr/local/bin - rm ncdu-$version-linux-x86_64.tar.gz -} - -# 默认的 tig 太老了 -function setup_tig() { - git clone https://github.com/jonas/tig - pushd tig - make -j - mv src/tig /root/bin - popd -} - -function setup_fio() { - cat <<'EOF' >>~/test.fio -[global] -ioengine=libaio -iodepth=128 - -[trash] -bs=4k -direct=1 -filename=/dev/nvme0n1 -rw=randread -runtime=30000 -time_based -EOF -} - -function setup_zellij() { - echo "TODO" -} - -function setup_fzf() { - echo " https://github.com/junegunn/fzf/blob/master/BUILD.md" -} - -function setup_initramfs() { - scp /boot/initramfs-"$(uname -r)".img martins3@10.0.2.2:/tmp -} - -function setup_partid() { - echo "TODO : 获取到 root partuuid ,拷贝取出" -} - -function remove_paswd() { - echo "TODO" -} - -function setup_pcm() { - echo "TODO" -} - -cd ~ -[[ ! -d install ]] && mkdir -p install && cd install - -mkdir /root/bin -install autoconf -install automake -install libtool -install systemd-devel -install bcc - -install vim htop perf elfutils elfutils-libelf-devel iperf3 sysstat - - -install pam-devel -install numactl fio libaio-devel -install flex flex-devel bios bison-devel -install ncurses-devel # tig 依赖 -install tree - -ohmyzsh -zsh_fix -setup_share -setup_tig -setup_libcgroup -setup_stress-ng -setup_fio -setup_zellij -setup_fzf diff --git a/kernel/guest-setup/readme.md b/kernel/guest-setup/readme.md deleted file mode 100644 index c2e8dd68b..000000000 --- a/kernel/guest-setup/readme.md +++ /dev/null @@ -1,196 +0,0 @@ -# Guest OS 初始化 - -暂时尝试过使用 cloud-init 或者 nixos 来构建 Guest 机器,但是最后发现太难 hacking 了。 - - -# 基本设计 - -将参数分离开,组合测试 - -- corn list -- corn setup -- corn execute # 使用 ansible 来自动控制 -- corn avocado # 使用 avocado 来进行测试 - -## 编译 ubuntu 内核 : 没太大必要,因为编译 rpm 也非常快 -```txt -GEN debian -Using default distribution of 'unstable' in the changelog -Install lsb-release or set $KDEB_CHANGELOG_DIST explicitly -dpkg-buildpackage -r"fakeroot -u" -a$(cat debian/arch) -b -nc -uc -dpkg-buildpackage: info: source package linux-upstream -dpkg-buildpackage: info: source version 6.3.0-rc1-00002-g8ca09d5fa354-dirty-169 -dpkg-buildpackage: info: source distribution unstable -dpkg-buildpackage: info: source changed by martins3 -dpkg-architecture: warning: specified GNU system type x86_64-linux-gnu does not match CC system type x86_64-unknown-linux-gnu, try setting a correct CC environment variable -dpkg-buildpackage: info: host architecture amd64 - dpkg-source --before-build . -dpkg-source: info: using options from linux/debian/source/local-options: --diff-ignore --extend-diff-ignore=.* -dpkg-checkbuilddeps: error: cannot open /var/lib/dpkg/status: No such file or directory -dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting -dpkg-buildpackage: warning: (Use -d flag to override.) -make[1]: *** [scripts/Makefile.package:127: bindeb-pkg] Error 3 -make: *** [Makefile:1657: bindeb-pkg] Error 2 -``` -借用 https://github.com/a13xp0p0v/kernel-build-containers 的实现。 - -https://wiki.debian.org/BuildADebianKernelPackage -参考: - make -j`nproc` bindeb-pkg - -不知道为什么,还是这个错误: -```txt - SYNC include/config/auto.conf.cmd -make[2]: scripts/kconfig/conf: No such file or directory -make[2]: *** [scripts/kconfig/Makefile:77: syncconfig] Error 127 -make[1]: *** [Makefile:693: syncconfig] Error 2 -make: *** [Makefile:794: include/config/auto.conf.cmd] Error 2 -``` - -## [x] build docker 镜像还是存在问题的 -sudo apt install dpkg-dev rsync kmod cpio - -## [x] 验证一下,是否可以用安装 - -.rw-r--r-- 8.9M root 9 Mar 17:08  linux-headers-6.3.0-rc1-00002-g8ca09d5fa354_6.3.0-rc1-00002-g8ca09d5fa354-4_amd64.deb -.rw-r--r-- 13M root 9 Mar 17:08  linux-image-6.3.0-rc1-00002-g8ca09d5fa354_6.3.0-rc1-00002-g8ca09d5fa354-4_amd64.deb -.rw-r--r-- 1.3M root 9 Mar 17:08  linux-libc-dev_6.3.0-rc1-00002-g8ca09d5fa354-4_amd64.deb - -虽然没有 debuginfo 包,但是我已经持有了 vmlinux ,其实无所谓 - -### 实际上,我们发现,只要是 -1. make defconfig kvm_guest.config 几乎任何内核都可以拉起来的 -2. 就是编译的内核有点大,不知道为什么。 - -## 需求 -### 使用 grubby 自动切换内核,修改 kernel cmdline -```sh -sudo grubby --update-kernel=ALL --args="nokaslr console=ttyS0,9600 earlyprink=serial" -``` -### 删除 guest 密码 - -### guest 中 oh-my-zsh 的基本命令 - -## 自动启动嵌套虚拟化 -```c -function share() { - cat <<'EOF' >/etc/systemd/system/nested.service -[Unit] -Description=nested virtualization setup - -[Service] -Type=oneshot -ExecStart=/root/core/vn/docs/qemu/sh/alpine.sh - -[Install] -WantedBy=getty.target -EOF - -systemctl enable nested -} -``` - -## 增加 edk2 的环境搭建 - -## 使用 libvirt 也是可以装系统的,但是需要 ovs - -## 打包方式 -```txt -Kernel packaging: - rpm-pkg - Build both source and binary RPM kernel packages - srcrpm-pkg - Build only the source kernel RPM package - binrpm-pkg - Build only the binary kernel RPM package -``` - -# corn - -一键 hacking 环境,收集各种 hacking 环境的脚本: -- avocado -- ansible -- grafana -- libvirt -- ovs -- perf / kvm_stat -- QEMU 调试 -- [ ] 虚拟机的自动安装 - - [ ] avocado -- [ ] core latency -- [ ] cache latency -- [ ] numa latency -- [ ] 各种 perf ,bpftrace,ftrace 之类的 -- [ ] 错误注入 - - -## [ ] python perf 有点问题 - -## perf 脚本 - -## dracut 生成规则是什么 -安装系统和安装驱动的过程中, - -了解下这里面的参数: -- https://man7.org/linux/man-pages/man7/dracut.cmdline.7.html - -```txt - The traditional root=/dev/sda1 style device specification is - allowed, but not encouraged. The root device should better be - identified by LABEL or UUID. If a label is used, as in - root=LABEL= the initramfs will search all - available devices for a filesystem with the appropriate label, - and mount that device as the root filesystem. - root=UUID= will mount the partition with that UUID as - the root filesystem. -``` -忽然意识到,实际上,kernel 的参数修改成为这个样子会更加好。 - -## 其实是两者都有问题: - -## 调试一下 udev -journalctl -u systemd-udevd.service - -## dracut 的源码可以分析下,主要是 dracut install 中,还是非常简单的 - -## 能否让 ci 运行在 github ci 中? -或者提交给 github,让本地的 ci 自动检测 - -## 能否直接访问网络 - -## 搭建 bios 调试环境 - -## 测试 cpu 和内存的热插拔 - -## 一些 Guest 的细节问题 - -- oe20.04 的网卡无法自动打开 - -将 /etc/sysconfig/network-scripts/enp1s0 中的 onboot 修改为 yes - -## 嵌套虚拟机化的支持 -- 继续使用 oe 来测试 -- 使用 Guest 自动登录的为 tmux 的方法 -- 自动备份机制 - - 真的需要使用逐个字节拷贝的方式吗?qemu 存在什么好的机制来辅助吗? - -### 测试嵌套虚拟化的性能问题 - -## jenkins 的 node 是本地的虚拟机,而且本地虚拟机被 cgroup 约束 - -## 虚拟机中搭建这个 -https://github.com/meienberger/runtipi - - -## 参考 goffinet 的 packer 脚本 -- https://github.com/goffinet/packer-kvm -- https://github.com/goffinet/virt-scripts - -```txt -qemu-system-x86 141151 141073 0 /home/martins3/core/qemu/build/qemu-system-x86_64 -vnc 127.0.0.1:26 -drive file=artifacts/qemu/centos9/packer-cen -tos9,if=virtio,cache=none,discard=unmap,format=qcow2 -drive file=/home/martins3/.cache/packer/7df0e601c1b6b1d629ebd8ddb382c34f976417d6.iso,media=cdrom - -netdev user,id=user.0,hostfwd=tcp::4053-:22 -cpu host -boot once=d -name packer-centos9 -machine type=pc,accel=kvm -device virtio-net,netdev=user.0 --m -``` - -尝试一下下面的集中方法: -- https://github.com/linuxkit/linuxkit -- https://fedoraproject.org/wiki/Changes/OstreeNativeContainerStable -- https://coreos.github.io/rpm-ostree/container/ diff --git a/kernel/guest-setup/ubuntu.sh b/kernel/guest-setup/ubuntu.sh deleted file mode 100644 index 8be2357d0..000000000 --- a/kernel/guest-setup/ubuntu.sh +++ /dev/null @@ -1,154 +0,0 @@ -#!/usr/bin/env bash - -# https://askubuntu.com/questions/1367139/apt-get-upgrade-auto-restart-services -export DEBIAN_FRONTEND=noninteractive - -set -E -e -u -o pipefail -set -x - -cd "$(dirname "$0")" - -function install() { - sudo apt install -y "$1" -} - -function neovim_compile_retry() { - if [[ $1 != 0 ]]; then - git clean -dfx - make CMAKE_BUILD_TYPE=Release -j$(($(getconf _NPROCESSORS_ONLN) - 4)) - fi -} - -function install_tig() { - pushd "$HOME" - if [[ ! -d tig ]]; then - git clone https://github.com/jonas/tig - fi - cd tig - git pull - git checkout tig-2.5.7 - make -j$(($(getconf _NPROCESSORS_ONLN) - 4)) - make install - popd - echo 'export PATH=$HOME/bin:/usr/local/bin:$PATH' >~/.zshrc -} - -function install_neovim_from_source() { - echo "install nevoim from source" - install ninja-build gettext libtool libtool-bin autoconf automake cmake g++ pkg-config unzip curl doxygen - pushd "$HOME" - if [[ ! -d neovim ]]; then - git clone https://github.com/neovim/neovim - fi - cd neovim - git pull - make CMAKE_BUILD_TYPE=Release -j$(($(getconf _NPROCESSORS_ONLN) - 4)) - sudo make install - popd -} - -function install_nodejs() { - sudo apt uninstall -y nodejs - curl -sL https://deb.nodesource.com/setup_18.x -o /tmp/setup_18.x - sudo /tmp/setup_18.x - install -y nodejs - # to install yarn package manager - # curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null - # echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list - # sudo apt-get update && sudo apt-get install yarn -} - -function setup_env() { - sudo apt update -y - sudo apt upgrade -y - install software-properties-common - install build-essential - install docker - install ripgrep - install fd-find - install git - install g++ gcc pip - install python3-pip - install zsh - install docker.io - install flex bison - install libssl-dev - install libglib2.0-dev - install libpixman-1-dev - install shellcheck - install shfmt - install default-jre # jenkins 需要 - - pip install pynvim -} - -function setup_zsh() { - if [[ $SHELL =~ "zsh" ]]; then - sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" - chsh -s "$(which zsh)" - fi -} - -function install_tig_from_source() { - pushd "$HOME" - if [[ ! -d neovim ]]; then - git clone https://github.com/jonas/tig - fi - cd tig - git pull - make CMAKE_BUILD_TYPE=Release -j$(($(getconf _NPROCESSORS_ONLN) - 4)) - sudo make install - popd - -} - -function setup_ok() { - sudo snap install jump - cargo install starship --locked - setup_zsh -} - -function setup_clang() { - install clang - install lld -} - -function setup_syncthing() { - echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list - curl -s https://syncthing.net/release-key.txt | sudo apt-key add - - sudo apt update - sudo apt install syncthing - sudo systemctl enable syncthing@"$USER".service - sudo systemctl start syncthing@"$USER".service - sudo systemctl status syncthing@"$USER".service - echo "edit $HOME/.config/syncthing/config.xml" - echo "1. change 127.0.0.1 to 0.0.0.0 so that access the web ui in LAN" - echo "2. disable relay and global discovery" -} - -function setup_cargo() { - curl https://sh.rustup.rs -sSf | sh - cargo install lsd - cargo install tree-sitter-cli - echo "source \"$HOME/.cargo/env\"" >~/.zshrc -} - -function service_http() { - echo "todo" -} - -function enable_docker() { - # https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo - sudo groupadd docker - sudo gpasswd -a "$USER" docker - echo "logout to make it work" -} - -# setup_env -# setup_zsh -# install_nodejs -# setup_ok -# install_neovim_from_source -# setup_syncthing -# install_tig_from_source -# enable_docker diff --git a/kernel/guest-setup/win.md b/kernel/guest-setup/win.md deleted file mode 100644 index 3c8d5aaef..000000000 --- a/kernel/guest-setup/win.md +++ /dev/null @@ -1,7 +0,0 @@ -windows 的写代码的环境需要解决一下。 - -- 输入法 -- wezterm - - wezterm 的字体时不时显示的不正常 -- flameshot 截图 -- wechat (以及企业版) diff --git a/kernel/module/Makefile b/kernel/module/Makefile deleted file mode 100644 index f95e42844..000000000 --- a/kernel/module/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# 参考 : https://stackoverflow.com/questions/22368264/compiling-out-of-tree-kernel-module-against-any-kernel-source-tree-on-the-filesy -# 但是是 M=${PWD} 而不是 SOURCES=${PWD} -# -# if KERNELRELEASE is defined, we've been invoked from the -# kernel build system and can use its language. -ifneq (${KERNELRELEASE},) -$(info call this in kernel environment) -obj-m += martins3.o - -martins3-m := hello.o seq.o seq2.o sys.o workqueue.o -# Otherwise we were called directly from the command line. -# Invoke the kernel build system. -else -KERNEL_SOURCE := /home/martins3/core/linux-build -PWD := $(shell pwd) -default: - ${MAKE} -C ${KERNEL_SOURCE} M=${PWD} modules - -clean: - ${MAKE} -C ${KERNEL_SOURCE} M=${PWD} clean -endif diff --git a/kernel/module/hacking.h b/kernel/module/hacking.h deleted file mode 100644 index 84e4542af..000000000 --- a/kernel/module/hacking.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef HACKING_H_PA2UMYTB -#define HACKING_H_PA2UMYTB -enum hacking { - PR_INFO, - WATCH_DOG, - KTHREAD, - // 测试 https://docs.kernel.org/RCU/Design/Requirements/Requirements.html - RCU, - MUTEX, - MEMORY_MODEL_1, // load load,x86 上找不到 - MEMORY_MODEL_2, // store load - SEQ_FILE_1, - SEQ_FILE_2, - SYS_FS, - WORKQUEUE, -}; - -int simple_seq_init(void); -void simple_seq_fini(void); - -int simple_seq_init2(void); -void simple_seq_fini2(void); - -int simple_seq_init3(void); -void simple_seq_fini3(void); - -int sysfs_init(void); -void sysfs_exit(void); - -int my_workqueue_init(void); -void my_workqueue_exit(void); - -#endif /* end of include guard: HACKING_H_PA2UMYTB */ diff --git a/kernel/module/hello.c b/kernel/module/hello.c deleted file mode 100644 index 02eb5b6cc..000000000 --- a/kernel/module/hello.c +++ /dev/null @@ -1,420 +0,0 @@ -#include "hacking.h" -#include -#include -#include -#include -#include - -// Define the module metadata. -#define MODULE_NAME "greeter" -MODULE_AUTHOR("Martins3"); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("A simple kernel module to greet a user"); -MODULE_VERSION("0.1"); - -// Define the name parameter. -static char *name = "martins3"; -module_param(name, charp, S_IRUGO); -MODULE_PARM_DESC(name, "The name to display in /var/log/kern.log"); - -#define MAX_THREAD_NUM 256 -static struct task_struct *threads[MAX_THREAD_NUM]; -static int thread_num; - -typedef int thread_function(void *); - -static void add_threads(struct task_struct *task) -{ - for (int i = 0; i < thread_num; ++i) { - if (threads[i] == task) { - BUG(); - } - } - if (thread_num >= MAX_THREAD_NUM) { - return; - } - threads[thread_num] = task; - thread_num++; -} - -static void stop_threads(void) -{ - int ret; - for (int i = 0; i < thread_num; ++i) { - /** - * 如果在 kthread 中 stop 自己,测试出来过这个问题: - * [ 31.770761] loop 305183 times, found 5 - * [ 31.770965] BUG: unable to handle page fault for address: - * ffffffffc000255c [ 31.771304] #PF: supervisor instruction fetch in - * kernel mode [ 31.771576] #PF: error_code(0x0010) - not-present page - * [ 31.771829] PGD 3043067 P4D 3043067 PUD 3045067 PMD 103ae9067 PTE 0 - * [ 31.772132] Oops: 0010 [#1] PREEMPT SMP NOPTI - * [ 31.772350] CPU: 7 PID: 1646 Comm: martins3 Tainted: G - * O 6.4.0-rc1-00138-gd4d58949a6ea-dirty #260 - */ - if (threads[i] == current) { - continue; - } - ret = kthread_stop(threads[i]); - if (ret == -EINTR) { - pr_info("thread %px never started", threads[i]); - } else { - pr_info("thread function return %d", ret); - } - } - thread_num = 0; -} - -static int sleep_kthread(void *idx) -{ - int t_id = *(int *)idx; - int i = 0; - while (!kthread_should_stop()) { - msleep(1000); - printk(KERN_INFO "thread %d \n", i++); - } - printk(KERN_INFO "thread %d stopped\n", t_id); - return 123; -} - -void initialize_thread(thread_function func, const char *name, int idx) -{ - struct task_struct *kth; - kth = kthread_create(func, &idx, "%s", name); - if (kth != NULL) { - wake_up_process(kth); - pr_info("thread %d is running\n", idx); - } else { - pr_info("kthread %s could not be created\n", name); - } - add_threads(kth); -} - -static void hacking_kthread(bool start) -{ - if (start) { - for (int i = 0; i < 2; ++i) { - initialize_thread(sleep_kthread, "martins3", i); - } - printk(KERN_INFO "all of the threads are running\n"); - } else { - stop_threads(); - } -} - -static unsigned int mm2_a, mm2_b; -static unsigned int mm2_x, mm2_y; -static struct semaphore sem_x; -static struct semaphore sem_y; -static struct semaphore sem_end; - -static int ordering_thread_fn2_cpu0(void *idx) -{ - static unsigned int detected; - static unsigned long loop; - while (!kthread_should_stop()) { - loop++; - - mm2_x = 0; - mm2_y = 0; - - up(&sem_x); - up(&sem_y); - - down(&sem_end); - down(&sem_end); - - if (mm2_a == 0 && mm2_b == 0) - pr_info("%d reorders detected\n", ++detected); - - if (detected >= 100) { - // 平均 10 次触发一次,不知道有没有更好的方法来触发 - pr_info("loop %ld times, found %d\n", loop, detected); - stop_threads(); - return 0; - } - } - return 0; -} - -static int ordering_thread_fn2_cpu1(void *idx) -{ - while (!kthread_should_stop()) { - down(&sem_x); - mm2_x = 1; -#ifdef CONFIG_USE_CPU_BARRIER - smp_wmb(); -#else - /* Prevent compiler reordering. */ - barrier(); -#endif - mm2_a = mm2_y; - up(&sem_end); - } - return 0; -} - -static int ordering_thread_fn2_cpu2(void *idx) -{ - while (!kthread_should_stop()) { - down(&sem_y); - mm2_y = 1; -#ifdef CONFIG_USE_CPU_BARRIER - smp_rmb(); -#else - /* Prevent compiler reordering. */ - barrier(); -#endif - mm2_b = mm2_x; - up(&sem_end); - } - return 0; -} - -static void hacking_memory_model_2(void) -{ - sema_init(&sem_x, 0); - sema_init(&sem_y, 0); - sema_init(&sem_end, 0); - initialize_thread(ordering_thread_fn2_cpu0, "martins3", 0); - initialize_thread(ordering_thread_fn2_cpu1, "martins3", 0); - initialize_thread(ordering_thread_fn2_cpu2, "martins3", 0); -} - -static atomic_t count = ATOMIC_INIT(0); -static unsigned int a, b; - -static int ordering_thread_fn_cpu0(void *idx) -{ - while (!kthread_should_stop()) { - atomic_inc(&count); - } - - pr_info("counter : %d\n", atomic_read(&count)); - return 0; -} - -static int ordering_thread_fn_cpu1(void *idx) -{ - pr_info("[martins3:%s:%d] \n", __FUNCTION__, __LINE__); - while (!kthread_should_stop()) { - int temp = atomic_read(&count); - - a = temp; -#ifdef CONFIG_USE_CPU_BARRIER - smp_wmb(); -#else - /* Prevent compiler reordering. */ - barrier(); -#endif - b = temp; - } - return 0; -} - -static int ordering_thread_fn_cpu2(void *idx) -{ - pr_info("[martins3:%s:%d] \n", __FUNCTION__, __LINE__); - while (!kthread_should_stop()) { - unsigned int c, d; - - d = b; -#ifdef CONFIG_USE_CPU_BARRIER - smp_rmb(); -#else - /* Prevent compiler reordering. */ - barrier(); -#endif - c = a; - - if ((int)(d - c) > 0) - pr_info("reorders detected, a = %d, b = %d\n", c, d); - } - return 0; -} - -static void hacking_memory_model_1(void) -{ - initialize_thread(ordering_thread_fn_cpu0, "martins3", 0); - initialize_thread(ordering_thread_fn_cpu1, "martins3", 0); - initialize_thread(ordering_thread_fn_cpu2, "martins3", 0); -} - -int rcu_x, rcu_y; -int rcu_thread0(void *idx) -{ - int r1, r2; - int t_id = *(int *)idx; - while (!kthread_should_stop()) { - rcu_read_lock(); - r1 = READ_ONCE(rcu_x); - r2 = READ_ONCE(rcu_y); - rcu_read_unlock(); - BUG_ON(r1 == 0 && r2 == 1); - } - printk(KERN_INFO "thread %d stopped\n", t_id); - return 0; -} - -int rcu_thread1(void *idx) -{ - int t_id = *(int *)idx; - - while (!kthread_should_stop()) { - WRITE_ONCE(rcu_x, 1); - synchronize_rcu(); // TODO 将这一行注释掉,并没有什么触发 BUG_ON 直到 - // softlock up - WRITE_ONCE(rcu_y, 1); - } - - printk(KERN_INFO "thread %d stopped\n", t_id); - return 0; -} - -unsigned long counter; -static DEFINE_MUTEX(test_mutex); -#define LOOP_NUM 10000000 -int mutex_thread0(void *idx) -{ - for (unsigned long i = 0; i < LOOP_NUM; ++i) { - mutex_lock(&test_mutex); - counter++; - mutex_unlock(&test_mutex); - } - pr_info("counter is %lx\n", counter); - // XXX 如果提前溜走了,那么 kthread_stop 会出问题 - while (!kthread_should_stop()) - msleep(1000); // TODO 有什么一直 sleep 下去的 API 吗? - return 2; -} - -int mutex_thread1(void *idx) -{ - for (unsigned long i = 0; i < LOOP_NUM; ++i) { - mutex_lock(&test_mutex); - counter--; - mutex_unlock(&test_mutex); - } - - pr_info("counter is %lx\n", counter); - while (!kthread_should_stop()) - msleep(1000); - return 1; -} - -static void hacking_mutex(void) -{ - initialize_thread(mutex_thread0, "martins3", 0); - initialize_thread(mutex_thread1, "martins3", 1); -} - -static void hacking_rcu(void) -{ - initialize_thread(rcu_thread0, "martins3", 0); - initialize_thread(rcu_thread1, "martins3", 1); -} - -static void hacking_pr_info(void) -{ - // %p 真的烦人,hash 的完全看不懂了 - pr_info("%p", current->mm->pgd); - pr_info("%px", current->mm->pgd); - pr_info("%s: module loaded at 0x%p\n", MODULE_NAME, hacking_pr_info); -} - -static void hacking_watchdog(void) -{ - bool hard = false; - if (hard) - local_irq_disable(); - - for (;;) { - // TODO - // 1. 如果中断屏蔽了,这个就没用了 - // 2. 此外,此时的 insmod martins3.ko 是无法被 Ctrl C 掉的 - cond_resched(); - } - - if (hard) - local_irq_enable(); -} - -// TODO 做成参数 -enum hacking h = WORKQUEUE; - -static int __init greeter_init(void) -{ - int error = 0; - switch (h) { - case PR_INFO: - hacking_pr_info(); - break; - case WATCH_DOG: - hacking_watchdog(); - break; - case KTHREAD: - hacking_kthread(true); - break; - case RCU: - hacking_rcu(); - break; - case MUTEX: - hacking_mutex(); - break; - case MEMORY_MODEL_1: - hacking_memory_model_1(); - break; - case MEMORY_MODEL_2: - hacking_memory_model_2(); - break; - case SEQ_FILE_1: - simple_seq_init(); - break; - case SEQ_FILE_2: - simple_seq_init2(); - break; - case SYS_FS: - error = sysfs_init(); - break; - case WORKQUEUE: - error = my_workqueue_init(); - break; - } - - if (error) - return error; - - pr_info("%s: module loaded\n", MODULE_NAME); - return 0; -} - -static void __exit greeter_exit(void) -{ - switch (h) { - case RCU: - case KTHREAD: - case MUTEX: - case MEMORY_MODEL_1: - hacking_kthread(false); - break; - case SEQ_FILE_1: - simple_seq_fini(); - break; - case SEQ_FILE_2: - simple_seq_fini2(); - break; - case SYS_FS: - sysfs_exit(); - break; - case WORKQUEUE: - my_workqueue_exit(); - break; - default: - break; - } - - pr_info("%s: module unloaded\n", MODULE_NAME); -} - -module_init(greeter_init); -module_exit(greeter_exit); diff --git a/kernel/module/proc.c b/kernel/module/proc.c deleted file mode 100644 index dd1f38728..000000000 --- a/kernel/module/proc.c +++ /dev/null @@ -1,91 +0,0 @@ -#include -#include -#include -#include -#include -#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) -#include -#endif - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) -#define HAVE_PROC_OPS -#endif - -#define PROCFS_MAX_SIZE 2048UL -#define PROCFS_ENTRY_FILENAME "buffer2k" - -static struct proc_dir_entry *our_proc_file; -static char procfs_buffer[PROCFS_MAX_SIZE]; -static unsigned long procfs_buffer_size = 0; - -static ssize_t procfs_read(struct file *filp, char __user *buffer, - size_t length, loff_t *offset) -{ - if (*offset || procfs_buffer_size == 0) { - pr_debug("procfs_read: END\n"); - *offset = 0; - return 0; - } - procfs_buffer_size = min(procfs_buffer_size, length); - if (copy_to_user(buffer, procfs_buffer, procfs_buffer_size)) - return -EFAULT; - *offset += procfs_buffer_size; - - pr_debug("procfs_read: read %lu bytes\n", procfs_buffer_size); - return procfs_buffer_size; -} - -static ssize_t procfs_write(struct file *file, const char __user *buffer, - size_t len, loff_t *off) -{ - procfs_buffer_size = min(PROCFS_MAX_SIZE, len); - if (copy_from_user(procfs_buffer, buffer, procfs_buffer_size)) - return -EFAULT; - *off += procfs_buffer_size; - - pr_debug("procfs_write: write %lu bytes\n", procfs_buffer_size); - return procfs_buffer_size; -} - -static int procfs_open(struct inode *inode, struct file *file) -{ - try_module_get(THIS_MODULE); - return 0; -} - -static int procfs_close(struct inode *inode, struct file *file) -{ - module_put(THIS_MODULE); - return 0; -} - -static struct proc_ops file_ops_4_our_proc_file = { - .proc_read = procfs_read, - .proc_write = procfs_write, - .proc_open = procfs_open, - .proc_release = procfs_close, -}; - -int procfs3_init(void) -{ - our_proc_file = proc_create(PROCFS_ENTRY_FILENAME, 0644, NULL, - &file_ops_4_our_proc_file); - if (our_proc_file == NULL) { - remove_proc_entry(PROCFS_ENTRY_FILENAME, NULL); - pr_debug("Error: Could not initialize /proc/%s\n", - PROCFS_ENTRY_FILENAME); - return -ENOMEM; - } - proc_set_size(our_proc_file, 80); - proc_set_user(our_proc_file, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID); - - pr_debug("/proc/%s created\n", PROCFS_ENTRY_FILENAME); - return 0; -} - -void procfs3_exit(void) -{ - remove_proc_entry(PROCFS_ENTRY_FILENAME, NULL); - pr_debug("/proc/%s removed\n", PROCFS_ENTRY_FILENAME); -} diff --git a/kernel/module/readme.md b/kernel/module/readme.md deleted file mode 100644 index 4a95d2da5..000000000 --- a/kernel/module/readme.md +++ /dev/null @@ -1,80 +0,0 @@ -# 测试内容 - -- [ ] rcu -- [ ] all kinds of locking -- [ ] https://github.com/smcdef/memory-reordering/blob/master/ordering.c -- [ ] include/linux/semaphore.h - - https://lwn.net/Articles/928026/ -- [ ] 测试 interruptable 和 uninterrpable 的 -- [ ] 测试等待 io 也是计入到 load 中的 - -## seq file -参考: -1. https://stackoverflow.com/questions/25399112/how-to-use-a-seq-file-in-linux-kernel-modules -2. https://github.com/sysprog21/lkmpg - -## cpu_relax vs cond_resched - - -## 持有 mutex 睡眠 - - -## 这个补充一下 -```c -trace_printk("martins3 like %s\n", "ftrace"); -``` - -```c -pr_info("[martins3:%s:%d] rtm always abort %d\n", __FUNCTION__, __LINE__, cpu_khz); -``` - -## 触发一下类似这种报错 -```txt -[19892.185338] "echo 0 > /proc/sys/kernel/hung__task__timeout__secs" disables this message. -[19892.185363] ps              D    0 83180  84135 0x00000080 -[19892.185366] Call Trace: -[19892.185375]  ? __schedule+0x24f/0x650 -[19892.185377]  schedule+0x2f/0xa0 -[19892.185379]  rwsem__down__read__slowpath+0x3e5/0x520 -[19892.185382]  __access__remote__vm+0x5a/0x2d0 -[19892.185386]  proc__pid__cmdline__read+0x1a6/0x350 -[19892.185389]  vfs__read+0x91/0x140 -[19892.185391]  ksys__read+0x4f/0xb0 -[19892.185394]  do__syscall__64+0x5b/0x1a0 -[19892.185397]  entry__SYSCALL__64__after__hwframe+0x65/0xca -[19892.185399] RIP: 0033:0x7f0a8dc9b7e0 -[19892.185405] Code: Bad RIP value. -[19892.185406] RSP: 002b:00007ffc3c1a1a38 EFLAGS: 00000246 ORIG__RAX: 0000000000000000 -[19892.185408] RAX: ffffffffffffffda RBX: 00007f0a8e53d010 RCX: 00007f0a8dc9b7e0 -[19892.185409] RDX: 0000000000020000 RSI: 00007f0a8e53d010 RDI: 0000000000000006 -[19892.185409] RBP: 0000000000020000 R08: 00007f0a8dbfa988 R09: 0000000000000013 -[19892.185410] R10: 0000000000000007 R11: 0000000000000246 R12: 0000000000000000 -[19892.185411] R13: 00007f0a8e53d010 R14: 0000000000000000 R15: 0000000000000006 -``` - -## 触发一下 rcu cpu stall 的 bug - - -## 对于一般的内核模块替换 -make path/to/name.ko -j32 - - -## wait_event -- blk_queue_enter 中,wait_event 前面居然有一个 smp_read -配合这个使用: -- wake_up_all - -## percpu_ref_kill - - -## 将 rcu 用起来再说 -https://lwn.net/Articles/777036/ - -- synchronize_rcu() : 等待 rcu grace 时间结束 -- synchronize_rcu_expedited() : 强制结束 rcu grace 时间,感觉一般都是在 subsystem 关闭的时候 -- call_rcu - -## workqueue - -## 还是用 sysfs 来整理这些代码吧 -除了 procfs 外吧 diff --git a/kernel/module/seq.c b/kernel/module/seq.c deleted file mode 100644 index bcb6ec5e8..000000000 --- a/kernel/module/seq.c +++ /dev/null @@ -1,45 +0,0 @@ -#include /* copy_from_user, copy_to_user */ -#include -#include /* EFAULT */ -#include -#include -#include /* pr_info */ -#include /* seq_read, seq_lseek, single_release */ -#include /* S_IRUSR */ - -static struct dentry *debugfs_file; - -static int show(struct seq_file *m, void *v) -{ - seq_printf(m, "ab\ncd\n"); - return 0; -} - -static int open(struct inode *inode, struct file *file) -{ - return single_open(file, show, NULL); -} - -static const struct file_operations fops = { - .llseek = seq_lseek, - .open = open, - .owner = THIS_MODULE, - .read = seq_read, - .release = single_release, -}; - -int simple_seq_init(void) -{ - debugfs_file = - debugfs_create_file("martins3-seq", S_IRUSR, NULL, NULL, &fops); - if (debugfs_file) { - return 0; - } else { - return -EINVAL; - } -} - -void simple_seq_fini(void) -{ - debugfs_remove(debugfs_file); -} diff --git a/kernel/module/seq2.c b/kernel/module/seq2.c deleted file mode 100644 index 27f8b87c1..000000000 --- a/kernel/module/seq2.c +++ /dev/null @@ -1,126 +0,0 @@ -#include /* copy_from_user, copy_to_user */ -#include -#include /* EFAULT */ -#include -#include -#include /* pr_info */ -#include /* seq_read, seq_lseek, single_release */ -#include -#include /* S_IRUSR */ - -static struct dentry *debugfs_file; - -struct student { - char name[100]; - int id; -}; - -struct student classmates[] = { { .id = 1, .name = "Alice" }, - { .id = 2, .name = "Bob" }, - { .id = 3, .name = "Kelvin" } }; - -/* Called at the beginning of every read. - * - * The return value is passsed to the first show. - * It normally represents the current position of the iterator. - * It could be any struct, but we use just a single integer here. - * - * NULL return means stop should be called next, and so the read will be empty.. - * This happens for example for an ftell that goes beyond the file size. - */ -static void *start(struct seq_file *s, loff_t *pos) -{ - pr_info("start"); - /* beginning a new sequence? */ - if (*pos == 0) { - /* yes => return a non null value to begin the sequence */ - return classmates; - } - - /** - * 整个执行流程,最后会执行下: - * - * [ 94.251027] open - * [ 94.251160] start - * [ 94.251161] show - * [ 94.251253] next - * [ 94.251338] show - * [ 94.251421] next - * [ 94.251507] show - * [ 94.251594] next - * [ 94.251680] stop - * [ 94.251856] start - * [ 94.251857] [martins3:start:40] - * [ 94.252140] stop - */ - pr_info("[martins3:%s:%d] \n", __FUNCTION__, __LINE__); - /* no => it is the end of the sequence, return end to stop reading */ - *pos = 0; - return NULL; -} - -/* The return value is passed to next show. - * If NULL, stop is called next instead of show, and read ends. - * - * Can get called multiple times, until enough data is returned for the read. - */ -static void *next(struct seq_file *s, void *v, loff_t *pos) -{ - struct student *spos = (struct student *)v + 1; - *pos += sizeof(struct student); - pr_info("next"); - if (*pos >= sizeof(classmates)) - return NULL; - return spos; -} - -/* Called at the end of every read. */ -static void stop(struct seq_file *s, void *v) -{ - pr_info("stop\n"); -} - -/* Return 0 means success, SEQ_SKIP ignores previous prints, negative for error. - */ -static int show(struct seq_file *s, void *v) -{ - struct student *spos = v; - pr_info("show"); - seq_printf(s, "%s %d\n", spos->name, spos->id); - return 0; -} - -static struct seq_operations my_seq_ops = { - .next = next, - .show = show, - .start = start, - .stop = stop, -}; - -static int open(struct inode *inode, struct file *file) -{ - pr_info("open\n"); - return seq_open(file, &my_seq_ops); -} - -static struct file_operations fops = { .owner = THIS_MODULE, - .llseek = seq_lseek, - .open = open, - .read = seq_read, - .release = seq_release }; - -int simple_seq_init2(void) -{ - debugfs_file = debugfs_create_file("lkmc_seq_file", S_IRUSR, NULL, NULL, - &fops); - if (debugfs_file) { - return 0; - } else { - return -EINVAL; - } -} - -void simple_seq_fini2(void) -{ - debugfs_remove(debugfs_file); -} diff --git a/kernel/module/sys.c b/kernel/module/sys.c deleted file mode 100644 index 480ee665e..000000000 --- a/kernel/module/sys.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * hello-sysfs.c sysfs example - */ -#include -#include -#include -#include -#include -#include - -static struct kobject *mymodule; - -/* the variable you want to be able to change */ -static int myvariable = 0; - -static ssize_t myvariable_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - return sprintf(buf, "%d\n", myvariable); -} - -static ssize_t myvariable_store(struct kobject *kobj, - struct kobj_attribute *attr, char *buf, - size_t count) -{ - sscanf(buf, "%du", &myvariable); - return count; -} - -static struct kobj_attribute myvariable_attribute = - __ATTR(myvariable, 0660, myvariable_show, (void *)myvariable_store); - -int sysfs_init(void) -{ - int error = 0; - - pr_info("mymodule: initialised\n"); - - // 创建 /sys/kernel/mymodule - mymodule = kobject_create_and_add("mymodule", kernel_kobj); - if (!mymodule) - return -ENOMEM; - - error = sysfs_create_file(mymodule, &myvariable_attribute.attr); - if (error) { - pr_info("failed to create the myvariable file " - "in /sys/kernel/mymodule\n"); - } - - return error; -} - -void sysfs_exit(void) -{ - pr_info("mymodule: Exit success\n"); - kobject_put(mymodule); -} diff --git a/kernel/module/workqueue.c b/kernel/module/workqueue.c deleted file mode 100644 index 7fb403518..000000000 --- a/kernel/module/workqueue.c +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include - -/* #define CREAT_WORKQUEUE */ - -static unsigned long onesec = HZ; -static void mykmod_work_handler(struct work_struct *w); -static DECLARE_DELAYED_WORK(mykmod_work, mykmod_work_handler); - -#ifdef CREAT_WORKQUEUE -static struct workqueue_struct *wq = 0; -static void mykmod_work_handler(struct work_struct *w) -{ - pr_info("mykmod work %u jiffies\n", (unsigned)onesec); - queue_delayed_work(wq, &mykmod_work, onesec); -} - -int my_workqueue_init(void) -{ - if (!wq) - wq = create_singlethread_workqueue("my_workqueue"); - if (wq) - queue_delayed_work(wq, &mykmod_work, onesec); - - return 0; -} - -void my_workqueue_exit(void) -{ - cancel_delayed_work_sync(&mykmod_work); - if (wq) - destroy_workqueue(wq); -} - -#else - -static void mykmod_work_handler(struct work_struct *w) -{ - pr_info("mykmod work %u jiffies\n", (unsigned)onesec); - schedule_delayed_work(&mykmod_work, onesec); -} - -int my_workqueue_init(void) -{ - schedule_delayed_work(&mykmod_work, onesec); - return 0; -} - -void my_workqueue_exit(void) -{ - cancel_delayed_work_sync(&mykmod_work); -} -#endif diff --git a/kernel/nixos/Makefile b/kernel/nixos/Makefile deleted file mode 100644 index 17ba7182c..000000000 --- a/kernel/nixos/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-m += hello.o diff --git a/kernel/nixos/hello.c b/kernel/nixos/hello.c deleted file mode 100644 index 5f26dcb49..000000000 --- a/kernel/nixos/hello.c +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include - -static void tsx_disable(void) -{ - u64 tsx; - - rdmsrl(MSR_IA32_TSX_CTRL, tsx); - - /* Force all transactions to immediately abort */ - tsx |= TSX_CTRL_RTM_DISABLE; - - /* - * Ensure TSX support is not enumerated in CPUID. - * This is visible to userspace and will ensure they - * do not waste resources trying TSX transactions that - * will always abort. - */ - tsx |= TSX_CTRL_CPUID_CLEAR; - - wrmsrl(MSR_IA32_TSX_CTRL, tsx); -} - -static int vermagic_init(void) { - pr_info("[martins3:%s:%d] disbale tsx\n", __FUNCTION__, __LINE__); - tsx_disable(); - pr_info("[martins3:%s:%d] \n", __FUNCTION__, __LINE__); - return 0; -} - -void aperfmperf_get_khz(int cpu) { - // @todo 测试一下这个代码 - /* smp_call_function_single(cpu, aperfmperf_snapshot_khz, NULL, wait); */ -} - -static void vermagic_exit(void) {} - -module_init(vermagic_init) -module_exit(vermagic_exit) -MODULE_LICENSE("GPL"); diff --git a/kernel/nixos/kvm.sh b/kernel/nixos/kvm.sh deleted file mode 100755 index abb8b7393..000000000 --- a/kernel/nixos/kvm.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env bash - -set -E -e -u -o pipefail - -project_dir=~/core/nixos-kernel -mkdir -p $project_dir -cd $project_dir - -version=$(uname -r) -if [[ $version =~ [0-9]\.[0-9]\.0 ]]; then - version=${version:0:3} -fi -tarfile=linux-${version}.tar.xz - -if [[ ! -f $tarfile ]]; then - wget https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/"$tarfile" -fi - -srcdir=linux-${version} -if [[ ! -d $srcdir ]]; then - tar -xvf "$tarfile" -fi - -cd "$srcdir" -[[ ! -f .config ]] && zcat /proc/config.gz >.config - -if [[ ! -d .git ]]; then - git init - git add -A - git commit -m "init" -fi - -function exe() { - command="$1" - echo "$command" - nix-shell '' -A linuxPackages_latest.kernel --command "$command" -} - -# @todo -# 不知道为什么,有报错! -# 难道是因为 nixos 存在什么 patch 吗? -# exe "make ./arch/x86/kernel/kvm-intel.ko" -# @todo -# 如何使用 direnv ? -cat <<_EOF_ >/dev/null - DESCEND objtool - DESCEND bpf/resolve_btfids - CALL scripts/checksyscalls.sh -make[3]: *** No rule to make target 'arch/x86/kernel/kvm-intel.o'. Stop. -make[2]: *** [scripts/Makefile.build:504: arch/x86/kernel] Error 2 -make[1]: *** [scripts/Makefile.build:504: arch/x86] Error 2 -make: *** [Makefile:2021: .] Error 2 -_EOF_ - -cat <<_EOF_ >/dev/null -[ 1503.956995] kvm: version magic '6.2.12-g6825a3677969-dirty SMP preempt mod_unload ' should be '6.2.12 SMP preempt mod_unload ' -[ 1503.962909] kvm_intel: version magic '6.2.12-g6825a3677969-dirty SMP preempt mod_unload ' should be '6.2.12 SMP preempt mod_unload ' -[ 1580.326624] kvm: version magic '6.2.12-g6825a3677969-dirty SMP preempt mod_unload ' should be '6.2.12 SMP preempt mod_unload ' -[ 1580.333232] kvm_intel: version magic '6.2.12-g6825a3677969-dirty SMP preempt mod_unload ' should be '6.2.12 SMP preempt mod_unload ' -_EOF_ - -# scripts/setlocalversion => -# include/config/kernel.release => -# linux-6.2.12/include/generated/utsrelease.h -# -# 所以将 scripts/setlocalversion 最后一行删除掉 -# 但是还是存在这个错误,都不知道插入了没有,而且现在也是修改一行,整个代码重新编译 -# 再仔细想想吧! -# -# 去掉 git 是不是就可以解决 XXX,也不是不能接受 -# 实际上,这个报错是无所谓的 -cat <<_EOF_ >/dev/null -[10606.080260] BPF: type_id=52229 bits_offset=896 -[10606.080263] BPF: -[10606.080264] BPF: Invalid name -[10606.080264] BPF: -[10606.080266] failed to validate module [kvm] BTF: -22 -[10606.089001] BPF: type_id=52229 bits_offset=896 -[10606.089004] BPF: -[10606.089005] BPF: Invalid name -[10606.089005] BPF: -[10606.089006] failed to validate module [kvm_intel] BTF: -22 -_EOF_ - -# 建议还是先编译一下 -# 不过不首先编译,会出现如下的报错 -# Makefile:736: include/config/auto.conf: No such file or directory -# exe "make -j32" -# scripts/setlocalversion 似乎还是需要删除的 -# @todo 极度怀疑这个命令的的正确性,尝试下 AMD kvm 的编译 -# -# ubuntu 中这样构建是没问题的 -# make ./drivers/md/raid1.ko -j32 -# -# -# 如果不首先 make 一下, 那么直接执行存在这个错误 -# Makefile:736: include/config/auto.conf: No such file or directory -ln -sf /home/martins3/.dotfiles/scripts/nix/env/linux.nix default.nix -echo "use nix" >> .envrc && direnv allow - -gum confirm "Continue to build kvm?" || exit 0 - -exe "make -j32" -exe "make M=./arch/x86/kvm/ modules -j32" -sudo rmmod kvm_amd kvm -sudo insmod ./arch/x86/kvm/kvm.ko -sudo insmod ./arch/x86/kvm/kvm-intel.ko -sudo insmod ./arch/x86/kvm/kvm-amd.ko - -gum confirm "Continue to build rpm?" || exit 0 -# TODO 这样编译出来的 rpm 为什么这么大啊 -exe "make binrpm-pkg -j32" - - -# TODO 靠,还是有点问题,难道需要一开始就设置 id 吗? -# TODO 还是其实,从来都没有成功过 -# -# 似乎这个才是正道? 自动将两个都编译好了 -# make arch/x86/kvm/kvm.ko -j32 - -# sudo modprobe kvm-intel -# kvm.ko 和 kvm-intel.ko 是配套的 -# - - -# 看看: Documentation/kbuild/reproducible-builds.rst -# 如果利用 stable 的 kernel 的 tree -# https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux.git diff --git a/kernel/nixos/readme.md b/kernel/nixos/readme.md deleted file mode 100644 index 6510f93e4..000000000 --- a/kernel/nixos/readme.md +++ /dev/null @@ -1,13 +0,0 @@ -# 如何方便的再 nixos 上构建 kvm 模块 - - -## 问题 1 : 这样执行完成之后,存在如下的警告 -```txt -exe "make -j32" -exe "make M=./arch/x86/kvm/ modules -j32" -``` - -```txt -[ 1446.603548] kvm: version magic '6.4.9-g5962edea824b SMP preempt mod_unload ' should - be '6.4.9 SMP preempt mod_unload ' -``` diff --git a/kernel/nixos/run.sh b/kernel/nixos/run.sh deleted file mode 100755 index 103e665e3..000000000 --- a/kernel/nixos/run.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -E -e -u -o pipefail -cd "$(dirname "$0")" - -nix-shell '' -A linuxPackages_latest.kernel.dev --command " make -C $(nix-build -E '(import {}).linuxPackages_latest.kernel.dev' --no-out-link)/lib/modules/*/build M=""$(pwd)"" modules" diff --git a/nixpkgs/home.nix b/nixpkgs/home.nix index ed563ff34..27c7092fe 100644 --- a/nixpkgs/home.nix +++ b/nixpkgs/home.nix @@ -1,12 +1,28 @@ { config, pkgs, stdenv, lib, ... }: +let + +# 用这种方法来使用最新的 neovim ,但是不一定编译成功 +# neovim = builtins.getFlake "github:neovim/neovim?dir=contrib"; + +in { imports = [ ./home/cli.nix - ] ++ (if (builtins.getEnv "DISPLAY") != "" - then [ - ./home/gui.nix - ] else [ ]); + ] ++ ( + if builtins.currentSystem == "x86_64-linux" then [ + ./home/gui.nix + ] else [ ] + ); + + + # 为了保证任何时候都安装 im-select ,否则无法 + i18n.inputMethod = { + enabled = "fcitx5"; + fcitx5.addons = with pkgs; [ + fcitx5-rime + ]; + }; # allow unfree software nixpkgs.config.allowUnfree = true; @@ -23,5 +39,7 @@ }; }; + # nixpkgs.overlays = [ neovim.overlay ]; + programs.home-manager.enable = true; } diff --git a/nixpkgs/home/app/gnome.nix b/nixpkgs/home/app/gnome.nix index fc1bdfdd8..7b33a1f6d 100644 --- a/nixpkgs/home/app/gnome.nix +++ b/nixpkgs/home/app/gnome.nix @@ -9,7 +9,6 @@ ++ (with pkgs.gnomeExtensions; [ unite clipboard-indicator - tweaks-in-system-menu bing-wallpaper-changer gtile hide-top-bar diff --git a/nixpkgs/home/cli.nix b/nixpkgs/home/cli.nix index 3973c3ab6..be25df891 100644 --- a/nixpkgs/home/cli.nix +++ b/nixpkgs/home/cli.nix @@ -2,50 +2,56 @@ let unstable = import { }; - x86-manpages = import (fetchTarball "https://github.com/blitz/x86-manpages-nix/archive/master.tar.gz"); in { fonts.fontconfig.enable = true; - home.stateVersion = "23.05"; + home.stateVersion = "23.11"; home.username = "martins3"; home.homeDirectory = "/home/martins3"; home.packages = with pkgs; [ gcc - gnuplot + libgcc # gcov + # gnuplot ccache - mold + # mold go + # gitea # 好吧,还需要手动搭建数据库才可以 + sipcalc ventoy - # uutils-coreutils @todo 到时候尝试下 rust 的 coreutils + novnc + # uutils-coreutils # @todo 到时候尝试下 rust 的 coreutils lua + quickemu lua-language-server stylua # TODO virt-customize -a bionic-server-cloudimg-amd64.img --root-password password: # libguestfs # libguestfs-appliance - cloud-utils + # cloud-utils imagemagick # 压缩照片 adoptopenjdk-icedtea-web ccls + checkmake + typos # 检查代码中 typo + # include-what-you-use # 很小的项目都用着不正常 cargo - unstable.rustc - rustfmt cmake - ov # feature rich pager + # ov # feature rich pager # zig dracut iw termshark - openvswitch + openvswitch-lts + dnsmasq gnumake audit # 没啥意义,用不起来 yarn nodejs tmux tmuxp - pueue # TODO 研究下这个怎么利用 + pueue screen clash-meta tig @@ -65,12 +71,13 @@ in starship gdb lsof - lshw + lshw # 侧重于展示 bus 的结构 + hwloc # 侧重于展示 cache hw-probe # sudo -E hw-probe -all -upload - exa # more powerful ls + eza # more powerful ls oh-my-posh # @todo for powershell gource - unstable.fastfetch + fastfetch bear tree fd @@ -81,15 +88,16 @@ in du-dust # 比 ncdu 更快 socat # unix domain delta # git diff + act # Run github action locally git-secrets nethogs sniffnet nmap # dhcpcd # 这个东西和 nixos 不兼容 iftop - neomutt + # neomutt # 邮件列表,很难用 b4 - weechat + # weechat offlineimap tcpdump ethtool @@ -97,7 +105,6 @@ in sshpass gping # better ping pingu # interesting ping - auto-cpufreq # frp # 反向代理 nbd kmon # 方便的管理内核模块 @@ -106,60 +113,76 @@ in kexec-tools rpm stress-ng - OVMFFull # 存储在 /run/libvirt/nix-ovmf/ 下 + # OVMFFull # 存储在 /run/libvirt/nix-ovmf/ 下 # 通过 tweaks 调整开机自启动 gnome3.gnome-tweaks # @todo 确定是这里设置的,还是只是一个 extension hexyl # 分析二进制 - rasdaemon # @todo 莫名其妙,不知道怎么使用 + # rasdaemon # @todo 莫名其妙,不知道怎么使用 nvme-cli ninja libvirt # 提供 virsh qemu + # unstable.nixos-shell + # krunvm # 有待尝试 + nixpacks + nix-tree # 动态的展示每一个包的依赖 + buildah virtiofsd # 之前 https://gitlab.com/virtio-fs/virtiofsd ,似乎之前是在 qemu 中的 - podman - nix-index + # podman + # podman-tui + # k9s + # minikube + # minio + # dufs # 一个全新的 ftp server + # hoard # 暂时不知道怎么使用 + # slirp4netns + # nix-index + # nixd # virt-manager @todo 这到底是个啥,需要使用上吗? meson - unstable.neovim + neovim # helix # modern neovim - cheat + # cheat # wakatime shellcheck shfmt tree-sitter - systeroid - linuxKernel.packages.linux_5_15.perf - # linuxPackages_6_5.perf - # 当 perf linuxPackages_6_5.perf 的时候,使用如下命令 - # sudo perf record --call-graph dwarf -p 200454 -- sleep 10 - # 必然导致 guest crash - # - # linuxPackages_latest.perf + # systeroid + # linuxKernel.packages.linux_5_15.perf + linuxPackages_6_7.perf + # linuxPackages_6_5.sysdig # 没法用,还需要内核模块 + + # cflow # 感觉很弱,没用懂 iperf # linuxPackages_latest.systemtap # 似乎这个让 libvirt 的编译开始依赖 systemdtab 的头文件了 # 其实也不能用 # ERROR: kernel release isn't found in "/nix/store/n3nrix9pc0m1ywzg8dq71bh2xr82c7l5-linux-6.3.5-dev" # 还是在虚拟机勉强维持生活吧 - unstable.bpftrace # bpftrace 新版本才支持 kfunc - blktrace - heaptrack - kernelshark - trace-cmd - # ltrace # library trace - unstable.bcc - # @todo 不知道为什么居然又两个程序 - # 应该对应的这个: https://github.com/libbpf/bpftool/tree/master/src + bpftrace + # blktrace + # kernelshark + # trace-cmd + # hotspot + # heaptrack + ltrace # library trace + bcc bpftool - bpftools + procps + xdp-tools acpi + ] ++ pkgs.lib.optionals (builtins.currentSystem=="x86_64-linux") [ + auto-cpufreq cpuid + # linuxKernel.packages.linux_latest_libre.turbostat + pcm + powertop # 分析功耗 + ] ++ [ # @todo https://github.com/kkharji/sqlite.lua/issues/28 # 需要设置 libsqlite3.so 的位置 sqlite parted sysbench - linuxKernel.packages.linux_latest_libre.turbostat - wirelesstools + # wirelesstools dos2unix # @todo 传统调试工具专门整理为一个包 sysstat # sar, iostat and pidstat mpstat @@ -169,19 +192,8 @@ in (python3.withPackages (p: with p; [ ipython autopep8 + gcovr pygments # 让 gdb-dashboard 支持高亮 - - # pandas - # pygal - # filelock - # libvirt - # mock - # filelock - # grpcio - # pytest - # monotonic - # libxml2 - # ansible ])) # ruff # 类似 pyright,据说很快,但是项目太小,看不出什么优势 # perl @@ -192,13 +204,11 @@ in atop nmon man-pages-posix - # x86-manpages # @todo 为什么 rnix-lsp 可以,但是 x86-manpages 不可以 lazydocker distrobox # 基于容器来提供各种 distribution arp-scan - pcm nixos-generators - unstable.gum + gum # acpi acpica-tools asciidoc @@ -209,14 +219,12 @@ in fio genact # A nonsense activity generator wtf # The personal information dashboard for your terminal - unstable.nixos-shell progress # 展示 cp dd 之类的进度条 psmisc # 包含 pstree fuser 等工具 viddy # A modern watch command. # mcfly # better ctrl-r for shell - unstable.atuin + atuin pciutils - powertop # 分析功耗 lm_sensors # 获取 CPU 温度 libxfs # @todo 使用 sudo mkfs.xfs -f /dev/sda1 还是需要 nix-shell -p libxfs bcachefs-tools @@ -225,17 +233,19 @@ in bat # better cat procs # better ps tokei # 代码统计工具,比 cloc 性能好 - unstable.zellij # tmux 替代品 + zellij # tmux 替代品 # kvmtool packer # 制作 qcow2 镜像 - (import (fetchTarball "https://github.com/cachix/devenv/archive/v0.5.tar.gz")) # @todo 和 default.nix 有区别? + just # 更加 nb 的执行命令 + # (import (fetchTarball https://install.devenv.sh/latest)).default # 浪费人生宝贵的 2h ,不明觉厉 + # @todo 不知道为什么,这种方法不行 + # (import (fetchTarball https://github.com/blitz/x86-manpages-nix/archive/master.tar.gz)) bridge-utils swtpm # windows 11 启动需要 # unstable.nushell libnotify # 通知小工具 - # 才知道在 Linux 下也是可以用的 pwsh - # 在 nixos 23.04 这个版本中,暂时因为 ssl 的版本,不能使用 # powershell + vector dmidecode # sudo dmidecode -t 1 git-review @@ -249,6 +259,7 @@ in # https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-dockerTools asciiquarium bc # bash 数值计算 + bash_unit # verilator # Fast and robust (System)Verilog simulator/compiler @@ -256,9 +267,11 @@ in figlet # 艺术字 lolcat # 彩虹 cat nyancat # 彩虹猫咪 + dig # dns分析 iptraf-ng # 网络流量分析 nvitop + ifmetric glances # 又一个 htop zenith-nvidia # TODO @@ -267,20 +280,20 @@ in lcov - czkawka # 垃圾文件清理 + # czkawka # 垃圾文件清理 ipmitool # cachix # nixos 的高级玩法,自己架设 binary cache # lsp - unstable.rust-analyzer + rust-analyzer efm-langserver # 集成 shellcheck marksman nodePackages.pyright # 为了方便,将常见的 c 库直接放出来 - libaio - liburing + # libaio + # liburing ]; programs.zsh = { @@ -309,73 +322,9 @@ in }; }; - programs.git = { - enable = true; - userEmail = "xueshi.hu@smartx.com"; - userName = "Xueshi Hu"; - - extraConfig = { - # https://github.com/dandavison/delta - # --- begin - core = { - editor = "nvim"; - pager = "delta"; - abbrev = 12; - }; - sendemail={ - smtpserver = "smtp.googlemail.com"; - smtpencryption = "tls"; - smtpserverport = 587; - smtpuser = "xueshi.hu@smartx.com"; - # 参考 - # https://www.marcusfolkesson.se/blog/get_maintainers-and-git-send-email/ - linux={ - tocmd ="/home/martins3/core/linux/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nol"; - cccmd ="/home/martins3/core/linux/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nom"; - }; - }; - pretty={ - fixes = "Fixes: %h (\"%s\")"; - commit = "commit %h (\"%s\")"; - }; - interactive = { - diffFilter = "delta --color-only"; - }; - delta = { - navigate = "true"; - light = "false"; - }; - merge = { - conflictstyle = "diff3"; - }; - diff = { - colorMoved = "default"; - }; - # --- end - - http = { - proxy = "http://127.0.0.1:8889"; - }; - - https = { - proxy = "http://127.0.0.1:8889"; - }; - - credential = { - helper = "store"; - }; - - alias = { - # 查询一个 merge commit 中的数值 - # https://stackoverflow.com/questions/6191138/how-to-see-commits-that-were-merged-in-to-a-merge-commit - log-merge = "!f() { git log --oneline --graph --stat \"$1^..$1\"; }; f"; - # 优雅的打印 - # https://stackoverflow.com/questions/6191138/how-to-see-commits-that-were-merged-in-to-a-merge-commit - adog = "log --all --decorate --oneline --graph"; - kernel = "log -n 1 --pretty=commit"; - bug = "log -n 1 --pretty=fixes"; - }; - }; + home.file.gitconfig = { + source = ../../config/.gitconfig; + target = ".gitconfig"; }; home.file.gdbinit = { diff --git a/nixpkgs/home/gui.nix b/nixpkgs/home/gui.nix index 7a2ff4ed5..551314f3c 100644 --- a/nixpkgs/home/gui.nix +++ b/nixpkgs/home/gui.nix @@ -16,30 +16,33 @@ in # shiori # bookmark 管理,但是没搞懂怎么使用 unstable.wpsoffice unstable.sublime-merge - unstable.vscode + # unstable.vscode unstable.flameshot # 截图 # unstable.zotero unstable.slack - # unstable.drawio + drawio # variety # wallpaper 但是 bing wallpaper 已经够好了 kitty + anki wezterm - wireshark - unstable.alacritty + # wireshark + alacritty + # unstable.spacedrive # 一打开就 crash 了,目前没法用 # zoom-us # spotify # joplin-desktop # 还有 joplin # gource - unstable.firefox + # unstable.firefox google-chrome + # libreoffice unstable.thunderbird - # unstable.feishu + feishu microsoft-edge vlc # podman-desktop # tdesktop # telegram - # unstable.clash-verge # 时不时连不上网,难道是我设置不对 + # clash-verge # 打开之后一块白板,不知道发生了什么 # gparted # 需要 GTK,使用 disk 也不错 # rofi # @todo rofi 的使用 # scrcpy # Android 的投屏工具 @@ -83,7 +86,7 @@ in bpftrace = { name = "bpftrace"; genericName = "bpftrace"; - exec = "microsoft-edge https://github.com/iovisor/bpftrace/blob/master/docs/reference_guide.md"; + exec = "microsoft-edge https://github.com/bpftrace/bpftrace/blob/master/man/adoc/bpftrace.adoc"; icon = (pkgs.fetchurl { url = "https://img.icons8.com/color/512/docker.png"; sha256 = "0jbjgh9gbh75q7sli8z6zn7m0nxcawq1v4vp1v4np7k4acp7r1dn"; diff --git a/nixpkgs/sys/gui.nix b/nixpkgs/sys/gui.nix index 61f4f3e7f..51b89544c 100644 --- a/nixpkgs/sys/gui.nix +++ b/nixpkgs/sys/gui.nix @@ -14,7 +14,7 @@ services.xserver.desktopManager.gnome.enable = true; # see xieby1 - fonts.fonts = ( + fonts.packages = ( with (import (fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/d881cf9fd64218a99a64a8bdae1272c3f94daea7.tar.gz"; sha256 = "1jaghsmsc05lvfzaq4qcy281rhq3jlx75q5x2600984kx1amwaal"; @@ -34,11 +34,11 @@ (stdenv.mkDerivation { name = "my_fonts"; srcs = [(fetchurl { - url = "https://github.com/lxgw/LxgwWenKai/releases/download/v1.235.2/LXGWWenKai-Bold.ttf"; - sha256 = "1v7bczjnadzf2s8q88rm0pf66kaymq3drsll4iy3i5axpbimap18"; + url = "https://github.com/lxgw/LxgwWenKai/releases/download/v1.315/LXGWWenKaiMono-Bold.ttf"; + sha256 = "129ikb5d9gqcy801rqqsirqjmz24mgshcc6mgj65bq6w6abs3y7y"; }) (fetchurl { - url = "https://github.com/lxgw/LxgwWenKai/releases/download/v1.235.2/LXGWWenKai-Regular.ttf"; - sha256 = "06kpqgar0vvsng4gzsnj1app1vkv7v07yqgi5mfwzxch0di5qk3v"; + url = "https://github.com/lxgw/LxgwWenKai/releases/download/v1.315/LXGWWenKai-Regular.ttf"; + sha256 = "1ybzbk50l3lmz0aja9cjh40bxcx9py8349qabxplpispk5jyy76d"; })]; sourceRoot = "./"; unpackCmd = '' @@ -66,10 +66,4 @@ # https://github.com/kovidgoyal/kitty/issues/403 environment.variables.GLFW_IM_MODULE = "ibus"; - i18n.inputMethod = { - enabled = "fcitx5"; - fcitx5.addons = with pkgs; [ - fcitx5-rime - ]; - }; } diff --git a/nixpkgs/sys/kernel.nix b/nixpkgs/sys/kernel-config.nix similarity index 63% rename from nixpkgs/sys/kernel.nix rename to nixpkgs/sys/kernel-config.nix index 8d9bd66ed..73a989213 100644 --- a/nixpkgs/sys/kernel.nix +++ b/nixpkgs/sys/kernel-config.nix @@ -2,51 +2,20 @@ { - boot = { - # kernelPackages = pkgs.linuxPackages_latest; - kernelPackages = pkgs.linuxPackages_6_5; - }; - - boot.kernelParams = [ - "transparent_hugepage=never" - "mitigations=off" - # 硬件上都直接不支持了 - # "tsx=on" - # "tsx_async_abort=off" - - # intel_iommu 需要手动打开 - # 不信请看 zcat /proc/config.gz | grep CONFIG_INTEL_IOMMU_DEFAULT_ON - "intel_iommu=on" - "iommu=pt" - "intremap=on" - # "amd_iommu_intr=vapic" - # "kvm-amd.avic=1" - # "isolcpus=28-31" - # "amd_iommu_intr=legacy" - # "ftrace=function" - # "ftrace_filter=amd_iommu_int_thread" - - # "processor.max_cstate=1" - # "intel_idle.max_cstate=0" - # "amd_iommu=off" - # "amd_iommu=pgtbl_v2" - # "iommu=pt" - # 手动禁用 avx2 - # "clearcpuid=156" - - # @todo 不是 systemd 会默认启动 fsck 的吗,这个需要啥 - # "fsck.mode=force" - "fsck.repair=yes" - "ftrace=function" - "ftrace_filter=dmar_set_interrupt" - ]; - +# TODO 这里存在让 fio nullblk 性能下降 10% 的选项,有趣啊 boot.kernelPatches = [ { name = "tracing"; patch = null; extraStructuredConfig = { BOOTTIME_TRACING = lib.kernel.yes; + IRQSOFF_TRACER = lib.kernel.yes; + MMIOTRACE = lib.kernel.yes; + OSNOISE_TRACER = lib.kernel.yes; + FPROBE = lib.kernel.yes; + TIMERLAT_TRACER = lib.kernel.yes; + PREEMPT_TRACER = lib.kernel.yes; + HWLAT_TRACER = lib.kernel.yes; }; } @@ -63,6 +32,15 @@ boot.kernelPatches = [ }; } + { + name = "hwpoison"; + patch = null; + extraStructuredConfig = { + MEMORY_FAILURE=lib.kernel.yes; + HWPOISON_INJECT=lib.kernel.yes; + }; + } + { name = "lru_gen"; patch = null; diff --git a/nixpkgs/sys/kernel-options.nix b/nixpkgs/sys/kernel-options.nix new file mode 100644 index 000000000..c9d3e22ba --- /dev/null +++ b/nixpkgs/sys/kernel-options.nix @@ -0,0 +1,56 @@ +{ config, pkgs, lib, ... }: + +{ + + boot = { + # kernelPackages = pkgs.linuxPackages_latest; + kernelPackages = pkgs.linuxPackages_6_8; + }; + + # @todo 加入的 vfio 参考 https://gist.github.com/CRTified/43b7ce84cd238673f7f24652c85980b3 不过他的感觉也是瞎写的 + boot.kernelModules = [ "vfio_pci" "vfio_iommu_type1" + "vmd" "null_blk" "scsi_debug" "vhost_net" ]; + boot.initrd.kernelModules = []; + boot.blacklistedKernelModules = [ "nouveau" ]; + + boot.extraModprobeConfig = '' + options scsi_debug dev_size_mb=100 +''; + + boot.kernelParams = [ + "transparent_hugepage=never" + "mitigations=off" + # 硬件上都直接不支持了 + # "tsx=on" + # "tsx_async_abort=off" + + # intel_iommu 需要手动打开 + # 不信请看 zcat /proc/config.gz | grep CONFIG_INTEL_IOMMU_DEFAULT_ON + "intel_iommu=on" + "iommu=pt" + "intremap=on" + # "amd_iommu_intr=vapic" + # "kvm-amd.avic=1" + # "isolcpus=28-31" + # "amd_iommu_intr=legacy" + # "ftrace=function" + # "ftrace_filter=amd_iommu_int_thread" + + # "processor.max_cstate=1" + # "intel_idle.max_cstate=0" + # "amd_iommu=off" + # "amd_iommu=pgtbl_v2" + # "iommu=pt" + # 手动禁用 avx2 + # "clearcpuid=156" + + # @todo 不是 systemd 会默认启动 fsck 的吗,这个需要啥 + # "fsck.mode=force" + "fsck.repair=yes" + + # 这个会导致 arm 打开所有函数的 trace ,难道是因为 ftrace_filter 设置一个不支持的函数 + # 然后机会导致所有的函数都被跟踪 + # "ftrace=function" + # "ftrace_filter=dmar_set_interrupt" + ]; +} diff --git a/nixpkgs/system.nix b/nixpkgs/system.nix index 65425ff2e..d4fcaabff 100644 --- a/nixpkgs/system.nix +++ b/nixpkgs/system.nix @@ -2,21 +2,20 @@ { config, pkgs, lib, ... }: let - # mkpasswd -m sha-512 - passwd = "$6$Iehu.x9i7eiceV.q$X4INuNrrxGvdK546sxdt3IV9yHr90/Mxo7wuIzdowoN..jFSFjX8gHaXchfBxV4pOYM4h38pPJOeuI1X/5fon/"; unstable = import { }; in { imports = [ ./sys/cli.nix - ./sys/kernel.nix + ./sys/kernel-options.nix + # ./sys/kernel-config.nix # ./sys/kernel-419.nix - ./sys/gui.nix # @todo 这个需要学习下 nix 语言了 - ] ++ (if (builtins.getEnv "DISPLAY") != "" - then [ - ./sys/gui.nix - ] else [ ]); + ] ++ ( + if builtins.currentSystem == "x86_64-linux" then [ + ./sys/gui.nix + ] else [ ] + ); nix.settings.substituters = [ "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" @@ -48,12 +47,18 @@ in ]; virtualisation.docker.enable = true; + virtualisation.docker.daemon.settings = { + bip = "10.11.0.1/16"; + }; + virtualisation.podman.enable = true; virtualisation.vswitch.enable = true; + virtualisation.vswitch.package = pkgs.openvswitch-lts; + zramSwap.enable = true; - networking.proxy.default = "http://127.0.0.1:8889"; - networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + # networking.proxy.default = "http://127.0.0.1:8889"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; environment.systemPackages = with pkgs; [ vim @@ -62,6 +67,7 @@ in zsh unstable.tailscale cifs-utils + k3s ]; services.tailscale.enable = true; @@ -97,6 +103,7 @@ in }; networking.firewall.checkReversePath = "loose"; + # networking.hostName = "martins3-host"; networking.firewall = { # enable the firewall @@ -106,52 +113,54 @@ in trustedInterfaces = [ "tailscale0" ]; # allow the Tailscale UDP port through the firewall - allowedUDPPorts = [ config.services.tailscale.port ]; + allowedUDPPorts = [ config.services.tailscale.port + + 8472 # k3s, flannel: required if using multi-node for inter-node networking + ]; # allow you to SSH in over the public internet allowedTCPPorts = [ 22 # ssh 5201 # iperf + 3434 # http.server 8889 # clash - 5900 # qemu vnc 445 # samba /* 8384 # syncthing */ /* 22000 # syncthing */ + 6443 # k3s: required so that pods can reach the API server (running on port 6443 by default) + 2379 # k3s, etcd clients: required if using a "High Availability Embedded etcd" configuration + 2380 # k3s, etcd peers: required if using a "High Availability Embedded etcd" configuration + ]; + + + allowedTCPPortRanges = [ + { from = 5900; to = 6100; } ]; }; # https://nixos.wiki/wiki/Fwupd - services.fwupd.enable = true; - - # @todo ----- 将这块代码移动到设备专用的地方去 ------- - # @todo 如何处理总是等待 /sys/subsystem/net/devices/enp4s0 的问题 - # 我靠,不知道什么时候 enp4s0 不见了,systemd 真的复杂啊 - # tailscale0 建立的网卡是什么原理,真有趣啊 - # networking.interfaces.enp4s0.useDHCP = false; - # networking.bridges.br0.interfaces = [ "enp5s0" ]; - # sudo ip ad add 10.0.0.1/24 dev enp5s0 - - # @todo 这个配置为什么不行 - /* networking.interfaces.enp5s0.ipv4.addresses = [{ */ - /* address = "10.0.0.1"; */ - /* prefixLength = 24; */ - /* }]; */ + # 似乎没啥用,而且还是存在 bug 的 + services.fwupd.enable = false; # wireless and wired coexist - # @todo disable this temporarily systemd.network.wait-online.timeout = 1; users.mutableUsers = false; - users.users.root.hashedPassword = passwd; users.users.martins3 = { isNormalUser = true; shell = pkgs.zsh; # shell = pkgs.nushell; home = "/home/martins3"; extraGroups = [ "wheel" "docker" "libvirtd" ]; - hashedPassword = passwd; }; + + services.k3s.enable = false; + services.k3s.role = "server"; + services.k3s.extraFlags = toString [ + # "--kubelet-arg=v=4" # Optionally add additional args to k3s + ]; + boot = { crashDump.enable = false; # TODO 这个东西形同虚设,无须浪费表情 crashDump.reservedMemory = "1G"; @@ -214,8 +223,6 @@ in enable = true; }; - services.jenkins.enable = false; - systemd.user.services.kernel = { enable = true; unitConfig = { }; @@ -249,7 +256,7 @@ in }; systemd.user.services.drink_water = { - enable = true; + enable = false; unitConfig = { }; serviceConfig = { Type = "forking"; @@ -269,7 +276,7 @@ in }; systemd.user.services.monitor = { - enable = true; + enable = false; unitConfig = { }; serviceConfig = { Type = "simple"; @@ -279,16 +286,25 @@ in wantedBy = [ "timers.target" ]; }; - systemd.user.services.httpd = { + systemd.user.services.clash = { enable = true; - description = "export home dir to LAN"; + unitConfig = { }; serviceConfig = { - WorkingDirectory = "/home/martins3/"; Type = "simple"; - ExecStart = "/home/martins3/.nix-profile/bin/python -m http.server"; + ExecStart = "${pkgs.clash-meta.outPath}/bin/clash-meta"; Restart = "no"; }; - wantedBy = [ "timers.target" ]; + wantedBy = [ "default.target" ]; + }; + + systemd.user.services.pueued = { + enable = true; + unitConfig = { }; + serviceConfig = { + ExecStart = "${pkgs.pueue.outPath}/bin/pueued -vv"; + Restart = "no"; + }; + wantedBy = [ "default.target" ]; }; systemd.user.services.kernel_doc = { @@ -325,16 +341,6 @@ in nixpkgs.config.allowUnfree = true; # programs.steam.enable = true; # steam 安装 - # @todo 加入的 vfio 参考 https://gist.github.com/CRTified/43b7ce84cd238673f7f24652c85980b3 不过他的感觉也是瞎写的 - boot.kernelModules = [ "vfio_pci" "vfio_iommu_type1" - "vmd" "null_blk" "scsi_debug" "vhost_net" ]; - boot.initrd.kernelModules = []; - boot.blacklistedKernelModules = [ "nouveau" ]; - - boot.extraModprobeConfig = '' - options scsi_debug dev_size_mb=100 -''; - services.samba = { enable = true; @@ -365,17 +371,19 @@ in "vm.overcommit_memory" = 1; }; + # https://nixos.org/manual/nixos/stable/index.html#ch-file-systems # 这一个例子如何自动 mount 一个盘,但是配置放到 /etc/nixos/configuration.nix # 中,参考[1] 但是 options 只有包含一个 # [1]: https://unix.stackexchange.com/questions/533265/how-to-mount-internal-drives-as-a-normal-user-in-nixos # - # fileSystems."/home/martins3/hackme" = { + # fileSystems."/home/martins3/hack" = { # device = "/dev/disk/by-uuid/b709d158-aa6a-4b72-8255-513517548111"; # fsType = "auto"; - # options = [ "user"]; + # options = [ "user" "exec" "nofail"]; # }; + # 配合使用 # sudo mount -t nfs 127.0.0.1:/home/martins3/nfs /mnt # 这个时候居然可以删除掉 nfs ,乌鱼子 @@ -384,3 +392,8 @@ in /home/martins3/nfs 127.0.0.1(rw,fsid=0,no_subtree_check) ''; } + + +# 做一个开机任务,记录下 SSD 的写入 +# 🧀 sudo smartctl -t short -a /dev/nvme2n1 | grep "Data Units Written" +# Data Units Written: 220,743,742 [113 TB] diff --git a/nvim/10k.txt b/nvim/10k.txt new file mode 100644 index 000000000..616c7c5b8 --- /dev/null +++ b/nvim/10k.txt @@ -0,0 +1,8810 @@ +abandoned +abilities +ability +able +aboriginal +abortion +about +above +abraham +abroad +absence +absent +absolute +absolutely +absorption +abstract +abstracts +abuse +academic +academics +academy +accent +accept +acceptable +acceptance +accepted +accepting +accepts +access +accessed +accessibility +accessible +accessing +accessories +accessory +accident +accidents +accommodate +accommodation +accommodations +accompanied +accompanying +accomplish +accomplished +accordance +according +accordingly +account +accountability +accounting +accounts +accreditation +accredited +accumulate +accuracy +accurate +accurately +accused +acdbentity +acer +achieve +achieved +achievement +achievements +achieving +acid +acids +acknowledge +acknowledged +acne +acoustic +acquire +acquired +acquisition +acquisitions +acre +acres +acrobat +across +acrylic +acting +action +actions +activated +activation +active +actively +activists +activities +activity +actor +actors +actress +acts +actual +actually +acute +adam +adams +adaptation +adapted +adapter +adapters +adaptive +adaptor +added +addiction +adding +addition +additional +additionally +additions +address +addressed +addresses +addressing +adds +adelaide +adequate +adidas +adipex +adjacent +adjust +adjustable +adjusted +adjustment +adjustments +admin +administered +administration +administrative +administrator +administrators +admission +admissions +admit +admitted +adobe +adolescent +adopt +adopted +adoption +adrian +adsl +adult +adults +advance +advanced +advancement +advances +advantage +advantages +adventure +adventures +adverse +advert +advertise +advertisement +advertisements +advertiser +advertisers +advertising +advice +advise +advised +advisor +advisors +advisory +advocacy +advocate +adware +aerial +aerospace +affair +affairs +affect +affected +affecting +affects +affiliate +affiliated +affiliates +affiliation +afford +affordable +afghanistan +afraid +africa +african +after +afternoon +afterwards +again +against +aged +agencies +agency +agenda +agent +agents +ages +aggregate +aggressive +aging +agree +agreed +agreement +agreements +agrees +agricultural +agriculture +ahead +aids +aimed +aims +aircraft +airfare +airline +airlines +airplane +airport +airports +alabama +alan +alarm +alaska +albania +albany +albert +alberta +album +albums +albuquerque +alcohol +alert +alerts +alex +alexander +alexandria +alfred +algebra +algeria +algorithm +algorithms +alias +alice +alien +align +alignment +alike +alive +allah +allan +alleged +allen +allergy +alliance +allied +allocated +allocation +allow +allowance +allowed +allowing +allows +alloy +almost +alone +along +alot +alpha +alphabetical +alpine +already +also +alter +altered +alternate +alternative +alternatively +alternatives +although +alto +aluminium +aluminum +alumni +always +amanda +amateur +amazing +amazon +ambassador +amber +ambien +ambient +amend +amended +amendment +amendments +amenities +america +american +americans +americas +amino +among +amongst +amount +amounts +ampland +amplifier +amsterdam +anaheim +analog +analyses +analysis +analyst +analysts +analytical +analyze +analyzed +anatomy +anchor +ancient +andale +anderson +andorra +andrea +andreas +andrew +andrews +andy +angel +angela +angeles +angels +anger +angle +angola +angry +animal +animals +animated +animation +anime +anna +anne +annex +annie +anniversary +annotated +annotation +announce +announced +announcement +announcements +announces +annoying +annual +annually +anonymous +another +answer +answered +answering +answers +antarctica +antenna +anthony +anthropology +anti +antibodies +antibody +anticipated +antigua +antique +antiques +antivirus +antonio +anxiety +anybody +anymore +anyone +anything +anytime +anyway +anywhere +apache +apart +apartment +apartments +apnic +apollo +apparatus +apparel +apparent +apparently +appeal +appeals +appear +appearance +appeared +appearing +appears +appendix +apple +appliance +appliances +applicable +applicant +applicants +application +applications +applied +applies +apply +applying +appointed +appointment +appointments +appraisal +appreciate +appreciated +appreciation +approach +approaches +appropriate +appropriations +approval +approve +approved +approx +approximate +approximately +apps +april +aqua +aquarium +aquatic +arab +arabia +arabic +arbitrary +arbitration +arbor +arcade +arch +architect +architects +architectural +architecture +archive +archived +archives +arctic +area +areas +arena +argentina +argue +argued +argument +arguments +arise +arising +arizona +arkansas +arlington +armed +armenia +armor +arms +armstrong +army +arnold +around +arrange +arranged +arrangement +arrangements +array +arrest +arrested +arrival +arrivals +arrive +arrived +arrives +arrow +arthritis +arthur +article +articles +artificial +artist +artistic +artists +arts +artwork +aruba +asbestos +ascii +ashley +asia +asian +aside +asin +asked +asking +asks +aspect +aspects +assault +assembled +assembly +assess +assessed +assessing +assessment +assessments +asset +assets +assign +assigned +assignment +assignments +assist +assistance +assistant +assisted +assists +associate +associated +associates +association +associations +assume +assumed +assumes +assuming +assumption +assumptions +assurance +assure +assured +asthma +astrology +astronomy +asus +asylum +athens +athletes +athletic +athletics +atlanta +atlantic +atlas +atmosphere +atmospheric +atom +atomic +attach +attached +attachment +attachments +attack +attacked +attacks +attempt +attempted +attempting +attempts +attend +attendance +attended +attending +attention +attitude +attitudes +attorney +attorneys +attract +attraction +attractions +attractive +attribute +attributes +auburn +auckland +auction +auctions +audi +audience +audio +audit +auditor +august +aurora +austin +australia +australian +austria +authentic +authentication +author +authorities +authority +authorization +authorized +authors +auto +automated +automatic +automatically +automation +automobile +automobiles +automotive +autos +autumn +availability +available +avatar +avenue +average +aviation +avoid +avoiding +avon +award +awarded +awards +aware +awareness +away +awesome +awful +axis +azerbaijan +babe +babes +babies +baby +bachelor +back +backed +background +backgrounds +backing +backup +bacon +bacteria +bacterial +badge +badly +baghdad +bags +bahamas +bahrain +bailey +baker +baking +balance +balanced +bald +bali +ball +ballet +balloon +ballot +baltimore +banana +band +bands +bandwidth +bang +bangkok +bangladesh +bank +banking +bankruptcy +banks +banned +banner +banners +baptist +barbados +barbara +barbie +barcelona +bare +barely +bargain +bargains +barn +barnes +barrel +barrier +barriers +barry +bars +base +baseball +based +baseline +basement +basename +bases +basic +basically +basics +basin +basis +basket +basketball +baskets +bass +batch +bath +bathroom +bathrooms +baths +batman +batteries +battery +battle +battlefield +beach +beaches +beads +beam +bean +beans +bear +bearing +bears +beast +beastality +beat +beatles +beats +beautiful +beautifully +beauty +beaver +became +because +become +becomes +becoming +bedding +bedford +bedroom +bedrooms +beds +beef +been +beer +before +began +begin +beginner +beginners +beginning +begins +begun +behalf +behavior +behavioral +behaviour +behind +beijing +being +beings +belarus +belfast +belgium +belief +beliefs +believe +believed +believes +belize +belkin +bell +belle +belly +belong +belongs +below +belt +belts +bench +benchmark +bend +beneath +beneficial +benefit +benefits +benjamin +bennett +bent +benz +berkeley +berlin +bermuda +bernard +berry +beside +besides +best +bestsellers +beta +beth +better +betting +betty +between +beverage +beverages +beverly +beyond +bhutan +bias +bible +biblical +bibliographic +bibliography +bicycle +bidder +bidding +bids +bigger +biggest +bike +bikes +bikini +bill +billing +billion +bills +billy +binary +bind +binding +bingo +biodiversity +biographies +biography +biol +biological +biology +bios +biotechnology +bird +birds +birmingham +birth +birthday +bishop +bite +bits +bizarre +bizrate +black +blackberry +blackjack +blacks +blade +blades +blah +blair +blake +blame +blank +blanket +blast +bleeding +blend +bless +blessed +blind +blink +block +blocked +blocking +blocks +blog +blogger +bloggers +blogging +blogs +blond +blonde +blood +bloom +bloomberg +blow +blowing +blue +blues +bluetooth +blvd +board +boards +boat +boating +boats +bobby +bodies +body +bold +bolivia +bolt +bomb +bond +bonds +bone +bones +bonus +book +booking +bookings +bookmark +bookmarks +books +bookstore +bool +boolean +boom +boost +boot +booth +boots +booty +border +borders +bored +boring +born +borough +bosnia +boss +boston +both +bother +botswana +bottle +bottles +bottom +bought +boulder +boulevard +bound +boundaries +boundary +bouquet +boutique +bowl +bowling +boxed +boxes +boxing +boys +bracelet +bracelets +bracket +brad +bradford +bradley +brain +brake +brakes +branch +branches +brand +brandon +brands +bras +brass +brave +brazil +brazilian +breach +bread +break +breakdown +breakfast +breaking +breaks +breast +breath +breathing +breed +breeding +breeds +brian +brick +bridal +bride +bridge +bridges +brief +briefing +briefly +briefs +bright +brighton +brilliant +bring +bringing +brings +brisbane +bristol +britain +britannica +british +britney +broad +broadband +broadcast +broadcasting +broader +broadway +brochure +brochures +broke +broken +broker +brokers +bronze +brook +brooklyn +brooks +brother +brothers +brought +brown +browse +browser +browsers +browsing +bruce +brunei +brunette +brunswick +brush +brussels +brutal +bryan +bryant +bubble +buck +bucks +budapest +buddy +budget +budgets +buffalo +buffer +bufing +bugs +build +builder +builders +building +buildings +builds +built +bulgaria +bulgarian +bulk +bull +bullet +bulletin +bumper +bunch +bundle +bunny +burden +bureau +buried +burke +burlington +burn +burner +burning +burns +burst +burton +buses +bush +business +businesses +busy +butler +butter +butterfly +button +buttons +butts +buyer +buyers +buying +buys +buzz +byte +bytes +cabin +cabinet +cabinets +cable +cables +cache +cached +cadillac +cafe +cage +cake +cakes +calcium +calculate +calculated +calculation +calculations +calculator +calculators +calendar +calendars +calgary +calibration +california +call +called +calling +calls +calm +calvin +cambodia +cambridge +camcorder +camcorders +came +camel +camera +cameras +cameron +cameroon +camp +campaign +campaigns +campbell +camping +camps +campus +cams +canada +canadian +canal +canberra +cancel +cancellation +cancelled +cancer +candidate +candidates +candle +candles +candy +cannon +canon +cant +canvas +canyon +capabilities +capability +capable +capacity +cape +capital +capitol +caps +captain +capture +captured +carb +carbon +card +cardiac +cardiff +cardiovascular +cards +care +career +careers +careful +carefully +carey +cargo +caribbean +caring +carl +carlo +carlos +carmen +carnival +carol +carolina +caroline +carpet +carried +carrier +carriers +carries +carroll +carry +carrying +cars +cart +carter +cartoon +cartoons +cartridge +cartridges +casa +case +cases +casey +cash +cashiers +casino +casinos +casio +cassette +cast +casting +castle +casual +catalog +catalogs +catalogue +catalyst +catch +categories +category +catering +cathedral +catherine +catholic +cats +cattle +caught +cause +caused +causes +causing +caution +cave +cayman +cdna +cedar +ceiling +celebrate +celebration +celebrities +celebrity +celebs +cell +cells +cellular +celtic +cement +cemetery +census +cent +center +centered +centers +central +centre +centres +cents +centuries +century +ceramic +ceremony +certain +certainly +certificate +certificates +certification +certified +chad +chain +chains +chair +chairman +chairs +challenge +challenged +challenges +challenging +chamber +chambers +champagne +champion +champions +championship +championships +chan +chance +chancellor +chances +change +changed +changelog +changes +changing +channel +channels +chaos +chapel +chapter +chapters +char +character +characteristic +characteristics +characterization +characterized +characters +charge +charged +charger +chargers +charges +charging +charitable +charity +charles +charleston +charlie +charlotte +charm +charming +charms +chart +charter +charts +chase +chassis +chat +cheap +cheaper +cheapest +cheat +cheats +check +checked +checking +checklist +checkout +checks +cheers +cheese +chef +chelsea +chem +chemical +chemicals +chemistry +chen +cheque +cherry +chess +chest +chester +chevrolet +chevy +chicago +chick +chicken +chicks +chief +child +childhood +children +childrens +chile +china +chinese +chip +chips +chocolate +choice +choices +choir +cholesterol +choose +choosing +chorus +chose +chosen +chris +christ +christian +christianity +christians +christina +christine +christmas +christopher +chrome +chronic +chronicle +chronicles +chrysler +chubby +chuck +church +churches +cialis +ciao +cigarette +cigarettes +cincinnati +cindy +cinema +cingular +circle +circles +circuit +circuits +circular +circulation +circumstances +circus +cisco +citation +citations +cite +cited +cities +citizen +citizens +citizenship +city +citysearch +civic +civil +civilian +civilization +claim +claimed +claims +claire +clan +clara +clarity +clark +clarke +class +classes +classic +classical +classics +classification +classified +classifieds +classroom +clause +clay +clean +cleaner +cleaners +cleaning +cleanup +clear +clearance +cleared +clearing +clearly +clerk +cleveland +click +clicking +clicks +client +clients +cliff +climate +climb +climbing +clinic +clinical +clinics +clinton +clip +clips +clock +clocks +clone +close +closed +closely +closer +closes +closest +closing +closure +cloth +clothes +clothing +cloud +clouds +cloudy +club +clubs +cluster +clusters +cnet +coach +coaches +coaching +coal +coalition +coast +coastal +coat +coated +coating +cocktail +code +codes +coding +coffee +cognitive +cohen +coin +coins +cold +cole +coleman +colin +collaboration +collaborative +collapse +collar +colleague +colleagues +collect +collectables +collected +collectible +collectibles +collecting +collection +collections +collective +collector +collectors +college +colleges +collins +cologne +colombia +colon +colonial +colony +color +colorado +colored +colors +colour +colours +columbia +columbus +column +columnists +columns +combat +combination +combinations +combine +combined +combines +combining +combo +come +comedy +comes +comfort +comfortable +comic +comics +coming +comm +command +commander +commands +comment +commentary +commented +comments +commerce +commercial +commission +commissioner +commissioners +commissions +commit +commitment +commitments +committed +committee +committees +commodities +commodity +common +commonly +commons +commonwealth +communicate +communication +communications +communist +communities +community +comp +compact +companies +companion +company +compaq +comparable +comparative +compare +compared +comparing +comparison +comparisons +compatibility +compatible +compensation +compete +competent +competing +competition +competitions +competitive +competitors +compilation +compile +compiled +compiler +complaint +complaints +complement +complete +completed +completely +completing +completion +complex +complexity +compliance +compliant +complicated +complications +complimentary +comply +component +components +composed +composer +composite +composition +compound +compounds +comprehensive +compressed +compression +compromise +computation +computational +compute +computed +computer +computers +computing +concentrate +concentration +concentrations +concept +concepts +conceptual +concern +concerned +concerning +concerns +concert +concerts +conclude +concluded +conclusion +conclusions +concord +concrete +condition +conditional +conditioning +conditions +condo +condos +conduct +conducted +conducting +conf +conference +conferences +conferencing +confidence +confident +confidential +confidentiality +config +configuration +configurations +configure +configured +configuring +confirm +confirmation +confirmed +conflict +conflicts +confused +confusion +congo +congratulations +congress +congressional +conjunction +connect +connected +connecticut +connecting +connection +connections +connectivity +connector +connectors +cons +conscious +consciousness +consecutive +consensus +consent +consequence +consequences +consequently +conservation +conservative +consider +considerable +consideration +considerations +considered +considering +considers +consist +consistency +consistent +consistently +consisting +consists +console +consoles +consolidated +consolidation +consortium +conspiracy +const +constant +constantly +constitute +constitutes +constitution +constitutional +constraint +constraints +construct +constructed +construction +consult +consultancy +consultant +consultants +consultation +consulting +consumer +consumers +consumption +contact +contacted +contacting +contacts +contain +contained +container +containers +containing +contains +contamination +contemporary +content +contents +contest +contests +context +continent +continental +continually +continue +continued +continues +continuing +continuity +continuous +continuously +contract +contracting +contractor +contractors +contracts +contrary +contrast +contribute +contributed +contributing +contribution +contributions +contributor +contributors +control +controlled +controller +controllers +controlling +controls +controversial +controversy +convenience +convenient +convention +conventional +conventions +convergence +conversation +conversations +conversion +convert +converted +converter +convertible +convicted +conviction +convinced +cook +cookbook +cooked +cookie +cookies +cooking +cool +cooler +cooling +cooper +cooperation +cooperative +coordinate +coordinated +coordinates +coordination +coordinator +cope +copied +copies +copper +copy +copying +copyright +copyrighted +copyrights +coral +cord +cordless +core +cork +corn +cornell +corner +corners +cornwall +corp +corporate +corporation +corporations +corps +corpus +correct +corrected +correction +corrections +correctly +correlation +correspondence +corresponding +corruption +cosmetic +cosmetics +cost +costa +costs +costume +costumes +cottage +cottages +cotton +could +council +councils +counsel +counseling +count +counted +counter +counters +counties +counting +countries +country +counts +county +couple +coupled +couples +coupon +coupons +courage +courier +course +courses +court +courtesy +courts +cove +cover +coverage +covered +covering +covers +cowboy +crack +cradle +craft +crafts +craig +craps +crash +crawford +crazy +cream +create +created +creates +creating +creation +creations +creative +creativity +creator +creature +creatures +credit +credits +creek +crest +crew +cricket +crime +crimes +criminal +crisis +criteria +criterion +critical +criticism +critics +croatia +crop +crops +cross +crossing +crossword +crowd +crown +crucial +crude +cruise +cruises +cruz +crystal +ctrl +cuba +cube +cubic +cuisine +cult +cultural +culture +cultures +cumulative +cups +cure +curious +currencies +currency +current +currently +curriculum +cursor +curtis +curve +curves +custody +custom +customer +customers +customise +customize +customized +customs +cute +cuts +cutting +cyber +cycle +cycles +cycling +cylinder +cyprus +czech +daddy +daily +dairy +daisy +dakota +dale +dallas +damage +damaged +damages +dame +dana +dance +dancing +danger +dangerous +daniel +danish +danny +dans +dare +dark +darkness +darwin +dash +data +database +databases +date +dated +dates +dating +daughter +daughters +dave +david +davidson +davis +dawn +days +dayton +dead +deadline +deadly +deaf +deal +dealer +dealers +dealing +deals +dealt +dealtime +dean +dear +death +deaths +debate +debian +deborah +debt +debug +debut +decade +decades +december +decent +decide +decided +decimal +decision +decisions +deck +declaration +declare +declared +decline +declined +decor +decorating +decorative +decrease +decreased +dedicated +deemed +deep +deeper +deeply +deer +default +defeat +defects +defence +defend +defendant +defense +defensive +deferred +deficit +define +defined +defines +defining +definitely +definition +definitions +degree +degrees +delaware +delay +delayed +delays +delegation +delete +deleted +delhi +delicious +delight +deliver +delivered +delivering +delivers +delivery +dell +delta +deluxe +demand +demanding +demands +demo +democracy +democrat +democratic +democrats +demographic +demonstrate +demonstrated +demonstrates +demonstration +denial +denied +denmark +dennis +dense +density +dental +dentists +denver +deny +department +departmental +departments +departure +depend +dependence +dependent +depending +depends +deployment +deposit +deposits +depot +depression +dept +depth +deputy +derby +derek +derived +descending +describe +described +describes +describing +description +descriptions +desert +deserve +design +designated +designation +designed +designer +designers +designing +designs +desirable +desire +desired +desk +desktop +desktops +desperate +despite +destination +destinations +destiny +destroy +destroyed +destruction +detail +detailed +details +detect +detected +detection +detective +detector +determination +determine +determined +determines +determining +detroit +deutsch +deutsche +deutschland +devel +develop +developed +developer +developers +developing +development +developmental +developments +develops +deviant +deviation +device +devices +devil +devon +devoted +diabetes +diagnosis +diagnostic +diagram +dial +dialog +dialogue +diameter +diamond +diamonds +diana +diane +diary +dice +dicke +dicks +dictionaries +dictionary +died +diego +dies +diesel +diet +dietary +diff +differ +difference +differences +different +differential +differently +difficult +difficulties +difficulty +diffs +digest +digit +digital +dimension +dimensional +dimensions +dining +dinner +diploma +direct +directed +direction +directions +directive +directly +director +directories +directors +directory +dirt +dirty +disabilities +disability +disable +disabled +disagree +disappointed +disaster +disc +discharge +disciplinary +discipline +disciplines +disclaimer +disclaimers +disclose +disclosure +disco +discount +discounted +discounts +discover +discovered +discovery +discrete +discretion +discrimination +discs +discuss +discussed +discusses +discussing +discussion +discussions +disease +diseases +dish +dishes +disk +disks +disney +disorder +disorders +dispatch +dispatched +display +displayed +displaying +displays +disposal +disposition +dispute +disputes +dist +distance +distances +distant +distinct +distinction +distinguished +distribute +distributed +distribution +distributions +distributor +distributors +district +districts +disturbed +dive +diverse +diversity +divide +divided +dividend +divine +diving +division +divisions +divorce +divx +dock +docs +doctor +doctors +doctrine +document +documentary +documentation +documented +documents +dodge +does +dogs +doing +doll +dollar +dollars +dolls +domain +domains +dome +domestic +dominant +dominican +donald +donate +donated +donation +donations +done +donna +donor +donors +dont +doom +door +doors +dosage +dose +double +doubt +doug +douglas +dover +down +download +downloadable +downloaded +downloading +downloads +downtown +dozen +dozens +draft +drag +dragon +drain +drainage +drama +dramatic +dramatically +draw +drawing +drawings +drawn +draws +dream +dreams +dress +dressed +dresses +dressing +drew +dried +drill +drilling +drink +drinking +drinks +drive +driven +driver +drivers +drives +driving +drop +dropped +drops +drove +drug +drugs +drum +drums +drunk +dryer +dual +dubai +dublin +duck +dude +duke +dumb +dump +duncan +duplicate +durable +duration +durham +during +dust +dutch +duties +duty +dvds +dying +dylan +dynamic +dynamics +each +eagle +eagles +earl +earlier +earliest +early +earn +earned +earning +earnings +earrings +ears +earth +earthquake +ease +easier +easily +east +easter +eastern +easy +eating +ebay +ebony +ebook +ebooks +echo +eclipse +ecological +ecology +ecommerce +economic +economics +economies +economy +ecuador +eddie +eden +edgar +edge +edges +edinburgh +edit +edited +editing +edition +editions +editor +editorial +editorials +editors +edmonton +educated +education +educational +educators +edward +edwards +effect +effective +effectively +effectiveness +effects +efficiency +efficient +efficiently +effort +efforts +eggs +egypt +egyptian +eight +either +elder +elderly +elect +elected +election +elections +electoral +electric +electrical +electricity +electro +electron +electronic +electronics +elegant +element +elementary +elements +elephant +elevation +eleven +eligibility +eligible +eliminate +elimination +elite +elizabeth +ellen +elliott +ellis +else +elsewhere +elvis +emacs +email +emails +embassy +embedded +emerald +emergency +emerging +emily +eminem +emirates +emission +emissions +emma +emotional +emotions +emperor +emphasis +empire +empirical +employ +employed +employee +employees +employer +employers +employment +empty +enable +enabled +enables +enabling +enclosed +enclosure +encoding +encounter +encountered +encourage +encouraged +encourages +encouraging +encryption +encyclopedia +endangered +ended +endif +ending +endless +endorsed +endorsement +ends +enemies +enemy +energy +enforcement +engage +engaged +engagement +engaging +engine +engineer +engineering +engineers +engines +england +english +enhance +enhanced +enhancement +enhancements +enhancing +enjoy +enjoyed +enjoying +enlarge +enlargement +enormous +enough +enquiries +enquiry +enrolled +enrollment +ensemble +ensure +ensures +ensuring +enter +entered +entering +enterprise +enterprises +enters +entertaining +entertainment +entire +entirely +entities +entitled +entity +entrance +entrepreneur +entrepreneurs +entries +entry +envelope +environment +environmental +environments +enzyme +epic +epinions +episode +episodes +epson +equal +equality +equally +equation +equations +equilibrium +equipment +equipped +equity +equivalent +eric +ericsson +erik +erotica +error +errors +escape +escorts +especially +espn +essay +essays +essence +essential +essentially +essentials +essex +establish +established +establishing +establishment +estate +estates +estimate +estimated +estimates +estimation +estonia +eternal +ethernet +ethical +ethics +ethiopia +ethnic +eugene +euro +europe +european +euros +eval +evaluate +evaluated +evaluating +evaluation +evaluations +evanescence +evans +even +evening +event +events +eventually +ever +every +everybody +everyday +everyone +everything +everywhere +evidence +evident +evil +evolution +exact +exactly +exam +examination +examinations +examine +examined +examines +examining +example +examples +exams +exceed +excel +excellence +excellent +except +exception +exceptional +exceptions +excerpt +excess +excessive +exchange +exchanges +excited +excitement +exciting +exclude +excluded +excluding +exclusion +exclusive +exclusively +excuse +exec +execute +executed +execution +executive +executives +exempt +exemption +exercise +exercises +exhaust +exhibit +exhibition +exhibitions +exhibits +exist +existed +existence +existing +exists +exit +exotic +expand +expanded +expanding +expansion +expansys +expect +expectations +expected +expects +expedia +expenditure +expenditures +expense +expenses +expensive +experience +experienced +experiences +experiencing +experiment +experimental +experiments +expert +expertise +experts +expiration +expired +expires +explain +explained +explaining +explains +explanation +explicit +explicitly +exploration +explore +explorer +exploring +explosion +expo +export +exports +exposed +exposure +express +expressed +expression +expressions +extend +extended +extending +extends +extension +extensions +extensive +extent +exterior +external +extra +extract +extraction +extraordinary +extras +extreme +extremely +eyed +eyes +fabric +fabrics +fabulous +face +faced +faces +facial +facilitate +facilities +facility +facing +fact +factor +factors +factory +facts +faculty +fail +failed +failing +fails +failure +failures +fair +fairfield +fairly +fairy +faith +fake +fall +fallen +falling +falls +false +fame +familiar +families +family +famous +fancy +fans +fantastic +fantasy +faqs +fare +fares +farm +farmer +farmers +farming +farms +fascinating +fashion +fast +faster +fastest +fatal +fate +father +fathers +fatty +fault +favor +favorite +favorites +favors +favour +favourite +favourites +fear +fears +feat +feature +featured +features +featuring +february +federal +federation +feed +feedback +feeding +feeds +feel +feeling +feelings +feels +fees +feet +fell +fellow +fellowship +felt +female +females +fence +feof +ferrari +ferry +festival +festivals +fetish +fever +fewer +fiber +fibre +fiction +field +fields +fifteen +fifth +fifty +fight +fighter +fighters +fighting +figure +figured +figures +fiji +file +filed +filename +files +filing +fill +filled +filling +film +filme +films +filter +filtering +filters +final +finally +finals +finance +finances +financial +financing +find +findarticles +finder +finding +findings +findlaw +finds +fine +finest +finger +fingers +finish +finished +finishing +finite +finland +finnish +fioricet +fire +fired +firefox +fireplace +fires +firewall +firewire +firm +firms +firmware +first +fiscal +fish +fisher +fisheries +fishing +fist +fitness +fits +fitted +fitting +five +fixed +fixes +fixtures +flag +flags +flame +flash +flashers +flashing +flat +flavor +fleece +fleet +flesh +flex +flexibility +flexible +flickr +flight +flights +flip +float +floating +flood +floor +flooring +floors +floppy +floral +florence +florida +florist +florists +flour +flow +flower +flowers +flows +floyd +fluid +flush +flux +flyer +flying +foam +focal +focus +focused +focuses +focusing +fold +folder +folders +folding +folk +folks +follow +followed +following +follows +font +fonts +food +foods +fool +foot +footage +football +footwear +forbes +forbidden +force +forced +forces +ford +forecast +forecasts +foreign +forest +forestry +forests +forever +forge +forget +forgot +forgotten +fork +form +formal +format +formation +formats +formatting +formed +former +formerly +forming +forms +formula +fort +forth +fortune +forty +forum +forums +forward +forwarding +fossil +foster +foto +fotos +fought +foul +found +foundation +foundations +founded +founder +fountain +four +fourth +fraction +fragrance +fragrances +frame +framed +frames +framework +framing +france +franchise +francis +francisco +frank +frankfurt +franklin +fraser +fraud +fred +frederick +free +freebsd +freedom +freelance +freely +freeware +freeze +freight +french +frequencies +frequency +frequent +frequently +fresh +friday +fridge +friend +friendly +friends +friendship +frog +from +front +frontier +frontpage +frost +frozen +fruit +fruits +fuel +fuji +fujitsu +full +fully +function +functional +functionality +functioning +functions +fund +fundamental +fundamentals +funded +funding +fundraising +funds +funeral +funk +funky +funny +furnished +furnishings +furniture +further +furthermore +fusion +future +futures +fuzzy +gabriel +gadgets +gage +gain +gained +gains +galaxy +gale +galleries +gallery +gambling +game +gamecube +games +gamespot +gaming +gamma +gang +gaps +garage +garbage +garcia +garden +gardening +gardens +garlic +garmin +gary +gasoline +gate +gates +gateway +gather +gathered +gathering +gauge +gave +gays +gazette +gear +geek +gender +gene +genealogy +general +generally +generate +generated +generates +generating +generation +generations +generator +generators +generic +generous +genes +genesis +genetic +genetics +geneva +genius +genome +genre +genres +gentle +gentleman +gently +genuine +geographic +geographical +geography +geological +geology +geometry +george +georgia +gerald +german +germany +gets +getting +ghana +ghost +giant +giants +gibraltar +gibson +gift +gifts +gilbert +girl +girlfriend +girls +give +given +gives +giving +glad +glance +glasgow +glass +glasses +glen +glenn +global +globe +glory +glossary +gloves +glow +glucose +gmbh +gnome +goal +goals +goat +gods +goes +going +gold +golden +golf +gone +gonna +good +goods +google +gordon +gore +gorgeous +gospel +gossip +gothic +goto +gotta +gotten +gourmet +governance +governing +government +governmental +governments +governor +grab +grace +grad +grade +grades +gradually +graduate +graduated +graduates +graduation +graham +grain +grammar +grams +grand +grande +granny +grant +granted +grants +graph +graphic +graphical +graphics +graphs +gras +grass +grateful +gratis +gratuit +grave +gravity +gray +great +greater +greatest +greatly +greece +greek +green +greene +greenhouse +greensboro +greeting +greetings +greg +gregory +grenada +grew +grey +grid +griffin +grill +grip +grocery +groove +gross +ground +grounds +groundwater +group +groups +grove +grow +growing +grown +grows +growth +guam +guarantee +guaranteed +guarantees +guard +guardian +guards +guatemala +guess +guest +guestbook +guests +guidance +guide +guided +guidelines +guides +guild +guilty +guinea +guitar +guitars +gulf +guns +guru +guyana +guys +gzip +habitat +habits +hack +hacker +hair +hairy +haiti +half +halifax +hall +halloween +halo +hamburg +hamilton +hammer +hampshire +hampton +hand +handbags +handbook +handed +handheld +handhelds +handle +handled +handles +handling +handmade +hands +handy +hang +hanging +hans +hansen +happen +happened +happening +happens +happiness +happy +harassment +harbor +harbour +hard +hardcover +harder +hardly +hardware +hardwood +harley +harm +harmful +harmony +harold +harper +harris +harrison +harry +hart +hartford +harvard +harvest +harvey +hash +hate +hats +have +haven +having +hawaii +hawaiian +hawk +hayes +hazard +hazardous +hazards +hdtv +head +headed +header +headers +heading +headline +headlines +headphones +headquarters +heads +headset +healing +health +healthcare +healthy +hear +heard +hearing +hearings +heart +hearts +heat +heated +heater +heath +heather +heating +heaven +heavily +heavy +hebrew +heel +height +heights +held +helen +helena +helicopter +hello +helmet +help +helped +helpful +helping +helps +hence +henderson +henry +hepatitis +herald +herb +herbal +herbs +here +hereby +herein +heritage +hero +heroes +herself +hewlett +hidden +hide +hierarchy +high +higher +highest +highland +highlight +highlighted +highlights +highly +highs +highway +highways +hiking +hill +hills +hilton +himself +hindu +hint +hints +hire +hired +hiring +hispanic +hist +historic +historical +history +hitachi +hits +hitting +hobbies +hobby +hockey +hold +holdem +holder +holders +holding +holdings +holds +hole +holes +holiday +holidays +holland +hollow +holly +hollywood +holmes +holocaust +holy +home +homeland +homeless +homepage +homes +hometown +homework +honda +honduras +honest +honey +hong +honolulu +honor +honors +hood +hook +hope +hoped +hopefully +hopes +hoping +hopkins +horizon +horizontal +hormone +horn +horrible +horror +horse +horses +hose +hospital +hospitality +hospitals +host +hosted +hostel +hostels +hosting +hosts +hotel +hotels +hotmail +hottest +hour +hourly +hours +house +household +households +houses +housewares +housewives +housing +houston +howard +however +howto +href +html +http +hudson +huge +hugh +hughes +hugo +hull +human +humanitarian +humanities +humanity +humans +humidity +humor +hundred +hundreds +hung +hungarian +hungary +hunger +hungry +hunt +hunter +hunting +huntington +hurricane +hurt +husband +hybrid +hydraulic +hydrocodone +hydrogen +hygiene +hypothesis +hypothetical +hyundai +iceland +icon +icons +idaho +idea +ideal +ideas +identical +identification +identified +identifier +identifies +identify +identifying +identity +idle +idol +ieee +ignore +ignored +illegal +illinois +illness +illustrated +illustration +illustrations +image +images +imagination +imagine +imaging +immediate +immediately +immigrants +immigration +immune +immunology +impact +impacts +impaired +imperial +implement +implementation +implemented +implementing +implications +implied +implies +import +importance +important +importantly +imported +imports +impose +imposed +impossible +impressed +impression +impressive +improve +improved +improvement +improvements +improving +inappropriate +inbox +incentive +incentives +inch +inches +incidence +incident +incidents +incl +include +included +includes +including +inclusion +inclusive +income +incoming +incomplete +incorporate +incorporated +incorrect +increase +increased +increases +increasing +increasingly +incredible +incurred +indeed +independence +independent +independently +index +indexed +indexes +india +indian +indiana +indianapolis +indians +indicate +indicated +indicates +indicating +indication +indicator +indicators +indices +indie +indigenous +indirect +individual +individually +individuals +indonesia +indonesian +indoor +induced +induction +industrial +industries +industry +inexpensive +infant +infants +infected +infection +infections +infectious +infinite +inflation +influence +influenced +influences +info +inform +informal +information +informational +informative +informed +infrared +infrastructure +infringement +ingredients +inherited +initial +initially +initiated +initiative +initiatives +injection +injured +injuries +injury +inkjet +inline +inner +innocent +innovation +innovations +innovative +inns +input +inputs +inquire +inquiries +inquiry +insects +insert +inserted +insertion +inside +insider +insight +insights +inspection +inspections +inspector +inspiration +inspired +install +installation +installations +installed +installing +instance +instances +instant +instantly +instead +institute +institutes +institution +institutional +institutions +instruction +instructional +instructions +instructor +instructors +instrument +instrumental +instrumentation +instruments +insulation +insulin +insurance +insured +intake +integer +integral +integrate +integrated +integrating +integration +integrity +intel +intellectual +intelligence +intelligent +intend +intended +intense +intensity +intensive +intent +intention +inter +interact +interaction +interactions +interactive +interest +interested +interesting +interests +interface +interfaces +interference +interim +interior +intermediate +internal +international +internationally +internet +internship +interpretation +interpreted +interracial +intersection +interstate +interval +intervals +intervention +interventions +interview +interviews +intimate +intl +into +intranet +intro +introduce +introduced +introduces +introducing +introduction +introductory +invalid +invasion +invention +inventory +invest +investigate +investigated +investigation +investigations +investigator +investigators +investing +investment +investments +investor +investors +invisible +invision +invitation +invitations +invite +invited +invoice +involve +involved +involvement +involves +involving +iowa +ipaq +ipod +iran +iraq +iraqi +ireland +irish +iron +irrigation +isaac +isbn +islam +islamic +island +islands +isle +isolated +isolation +israel +israeli +issn +issue +issued +issues +istanbul +italia +italian +italiano +italic +italy +item +items +itself +itunes +ivory +jack +jacket +jackets +jackie +jackson +jacksonville +jacob +jade +jaguar +jail +jake +jamaica +james +jamie +jane +janet +january +japan +japanese +jason +java +javascript +jazz +jean +jeans +jeep +jeff +jefferson +jeffrey +jelsoft +jennifer +jenny +jeremy +jerry +jersey +jerusalem +jesse +jessica +jesus +jets +jewel +jewellery +jewelry +jewish +jews +jill +jimmy +joan +jobs +joel +john +johnny +johns +johnson +johnston +join +joined +joining +joins +joint +joke +jokes +jonathan +jones +jordan +jose +joseph +josh +joshua +journal +journalism +journalist +journalists +journals +journey +joyce +jpeg +juan +judge +judges +judgment +judicial +judy +juice +julia +julian +julie +july +jump +jumping +junction +june +jungle +junior +junk +jurisdiction +jury +just +justice +justify +justin +juvenile +kansas +karaoke +karen +karl +karma +kate +kathy +katie +katrina +kazakhstan +keen +keep +keeping +keeps +keith +kelkoo +kelly +kennedy +kenneth +kenny +keno +kent +kentucky +kenya +kept +kernel +kerry +kevin +keyboard +keyboards +keys +keyword +keywords +kick +kidney +kids +kijiji +kill +killed +killer +killing +kills +kilometers +kinase +kind +kinda +kinds +king +kingdom +kings +kingston +kirk +kiss +kissing +kitchen +kits +kitty +klein +knee +knew +knife +knight +knights +knit +knitting +knives +knock +know +knowing +knowledge +knowledgestorm +known +knows +kodak +kong +korea +korean +kruger +kurt +kuwait +kyle +label +labeled +labels +labor +laboratories +laboratory +labour +labs +lace +lack +ladder +laden +ladies +lady +lafayette +laid +lake +lakes +lamb +lambda +lamp +lamps +lancaster +lance +land +landing +lands +landscape +landscapes +lane +lanes +lang +language +languages +lanka +laos +laptop +laptops +large +largely +larger +largest +larry +laser +last +lasting +late +lately +later +latest +latex +latin +latina +latinas +latino +latitude +latter +latvia +lauderdale +laugh +laughing +launch +launched +launches +laundry +laura +lauren +lawn +lawrence +laws +lawsuit +lawyer +lawyers +layer +layers +layout +lazy +lead +leader +leaders +leadership +leading +leads +leaf +league +lean +learn +learned +learners +learning +lease +leasing +least +leather +leave +leaves +leaving +lebanon +lecture +lectures +leeds +left +legacy +legal +legally +legend +legendary +legends +legislation +legislative +legislature +legitimate +legs +leisure +lemon +lender +lenders +lending +length +lens +lenses +leon +leonard +leone +lesbian +lesbians +leslie +less +lesser +lesson +lessons +lets +letter +letters +letting +level +levels +levitra +levy +lewis +lexington +lexmark +lexus +liabilities +liability +liable +liberal +liberia +liberty +librarian +libraries +library +libs +licence +license +licensed +licenses +licensing +licking +liechtenstein +lies +life +lifestyle +lifetime +lift +light +lightbox +lighter +lighting +lightning +lights +lightweight +like +liked +likelihood +likely +likes +likewise +lime +limit +limitation +limitations +limited +limiting +limits +limousines +lincoln +linda +lindsay +line +linear +lined +lines +lingerie +link +linked +linking +links +linux +lion +lions +lips +liquid +lisa +list +listed +listen +listening +listing +listings +listprice +lists +lite +literacy +literally +literary +literature +lithuania +litigation +little +live +livecam +lived +liver +liverpool +lives +livestock +living +lloyd +load +loaded +loading +loads +loan +loans +lobby +local +locale +locally +locate +located +location +locations +locator +lock +locked +locking +locks +lodge +lodging +logan +logged +logging +logic +logical +login +logistics +logitech +logo +logos +logs +london +lone +lonely +long +longer +longest +longitude +look +looked +looking +looks +looksmart +lookup +loop +loops +loose +lopez +lord +lose +losing +loss +losses +lost +lots +lottery +lotus +loud +louis +louise +louisiana +louisville +lounge +love +loved +lovely +lover +lovers +loves +loving +lower +lowest +lows +lucas +lucia +luck +lucky +lucy +luggage +luis +luke +lunch +lung +luther +luxembourg +luxury +lycos +lying +lynn +lyric +lyrics +macedonia +machine +machinery +machines +macintosh +macro +macromedia +madagascar +made +madison +madness +madonna +madrid +magazine +magazines +magic +magical +magnet +magnetic +magnificent +magnitude +maiden +mail +mailed +mailing +mailman +mails +mailto +main +maine +mainland +mainly +mainstream +maintain +maintained +maintaining +maintains +maintenance +major +majority +make +maker +makers +makes +makeup +making +malawi +malaysia +maldives +male +males +mali +mall +malpractice +malta +mambo +manage +managed +management +manager +managers +managing +manchester +mandate +mandatory +manga +manhattan +manitoba +manner +manor +manual +manually +manuals +manufacture +manufactured +manufacturer +manufacturers +manufacturing +many +maple +mapping +maps +marathon +marble +marc +march +marco +marcus +mardi +margaret +margin +maria +mariah +marie +marijuana +marilyn +marina +marine +mario +marion +maritime +mark +marked +marker +markers +market +marketing +marketplace +markets +marking +marks +marriage +married +marriott +mars +marsh +marshall +mart +martha +martial +martin +marvel +mary +maryland +mask +mason +mass +massachusetts +massage +massive +master +mastercard +masters +masturbating +masturbation +match +matched +matches +matching +mate +material +materials +maternity +math +mathematical +mathematics +mating +matrix +mats +matt +matter +matters +matthew +mattress +mature +maui +mauritius +maximize +maximum +maybe +mayor +mazda +mcdonald +meal +meals +mean +meaning +meaningful +means +meant +meanwhile +measure +measured +measurement +measurements +measures +measuring +meat +mechanical +mechanics +mechanism +mechanisms +medal +media +median +mediawiki +medicaid +medical +medicare +medication +medications +medicine +medicines +medieval +meditation +mediterranean +medium +medline +meet +meeting +meetings +meets +meetup +mega +melbourne +melissa +member +members +membership +membrane +memo +memorabilia +memorial +memories +memory +memphis +mens +ment +mental +mention +mentioned +mentor +menu +menus +mercedes +merchandise +merchant +merchants +mercury +mercy +mere +merely +merge +merger +merit +merry +mesa +mesh +mess +message +messages +messaging +messenger +meta +metabolism +metadata +metal +metallic +metallica +metals +meter +meters +method +methodology +methods +metres +metric +metro +metropolitan +mexican +mexico +meyer +miami +mice +michael +michel +michelle +michigan +micro +microphone +microsoft +microwave +middle +midi +midlands +midnight +midwest +might +mighty +migration +mike +milan +mild +mile +mileage +miles +military +milk +mill +millennium +miller +million +millions +mills +milton +milwaukee +mime +mind +minds +mine +mineral +minerals +mines +mini +miniature +minimal +minimize +minimum +mining +minister +ministers +ministries +ministry +minneapolis +minnesota +minolta +minor +minority +mins +mint +minus +minute +minutes +miracle +mirror +mirrors +misc +miscellaneous +miss +missed +missile +missing +mission +missions +mississippi +missouri +mistake +mistakes +mistress +mitchell +mitsubishi +mixed +mixer +mixing +mixture +mobile +mobiles +mobility +mode +model +modeling +modelling +models +modem +modems +moderate +moderator +moderators +modern +modes +modification +modifications +modified +modify +mods +modular +module +modules +moisture +mold +moldova +molecular +molecules +moment +moments +momentum +moms +monaco +monday +monetary +money +mongolia +monica +monitor +monitored +monitoring +monitors +monkey +mono +monroe +monster +monsters +montana +monte +montgomery +month +monthly +months +montreal +mood +moon +moore +moral +more +moreover +morgan +morning +morocco +morris +morrison +mortality +mortgage +mortgages +moscow +moses +moss +most +mostly +motel +motels +mother +motherboard +mothers +motion +motivated +motivation +motor +motorcycle +motorcycles +motorola +motors +mount +mountain +mountains +mounted +mounting +mounts +mouse +mouth +move +moved +movement +movements +movers +moves +movie +movies +moving +mozambique +mozilla +mpeg +mpegs +mrna +msgid +msgstr +msie +much +multi +multimedia +multiple +mumbai +munich +municipal +municipality +murder +murphy +murray +muscle +muscles +museum +museums +music +musical +musician +musicians +muslim +muslims +must +mustang +mutual +muze +myanmar +myers +myrtle +myself +mysimon +myspace +mysql +mysterious +mystery +myth +nail +nails +naked +name +named +namely +names +namespace +namibia +nancy +nano +naples +narrative +narrow +nasa +nascar +nasdaq +nashville +nasty +nathan +nation +national +nationally +nations +nationwide +native +nato +natural +naturally +naturals +nature +naughty +naval +navigate +navigation +navigator +navy +ncaa +near +nearby +nearest +nearly +nebraska +necessarily +necessary +necessity +neck +necklace +need +needed +needle +needs +negative +negotiation +negotiations +neighbor +neighborhood +neighbors +neil +neither +nelson +neon +nepal +nerve +nervous +nest +nested +netherlands +netscape +network +networking +networks +neural +neutral +nevada +never +nevertheless +newark +newbie +newcastle +newer +newest +newfoundland +newly +newman +newport +news +newsletter +newsletters +newspaper +newspapers +newton +next +nextel +niagara +nicaragua +nice +nicholas +nick +nickel +nickname +nicole +niger +nigeria +night +nightlife +nightmare +nights +nike +nikon +nine +nintendo +nirvana +nissan +nitrogen +noble +nobody +node +nodes +noise +nokia +nominated +nomination +nominations +none +nonprofit +noon +norfolk +norm +normal +normally +norman +north +northeast +northern +northwest +norton +norway +norwegian +nose +note +notebook +notebooks +noted +notes +nothing +notice +noticed +notices +notification +notifications +notified +notify +notion +notre +nottingham +nova +novel +novels +novelty +november +nowhere +ntsc +nuclear +nudist +nuke +null +number +numbers +numeric +numerical +numerous +nurse +nursery +nurses +nursing +nutrition +nutritional +nuts +nutten +nvidia +nylon +oakland +oaks +oasis +obesity +obituaries +object +objective +objectives +objects +obligation +obligations +observation +observations +observe +observed +observer +obtain +obtained +obtaining +obvious +obviously +occasion +occasional +occasionally +occasions +occupation +occupational +occupations +occupied +occur +occurred +occurrence +occurring +occurs +ocean +oclc +october +odds +oecd +offense +offensive +offer +offered +offering +offerings +offers +office +officer +officers +offices +official +officially +officials +offline +offset +offshore +often +ohio +oils +okay +oklahoma +older +oldest +olive +oliver +olympic +olympics +olympus +omaha +oman +omega +omissions +once +ones +ongoing +onion +online +only +ontario +onto +oops +open +opened +opening +openings +opens +opera +operate +operated +operates +operating +operation +operational +operations +operator +operators +opinion +opinions +opponent +opponents +opportunities +opportunity +opposed +opposite +opposition +optical +optics +optimal +optimization +optimize +optimum +option +optional +options +oracle +oral +orange +orbit +orchestra +order +ordered +ordering +orders +ordinance +ordinary +oregon +organ +organic +organisation +organisations +organised +organisms +organization +organizational +organizations +organize +organized +organizer +organizing +oriental +orientation +oriented +origin +original +originally +origins +orlando +orleans +oscar +other +others +otherwise +ottawa +ought +ours +ourselves +outcome +outcomes +outdoor +outdoors +outer +outlet +outlets +outline +outlined +outlook +output +outputs +outreach +outside +outsourcing +outstanding +oval +oven +over +overall +overcome +overhead +overnight +overseas +overview +owen +owned +owner +owners +ownership +owns +oxford +oxide +oxygen +ozone +pace +pacific +pack +package +packages +packaging +packard +packed +packet +packets +packing +packs +pads +page +pages +paid +pain +painful +paint +paintball +painted +painting +paintings +pair +pairs +pakistan +palace +pale +palestine +palestinian +palm +palmer +pamela +panama +panasonic +panel +panels +panic +pants +pantyhose +paper +paperback +paperbacks +papers +papua +para +parade +paradise +paragraph +paragraphs +paraguay +parallel +parameter +parameters +parcel +parent +parental +parenting +parents +paris +parish +park +parker +parking +parks +parliament +parliamentary +part +partial +partially +participant +participants +participate +participated +participating +participation +particle +particles +particular +particularly +parties +partition +partly +partner +partners +partnership +partnerships +parts +party +paso +pass +passage +passed +passenger +passengers +passes +passing +passion +passive +passport +password +passwords +past +pasta +paste +pastor +patch +patches +patent +patents +path +pathology +paths +patient +patients +patio +patricia +patrick +patrol +pattern +patterns +paul +pavilion +paxil +payable +payday +paying +payment +payments +paypal +payroll +pays +pdas +peace +peaceful +peak +pearl +peas +pediatric +peeing +peer +peers +penalties +penalty +pencil +pendant +pending +penetration +penguin +peninsula +penn +pennsylvania +penny +pens +pension +pensions +pentium +people +peoples +pepper +perceived +percent +percentage +perception +perfect +perfectly +perform +performance +performances +performed +performer +performing +performs +perfume +perhaps +period +periodic +periodically +periods +peripheral +peripherals +perl +permalink +permanent +permission +permissions +permit +permits +permitted +perry +persian +persistent +person +personal +personality +personalized +personally +personals +personnel +persons +perspective +perspectives +perth +peru +pest +pete +peter +petersburg +peterson +petite +petition +petroleum +pets +phantom +pharmaceutical +pharmaceuticals +pharmacies +pharmacology +pharmacy +phase +phases +phenomenon +phentermine +phil +philadelphia +philip +philippines +philips +phillips +philosophy +phoenix +phone +phones +photo +photograph +photographer +photographers +photographic +photographs +photography +photos +photoshop +phpbb +phrase +phrases +phys +physical +physically +physician +physicians +physics +physiology +piano +pichunter +pick +picked +picking +picks +pickup +picnic +pics +picture +pictures +piece +pieces +pierce +pierre +pike +pill +pillow +pills +pilot +pine +ping +pink +pins +pioneer +pipe +pipeline +pipes +pirates +pitch +pittsburgh +pixel +pixels +pizza +place +placed +placement +places +placing +plain +plains +plaintiff +plan +plane +planes +planet +planets +planned +planner +planners +planning +plans +plant +plants +plasma +plastic +plastics +plate +plates +platform +platforms +platinum +play +playback +played +player +players +playing +playlist +plays +playstation +plaza +pleasant +please +pleased +pleasure +pledge +plenty +plot +plots +plug +plugin +plugins +plumbing +plus +plymouth +pmid +pocket +pockets +podcast +podcasts +poem +poems +poet +poetry +point +pointed +pointer +pointing +points +poison +pokemon +poker +poland +polar +pole +police +policies +policy +polish +polished +political +politicians +politics +poll +polls +pollution +polo +poly +polyester +polymer +polyphonic +pond +pontiac +pool +pools +poor +pope +popular +popularity +population +populations +porcelain +pork +porsche +port +portable +portal +porter +portfolio +portion +portions +portland +portrait +portraits +ports +portsmouth +portugal +portuguese +pose +posing +position +positioning +positions +positive +possess +possession +possibilities +possibility +possible +possibly +post +postage +postal +postcard +postcards +posted +poster +posters +posting +postings +postposted +posts +potato +potatoes +potential +potentially +potter +pottery +poultry +pound +pounds +pour +poverty +powder +powell +power +powered +powerful +powerpoint +powers +powerseller +practical +practice +practices +practitioner +practitioners +prague +prairie +praise +pray +prayer +prayers +preceding +precious +precipitation +precise +precisely +precision +predict +predicted +prediction +predictions +prefer +preference +preferences +preferred +prefers +prefix +pregnancy +pregnant +preliminary +premier +premiere +premises +premium +prep +prepaid +preparation +prepare +prepared +preparing +prerequisite +prescribed +prescription +presence +present +presentation +presentations +presented +presenting +presently +presents +preservation +preserve +president +presidential +press +pressed +pressing +pressure +preston +pretty +prev +prevent +preventing +prevention +preview +previews +previous +previously +price +priced +prices +pricing +pride +priest +primarily +primary +prime +prince +princess +princeton +principal +principle +principles +print +printable +printed +printer +printers +printing +prints +prior +priorities +priority +prison +prisoner +prisoners +privacy +private +privilege +privileges +prix +prize +prizes +probability +probably +probe +problem +problems +proc +procedure +procedures +proceed +proceeding +proceedings +proceeds +process +processed +processes +processing +processor +processors +procurement +produce +produced +producer +producers +produces +producing +product +production +productions +productive +productivity +products +profession +professional +professionals +professor +profile +profiles +profit +profits +program +programme +programmer +programmers +programmes +programming +programs +progress +progressive +prohibited +project +projected +projection +projector +projectors +projects +prominent +promise +promised +promises +promising +promo +promote +promoted +promotes +promoting +promotion +promotional +promotions +prompt +promptly +proof +propecia +proper +properly +properties +property +prophet +proportion +proposal +proposals +propose +proposed +proposition +proprietary +pros +prospect +prospective +prospects +prostate +prostores +prot +protect +protected +protecting +protection +protective +protein +proteins +protest +protocol +protocols +prototype +proud +proudly +prove +proved +proven +provide +provided +providence +provider +providers +provides +providing +province +provinces +provincial +provision +provisions +proxy +prozac +psychiatry +psychological +psychology +public +publication +publications +publicity +publicly +publish +published +publisher +publishers +publishing +pubmed +pubs +puerto +pull +pulled +pulling +pulse +pump +pumps +punch +punishment +punk +pupils +puppy +purchase +purchased +purchases +purchasing +pure +purple +purpose +purposes +purse +pursuant +pursue +pursuit +push +pushed +pushing +puts +putting +puzzle +puzzles +python +qatar +quad +qualification +qualifications +qualified +qualify +qualifying +qualities +quality +quantitative +quantities +quantity +quantum +quarter +quarterly +quarters +quebec +queen +queens +queensland +queries +query +quest +question +questionnaire +questions +queue +quick +quickly +quiet +quilt +quit +quite +quiz +quizzes +quotations +quote +quoted +quotes +rabbit +race +races +rachel +racial +racing +rack +racks +radar +radiation +radical +radio +radios +radius +rage +raid +rail +railroad +railway +rain +rainbow +raise +raised +raises +raising +raleigh +rally +ralph +ranch +rand +random +randy +range +ranger +rangers +ranges +ranging +rank +ranked +ranking +rankings +ranks +rapid +rapidly +rapids +rare +rarely +rate +rated +rates +rather +rating +ratings +ratio +rational +ratios +rats +raymond +rays +reach +reached +reaches +reaching +reaction +reactions +read +reader +readers +readily +reading +readings +reads +ready +real +realistic +reality +realize +realized +really +realm +realtor +realtors +realty +rear +reason +reasonable +reasonably +reasoning +reasons +rebate +rebates +rebecca +rebel +rebound +recall +receipt +receive +received +receiver +receivers +receives +receiving +recent +recently +reception +receptor +receptors +recipe +recipes +recipient +recipients +recognised +recognition +recognize +recognized +recommend +recommendation +recommendations +recommended +recommends +reconstruction +record +recorded +recorder +recorders +recording +recordings +records +recover +recovered +recovery +recreation +recreational +recruiting +recruitment +recycling +redeem +redhead +reduce +reduced +reduces +reducing +reduction +reductions +reed +reef +reel +refer +reference +referenced +references +referral +referrals +referred +referring +refers +refinance +refine +refined +reflect +reflected +reflection +reflections +reflects +reform +reforms +refresh +refrigerator +refugees +refund +refurbished +refuse +refused +regard +regarded +regarding +regardless +regards +reggae +regime +region +regional +regions +register +registered +registrar +registration +registry +regression +regular +regularly +regulated +regulation +regulations +regulatory +rehab +rehabilitation +reid +reject +rejected +relate +related +relates +relating +relation +relations +relationship +relationships +relative +relatively +relatives +relax +relaxation +relay +release +released +releases +relevance +relevant +reliability +reliable +reliance +relief +religion +religions +religious +reload +relocation +rely +relying +remain +remainder +remained +remaining +remains +remark +remarkable +remarks +remedies +remedy +remember +remembered +remind +reminder +remix +remote +removable +removal +remove +removed +removing +renaissance +render +rendered +rendering +renew +renewable +renewal +reno +rent +rental +rentals +repair +repairs +repeat +repeated +replace +replaced +replacement +replacing +replica +replication +replied +replies +reply +report +reported +reporter +reporters +reporting +reports +repository +represent +representation +representations +representative +representatives +represented +representing +represents +reprint +reprints +reproduce +reproduced +reproduction +reproductive +republic +republican +republicans +reputation +request +requested +requesting +requests +require +required +requirement +requirements +requires +requiring +rescue +research +researcher +researchers +reseller +reservation +reservations +reserve +reserved +reserves +reservoir +reset +residence +resident +residential +residents +resist +resistance +resistant +resolution +resolutions +resolve +resolved +resort +resorts +resource +resources +respect +respected +respective +respectively +respiratory +respond +responded +respondent +respondents +responding +response +responses +responsibilities +responsibility +responsible +rest +restaurant +restaurants +restoration +restore +restored +restrict +restricted +restriction +restrictions +restructuring +result +resulted +resulting +results +resume +resumes +retail +retailer +retailers +retain +retained +retention +retired +retirement +retreat +retrieval +retrieve +retrieved +retro +return +returned +returning +returns +reunion +reuters +reveal +revealed +reveals +revelation +revenge +revenue +revenues +reverse +review +reviewed +reviewer +reviewing +reviews +revised +revision +revisions +revolution +revolutionary +reward +rewards +reynolds +rhode +rhythm +ribbon +rica +rice +rich +richard +richards +richardson +richmond +rick +ricky +rico +ride +rider +riders +rides +ridge +riding +right +rights +ring +rings +ringtone +ringtones +ripe +rise +rising +risk +risks +river +rivers +riverside +road +roads +robbie +robert +roberts +robertson +robin +robinson +robot +robots +robust +rochester +rock +rocket +rocks +rocky +roger +rogers +roland +role +roles +roll +rolled +roller +rolling +rolls +roman +romance +romania +romantic +rome +ronald +roof +room +roommate +roommates +rooms +root +roots +rope +rosa +rose +roses +ross +roster +rotary +rotation +rouge +rough +roughly +roulette +round +rounds +route +router +routers +routes +routine +routines +routing +rover +rows +royal +royalty +rubber +ruby +rugby +rugs +rule +ruled +rules +ruling +runner +running +runs +runtime +rural +rush +russell +russia +russian +ruth +rwanda +ryan +sacramento +sacred +sacrifice +saddam +safari +safe +safely +safer +safety +sage +sagem +said +sail +sailing +saint +saints +sake +salad +salaries +salary +sale +salem +sales +sally +salmon +salon +salt +salvador +salvation +samba +same +samoa +sample +samples +sampling +samsung +samuel +sand +sandra +sandwich +sandy +sans +santa +sanyo +sapphire +sara +sarah +saskatchewan +satellite +satin +satisfaction +satisfactory +satisfied +satisfy +saturday +saturn +sauce +saudi +savage +savannah +save +saved +saver +saves +saving +savings +saying +says +sbjct +scale +scales +scan +scanned +scanner +scanners +scanning +scared +scary +scenario +scenarios +scene +scenes +scenic +schedule +scheduled +schedules +scheduling +schema +scheme +schemes +scholar +scholars +scholarship +scholarships +school +schools +science +sciences +scientific +scientist +scientists +scoop +scope +score +scored +scores +scoring +scotia +scotland +scott +scottish +scout +scratch +screen +screening +screens +screensaver +screensavers +screenshot +screenshots +screw +script +scripting +scripts +scroll +scsi +scuba +sculpture +seafood +seal +sealed +sean +search +searched +searches +searching +seas +season +seasonal +seasons +seat +seating +seats +seattle +second +secondary +seconds +secret +secretariat +secretary +secrets +section +sections +sector +sectors +secure +secured +securely +securities +security +seed +seeds +seeing +seek +seeker +seekers +seeking +seeks +seem +seemed +seems +seen +sees +sega +segment +segments +select +selected +selecting +selection +selections +selective +self +sell +seller +sellers +selling +sells +semester +semi +semiconductor +seminar +seminars +senate +senator +senators +send +sender +sending +sends +senegal +senior +seniors +sense +sensitive +sensitivity +sensor +sensors +sent +sentence +sentences +separate +separated +separately +separation +sept +september +sequence +sequences +serbia +serial +series +serious +seriously +serum +serve +served +server +servers +serves +service +services +serving +session +sessions +sets +setting +settings +settle +settled +settlement +setup +seven +seventh +several +severe +sewing +sexual +sexuality +sexually +shade +shades +shadow +shadows +shaft +shake +shakespeare +shakira +shall +shame +shanghai +shannon +shape +shaped +shapes +share +shared +shareholders +shares +shareware +sharing +shark +sharon +sharp +shaved +shaw +shed +sheep +sheer +sheet +sheets +sheffield +shelf +shell +shelter +shepherd +sheriff +sherman +shield +shift +shine +ship +shipment +shipments +shipped +shipping +ships +shirt +shirts +shock +shoe +shoes +shoot +shooting +shop +shopper +shoppers +shopping +shops +shopzilla +shore +short +shortcuts +shorter +shortly +shorts +shot +shots +should +shoulder +show +showcase +showed +shower +showers +showing +shown +shows +showtimes +shut +shuttle +sick +side +sides +siemens +sierra +sight +sigma +sign +signal +signals +signature +signatures +signed +significance +significant +significantly +signing +signs +signup +silence +silent +silicon +silk +silly +silver +similar +similarly +simon +simple +simplified +simply +simpson +simpsons +sims +simulation +simulations +simultaneously +since +sing +singapore +singer +singh +singing +single +singles +sink +sister +sisters +site +sitemap +sites +sitting +situated +situation +situations +sixth +size +sized +sizes +skating +skiing +skill +skilled +skills +skin +skins +skip +skirt +skirts +skype +slave +sleep +sleeping +sleeps +sleeve +slide +slides +slideshow +slight +slightly +slim +slip +slope +slot +slots +slovak +slovakia +slovenia +slow +slowly +small +smaller +smallest +smart +smell +smile +smilies +smith +smithsonian +smoke +smoking +smooth +smtp +snake +snap +snapshot +snow +snowboard +soap +soccer +social +societies +society +sociology +socket +socks +sodium +sofa +soft +softball +software +soil +solar +solaris +sold +soldier +soldiers +sole +solely +solid +solo +solomon +solution +solutions +solve +solved +solving +soma +somalia +some +somebody +somehow +someone +somerset +something +sometimes +somewhat +somewhere +song +songs +sonic +sons +sony +soon +soonest +sophisticated +sorry +sort +sorted +sorts +sought +soul +souls +sound +sounds +soundtrack +soup +source +sources +south +southampton +southeast +southern +southwest +soviet +space +spaces +spain +spam +span +spanish +spank +spanking +sparc +spare +spas +spatial +speak +speaker +speakers +speaking +speaks +spears +spec +special +specialist +specialists +specialized +specializing +specially +specials +specialties +specialty +species +specific +specifically +specification +specifications +specifics +specified +specifies +specify +specs +spectacular +spectrum +speech +speeches +speed +speeds +spell +spelling +spencer +spend +spending +spent +sperm +sphere +spice +spider +spies +spin +spine +spirit +spirits +spiritual +spirituality +split +spoke +spoken +spokesman +sponsor +sponsored +sponsors +sponsorship +sport +sporting +sports +spot +spotlight +spots +spouse +spray +spread +spreading +spring +springer +springfield +springs +sprint +spyware +squad +square +stability +stable +stack +stadium +staff +staffing +stage +stages +stainless +stake +stakeholders +stamp +stamps +stan +stand +standard +standards +standing +standings +stands +stanford +stanley +star +starring +stars +starsmerchant +start +started +starter +starting +starts +startup +stat +state +stated +statement +statements +states +statewide +static +stating +station +stationery +stations +statistical +statistics +stats +status +statute +statutes +statutory +stay +stayed +staying +stays +steady +steal +steam +steel +steering +stem +step +stephanie +stephen +steps +stereo +sterling +steve +steven +stevens +stewart +stick +sticker +stickers +sticks +sticky +still +stock +stockholm +stockings +stocks +stolen +stomach +stone +stones +stood +stop +stopped +stopping +stops +storage +store +stored +stores +stories +storm +story +straight +strain +strand +strange +stranger +strap +strategic +strategies +strategy +stream +streaming +streams +street +streets +strength +strengthen +strengthening +strengths +stress +stretch +strict +strictly +strike +strikes +striking +string +strings +strip +stripes +strips +stroke +strong +stronger +strongly +struck +struct +structural +structure +structured +structures +struggle +stuart +stuck +stud +student +students +studied +studies +studio +studios +study +studying +stuff +stuffed +stunning +stupid +style +styles +stylish +stylus +subaru +subcommittee +subdivision +subject +subjective +subjects +sublime +submission +submissions +submit +submitted +submitting +subscribe +subscriber +subscribers +subscription +subscriptions +subsection +subsequent +subsequently +subsidiaries +subsidiary +substance +substances +substantial +substantially +substitute +subtle +suburban +succeed +success +successful +successfully +such +sucking +sudan +sudden +suddenly +suffer +suffered +suffering +sufficient +sufficiently +sugar +suggest +suggested +suggesting +suggestion +suggestions +suggests +suicide +suit +suitable +suite +suited +suites +suits +sullivan +summaries +summary +summer +summit +sunday +sunglasses +sunny +sunrise +sunset +sunshine +super +superb +superintendent +superior +supervision +supervisor +supervisors +supplement +supplemental +supplements +supplied +supplier +suppliers +supplies +supply +support +supported +supporters +supporting +supports +suppose +supposed +supreme +sure +surely +surf +surface +surfaces +surfing +surge +surgeon +surgeons +surgery +surgical +surname +surplus +surprise +surprised +surprising +surrey +surround +surrounded +surrounding +surveillance +survey +surveys +survival +survive +survivor +survivors +susan +suse +suspect +suspected +suspended +suspension +sussex +sustainability +sustainable +sustained +suzuki +swap +swaziland +sweden +swedish +sweet +swift +swim +swimming +swing +swingers +swiss +switch +switched +switches +switching +switzerland +sword +sydney +symantec +symbol +symbols +sympathy +symphony +symposium +symptoms +sync +syndicate +syndication +syndrome +synopsis +syntax +synthesis +synthetic +syracuse +syria +system +systematic +systems +table +tables +tablet +tablets +tabs +tackle +tactics +tagged +tags +tahoe +tail +taiwan +take +taken +takes +taking +tale +talent +talented +tales +talk +talked +talking +talks +tall +tamil +tampa +tank +tanks +tanzania +tape +tapes +target +targeted +targets +tariff +task +tasks +taste +tattoo +taught +taxation +taxes +taxi +taylor +teach +teacher +teachers +teaches +teaching +team +teams +tear +tears +tech +technical +technician +technique +techniques +techno +technological +technologies +technology +techrepublic +teddy +teen +teenage +teens +teeth +telecharger +telecom +telecommunications +telephone +telephony +telescope +television +televisions +tell +telling +tells +temp +temperature +temperatures +template +templates +temple +temporal +temporarily +temporary +tenant +tend +tender +tennessee +tennis +tension +tent +term +terminal +terminals +termination +terminology +terms +terrace +terrain +terrible +territories +territory +terror +terrorism +terrorist +terrorists +terry +test +testament +tested +testimonials +testimony +testing +tests +texas +text +textbook +textbooks +textile +textiles +texts +texture +thai +thailand +than +thank +thanks +thanksgiving +that +thats +theater +theaters +theatre +thee +theft +thehun +their +them +theme +themes +themselves +then +theology +theorem +theoretical +theories +theory +therapeutic +therapist +therapy +there +thereafter +thereby +therefore +thereof +thermal +thesaurus +these +thesis +theta +they +thick +thickness +thin +thing +things +think +thinking +thinkpad +thinks +third +thirty +this +thomas +thompson +thomson +thong +thongs +thorough +thoroughly +those +thou +though +thought +thoughts +thousand +thousands +thread +threaded +threads +threat +threatened +threatening +threats +three +threshold +thriller +throat +through +throughout +throw +throwing +thrown +throws +thru +thumb +thumbnail +thumbnails +thumbs +thumbzilla +thunder +thursday +thus +ticket +tickets +tide +tied +tier +ties +tiffany +tiger +tigers +tight +tile +tiles +till +timber +time +timeline +timely +timer +times +timing +timothy +tiny +tion +tions +tips +tire +tired +tires +tissue +titanium +titans +title +titled +titles +titten +tobacco +tobago +today +todd +toddler +together +toilet +token +tokyo +told +tolerance +toll +tomato +tomatoes +tommy +tomorrow +tone +toner +tones +tongue +tonight +tons +tony +took +tool +toolbar +toolbox +toolkit +tools +tooth +topic +topics +tops +toronto +torture +toshiba +total +totally +totals +touch +touched +tough +tour +touring +tourism +tourist +tournament +tournaments +tours +toward +towards +tower +towers +town +towns +township +toxic +toyota +toys +trace +track +trackback +trackbacks +tracked +tracker +tracking +tracks +tract +tractor +tracy +trade +trademark +trademarks +trader +trades +trading +tradition +traditional +traditions +traffic +tragedy +trail +trailer +trailers +trails +train +trained +trainer +trainers +training +trains +tramadol +trance +trans +transaction +transactions +transcript +transcription +transcripts +transexual +transexuales +transfer +transferred +transfers +transform +transformation +transit +transition +translate +translated +translation +translations +translator +transmission +transmit +transmitted +transparency +transparent +transport +transportation +transsexual +trap +trash +trauma +travel +traveler +travelers +traveling +traveller +travelling +travels +travesti +travis +tray +treasure +treasurer +treasures +treasury +treat +treated +treating +treatment +treatments +treaty +tree +trees +trek +trembl +tremendous +trend +trends +treo +trial +trials +triangle +tribal +tribe +tribes +tribunal +tribune +tribute +trick +tricks +tried +tries +trigger +trim +trinidad +trinity +trio +trip +tripadvisor +triple +trips +triumph +trivia +troops +tropical +trouble +troubleshooting +trout +troy +truck +trucks +true +truly +trunk +trust +trusted +trustee +trustees +trusts +truth +trying +tsunami +tube +tubes +tucson +tuesday +tuition +tulsa +tumor +tune +tuner +tunes +tuning +tunisia +tunnel +turbo +turkey +turkish +turn +turned +turner +turning +turns +turtle +tutorial +tutorials +twelve +twenty +twice +twiki +twin +twins +twist +twisted +tyler +type +types +typical +typically +typing +uganda +ugly +ukraine +ultimate +ultimately +ultra +ultram +unable +unauthorized +unavailable +uncertainty +uncle +undefined +under +undergraduate +underground +underlying +understand +understanding +understood +undertake +undertaken +underwear +undo +unemployment +unexpected +unfortunately +unified +uniform +union +unions +uniprotkb +unique +unit +united +units +unity +univ +universal +universe +universities +university +unix +unknown +unless +unlike +unlikely +unlimited +unlock +unnecessary +unsigned +unsubscribe +until +untitled +unto +unusual +unwrap +upcoming +update +updated +updates +updating +upgrade +upgrades +upgrading +upload +uploaded +upon +upper +upset +urban +urge +urgent +urls +uruguay +usage +usda +used +useful +user +username +users +uses +usgs +using +usps +usual +usually +utah +utilities +utility +utilization +utilize +utils +uzbekistan +vacancies +vacation +vacations +vaccine +vacuum +valentine +valid +validation +validity +valium +valley +valuable +valuation +value +valued +values +valve +valves +vampire +vancouver +vanilla +variable +variables +variance +variation +variations +varied +varies +varieties +variety +various +vary +varying +vast +vatican +vault +vbulletin +vector +vegas +vegetable +vegetables +vegetarian +vegetation +vehicle +vehicles +velocity +velvet +vendor +vendors +venezuela +venice +venture +ventures +venue +venues +verbal +verde +verification +verified +verify +verizon +vermont +vernon +verse +version +versions +versus +vertex +vertical +very +verzeichnis +vessel +vessels +veteran +veterans +veterinary +vice +victim +victims +victor +victoria +victorian +victory +video +videos +vids +vienna +vietnam +vietnamese +view +viewed +viewer +viewers +viewing +viewpicture +views +viii +viking +villa +village +villages +villas +vincent +vintage +vinyl +violation +violations +violence +violent +violin +viral +virgin +virginia +virtual +virtually +virtue +virus +viruses +visa +visibility +visible +vision +visit +visited +visiting +visitor +visitors +visits +vista +visual +vital +vitamin +vitamins +vocabulary +vocal +vocals +vocational +voice +voices +void +voip +volkswagen +volleyball +volt +voltage +volume +volumes +voluntary +volunteer +volunteers +volvo +vote +voted +voters +votes +voting +voyeurweb +voyuer +vsnet +vulnerability +vulnerable +wage +wages +wagner +wagon +wait +waiting +waiver +wake +wales +walk +walked +walker +walking +walks +wall +wallace +wallet +wallpaper +wallpapers +walls +walnut +walt +walter +wanna +want +wanted +wanting +wants +warcraft +ward +ware +warehouse +warm +warming +warned +warner +warning +warnings +warrant +warranties +warranty +warren +warrior +warriors +wars +wash +washer +washing +washington +waste +watch +watched +watches +watching +water +waterproof +waters +watershed +watson +watt +watts +wave +waves +wayne +ways +weak +wealth +weapon +weapons +wear +wearing +weather +webcam +webcams +webcast +weblog +weblogs +webmaster +webmasters +webpage +webshots +website +websites +webster +wedding +weddings +wednesday +weed +week +weekend +weekends +weekly +weeks +weight +weighted +weights +weird +welcome +welding +welfare +well +wellington +wellness +wells +welsh +wendy +went +were +wesley +west +western +westminster +whale +what +whatever +whats +wheat +wheel +wheels +when +whenever +where +whereas +wherever +whether +which +while +whilst +white +whole +wholesale +whom +whose +wichita +wicked +wide +widely +wider +widescreen +widespread +width +wife +wifi +wiki +wikipedia +wild +wilderness +wildlife +wiley +will +william +williams +willing +willow +wilson +wind +window +windows +winds +windsor +wine +wines +wing +wings +winner +winners +winning +wins +winston +winter +wire +wired +wireless +wires +wiring +wisconsin +wisdom +wise +wish +wishes +wishing +wishlist +witch +with +withdrawal +within +without +witness +witnesses +wives +wizard +wolf +woman +women +womens +wonder +wonderful +wondering +wood +wooden +woods +wool +worcester +word +wordpress +words +work +worked +worker +workers +workflow +workforce +working +workout +workplace +works +workshop +workshops +workstation +world +worldcat +worlds +worldwide +worm +worn +worried +worry +worse +worship +worst +worth +worthy +would +wound +wrap +wrapped +wrapping +wrestling +wright +wrist +write +writer +writers +writes +writing +writings +written +wrong +wrote +wyoming +xanax +xbox +xerox +xhtml +yacht +yahoo +yale +yamaha +yang +yard +yards +yarn +yeah +yearly +years +yeast +yellow +yemen +yesterday +yield +yields +yoga +york +yorkshire +young +younger +your +yours +yourself +youth +yugoslavia +yukon +zambia +zdnet +zealand +zero +zimbabwe +zinc +zoloft +zone +zones +zoning +zope +zshops diff --git a/nvim/debug/init.lua b/nvim/debug/init.lua index 546e7d904..19dcee5a5 100644 --- a/nvim/debug/init.lua +++ b/nvim/debug/init.lua @@ -12,12 +12,6 @@ end vim.opt.rtp:prepend(lazypath) require("lazy").setup({ - "axkirillov/hbac.nvim", - "olimorris/persisted.nvim", "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim", }, {}) - -require("persisted").setup({ autoload = true }) - -require("hbac").setup({ }) diff --git a/nvim/init.vim b/nvim/init.vim index 85d3d1a45..945069f25 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -49,10 +49,6 @@ let g:table_mode_corner='|' let g:git_messenger_always_into_popup = v:true let g:git_messenger_no_default_mappings = v:true -let g:vista_sidebar_position = "vertical topleft" -let g:vista_default_executive = 'nvim_lsp' -" let g:vista_finder_alternative_executives = 'ctags' - " 使用 gx 在 vim 中间直接打开链接 let g:netrw_nogx = 1 " disable netrw's gx mapping. nmap gx (openbrowser-smart-search) diff --git a/nvim/lua/usr/alpha.lua b/nvim/lua/usr/alpha.lua deleted file mode 100644 index 88d7ae147..000000000 --- a/nvim/lua/usr/alpha.lua +++ /dev/null @@ -1,29 +0,0 @@ -local alpha = require("alpha") -local dashboard = require("alpha.themes.dashboard") - --- 通过 https://patorjk.com/software/taag 来生成 -dashboard.section.header.val = { - "███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗", - "████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║", - "██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║", - "██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║", - "██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║", - "╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝", - " ", - " ██╗ ██╗██╗ ██╗██████╗ ███████╗ ", - " ╚██╗ ██╔╝╚██╗ ██╔╝██╔══██╗██╔════╝ ", - " ╚████╔╝ ╚████╔╝ ██║ ██║███████╗ ", - " ╚██╔╝ ╚██╔╝ ██║ ██║╚════██║ ", - " ██║ ██║ ██████╔╝███████║ ", -} - --- Set menu -dashboard.section.buttons.val = {} - -dashboard.section.buttons.val = { - dashboard.button(" ,f", " > Find file", ":Telescope find_files"), - dashboard.button("ft", " > FileTree", ":NvimTreeOpen"), -} - --- Send config to alpha -alpha.setup(dashboard.opts) diff --git a/nvim/lua/usr/cmp.lua b/nvim/lua/usr/cmp.lua index b75d55375..6d1d5d296 100644 --- a/nvim/lua/usr/cmp.lua +++ b/nvim/lua/usr/cmp.lua @@ -15,35 +15,7 @@ local check_backspace = function() return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") end ---   פּ ﯟ   some other good icons -local kind_icons = { - Text = "", - Method = "m", - Function = "", - Constructor = "", - Field = "", - Variable = "", - Class = "", - Interface = "", - Module = "", - Property = "", - Unit = "", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", -} --- find more here: https://www.nerdfonts.com/cheat-sheet +local dict = vim.fn.expand('$HOME/.dotfiles/nvim/10k.txt') cmp.setup({ snippet = { @@ -94,29 +66,20 @@ cmp.setup({ "s", }), }, - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - -- Kind icons - vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind - vim_item.menu = ({ - nvim_lsp = "[LSP]", - luasnip = "[Snippet]", - buffer = "[Buffer]", - path = "[Path]", - })[entry.source.name] - return vim_item - end, - }, sources = { { name = "nvim_lsp" }, { name = "luasnip" }, { name = "buffer" }, { name = "path" }, + { name = "emoji" }, { - name = "dictionary", + name = "look", keyword_length = 2, + option = { + convert_case = true, + loud = true, + dict = dict, + }, }, }, confirm_opts = { diff --git a/nvim/lua/usr/init.lua b/nvim/lua/usr/init.lua index cf6d70edc..919f23090 100644 --- a/nvim/lua/usr/init.lua +++ b/nvim/lua/usr/init.lua @@ -12,11 +12,11 @@ require("usr.telescope") require("usr.version") require("usr.which-key") require("usr.colorscheme") -require("usr.alpha") require("colorizer").setup({ "css", "javascript", "vim", html = { mode = "foreground" } }) require("nvim-surround").setup() require("gitsigns").setup({ signcolumn = false, numhl = true }) require("leap").add_default_mappings() +require("flit").setup({}) require("nvim-autopairs").setup() require("fidget").setup() require("nvim-navic").setup() @@ -24,10 +24,8 @@ require("barbecue").setup() require("nvim-lightbulb").update_lightbulb() require("im_select").setup() require("lualine").setup() -require("rsync").setup() require("numb").setup() require("debugprint").setup() --- require("hardtime").setup() # 一时难以适应 -- require("luasnip.loaders.from_lua").lazy_load({ paths = "~/.config/nvim/LuaSnip/" }) require("luasnip.loaders.from_snipmate").lazy_load({ paths = "~/.config/nvim/snippets/" }) diff --git a/nvim/lua/usr/lazy.lua b/nvim/lua/usr/lazy.lua index b47213f2a..3ad989260 100644 --- a/nvim/lua/usr/lazy.lua +++ b/nvim/lua/usr/lazy.lua @@ -26,20 +26,23 @@ require("lazy").setup({ { "saadparwaiz1/cmp_luasnip" }, -- snippet completions { "hrsh7th/cmp-nvim-lsp" }, { "hrsh7th/cmp-nvim-lua" }, + { "octaltree/cmp-look" }, -- 利用 nvim/10k.txt 来补全输入 - -- Snippets - { "L3MON4D3/LuaSnip" }, --snippet engine - { "rafamadriz/friendly-snippets" }, -- a bunch of snippets to use + -- 代码段 + { + "L3MON4D3/LuaSnip", + dependencies = { "rafamadriz/friendly-snippets" }, + }, - -- LSP + -- lsp { "neovim/nvim-lspconfig" }, -- enable LSP { "williamboman/mason.nvim" }, -- simple to use language server installer { "williamboman/mason-lspconfig.nvim" }, - { "jose-elias-alvarez/null-ls.nvim" }, -- for formatters and linters + { "nvimtools/none-ls.nvim" }, -- for formatters and linters { "j-hui/fidget.nvim", tag = "legacy" }, - { "SmiteshP/nvim-navic" }, + { "SmiteshP/nvim-navic" }, -- 在 winbar 展示当前的路径 { "utilyre/barbecue.nvim" }, - { "kosayoda/nvim-lightbulb" }, + { "kosayoda/nvim-lightbulb" }, -- 右下角展示索引的进度 --treesitter { @@ -62,16 +65,10 @@ require("lazy").setup({ "akinsho/bufferline.nvim", -- buffer "nvim-lualine/lualine.nvim", -- 状态栏 "kazhala/close-buffers.nvim", -- 一键删除不可见 buffer - { - "axkirillov/hbac.nvim", - event = "SessionLoadPost", - opts = {}, - }, - -- 自动删除长期不用的 buffer + { "axkirillov/hbac.nvim", event = "SessionLoadPost", opts = {} }, -- 自动删除长期不用的 buffer "gelguy/wilder.nvim", -- 更加智能的命令窗口 "romgrk/fzy-lua-native", -- wilder.nvim 的依赖 "xiyaowong/nvim-transparent", -- 可以移除掉背景色,让 vim 透明 - { "goolord/alpha-nvim", event = "VimEnter" }, -- 颜色主题 "folke/tokyonight.nvim", { "catppuccin/nvim", name = "catppuccin", priority = 1000 }, @@ -102,25 +99,33 @@ require("lazy").setup({ ft = { "markdown" }, build = "cd app && npm install", }, + -- 如果发现插件有问题, 可以进入到 ~/.local/share/nvim/lazy/markdown-preview.nvim/app && npm install "mzlogin/vim-markdown-toc", -- 自动目录生成 "dhruvasagar/vim-table-mode", -- 快速编辑 markdown 的表格 - "xiyaowong/telescope-emoji.nvim", -- 使用 telescope 搜索 emoji 表情 -- 高效编辑 "tpope/vim-commentary", -- 快速注释代码 "kylechui/nvim-surround", -- 快速编辑单词两侧的符号 "tpope/vim-repeat", -- 更加强大的 `.` "windwp/nvim-autopairs", -- 自动括号匹配 - "honza/vim-snippets", -- 安装公共的的 snippets "mbbill/undotree", -- 显示编辑的历史记录 "mg979/vim-visual-multi", -- 同时编辑多个位置 "AckslD/nvim-neoclip.lua", -- 保存 macro "windwp/nvim-spectre", -- 媲美 vscode 的多文件替换 + { + "cbochs/portal.nvim", + -- Optional dependencies + dependencies = { + "cbochs/grapple.nvim", + "ThePrimeagen/harpoon", + }, + }, -- 高亮 "norcalli/nvim-colorizer.lua", -- 显示 #FFFFFF "andymass/vim-matchup", -- 高亮匹配的元素,例如 #if 和 #endif -- 时间管理 "nvim-orgmode/orgmode", -- orgmode 日程管理 -- use 'wakatime/vim-wakatime' -- 代码时间统计 + -- lsp 增强 "jackguo380/vim-lsp-cxx-highlight", -- ccls 高亮 "mattn/efm-langserver", -- 支持 bash @@ -128,20 +133,37 @@ require("lazy").setup({ "jakemason/ouroboros", -- quickly switch between header and source file in C/C++ project -- 其他 "ggandor/leap.nvim", -- 快速移动 + "ggandor/flit.nvim", -- 利用 leap.nvim 强化 f/F t/T + { "crusj/bookmarks.nvim", branch = "main" }, -- 书签, 存储在 ~/.local/share/nvim/bookmarks 中 "tyru/open-browser.vim", -- 使用 gx 打开链接 "keaising/im-select.nvim", -- 自动切换输入法 { "olimorris/persisted.nvim", opts = { autoload = true } }, -- 打开 vim 的时候,自动恢复为上一次关闭的状态 "anuvyklack/hydra.nvim", -- 消除重复快捷键,可以用于调整 window 大小等 - "ojroques/vim-oscyank", -- 让 nvim 在远程 server 上拷贝到本地剪切板上 "azabiong/vim-highlighter", -- 高亮多个搜索内容 "dstein64/vim-startuptime", -- 分析 nvim 启动时间 "voldikss/vim-translator", -- 翻译 "nacro90/numb.nvim", - { - "OscarCreator/rsync.nvim", - build = "make", -- 实在不行,进入到 ~/.local/share/nvim/lazy/rsync.nvim 中执行下 make - }, -- 自动同步代码远程 { "andrewferrier/debugprint.nvim", version = "*" }, -- 快速插入 print 来调试 - "m4xshen/hardtime.nvim", -- 训练自己的 vim 习惯,默认没有开启 + { + "m4xshen/hardtime.nvim", + opts = { enabled = false }, + }, -- 训练自己的 vim 习惯,默认没有开启 + { + "allaman/emoji.nvim", + ft = "markdown", + opts = { enable_cmp_integration = true }, + }, -- emoji 支持 + { + "martins3/rsync.nvim", + -- dir = "/home/martins3/core/rsync.nvim/", + lazy = true, + enabled = function() + local root = vim.fn.system("whoami") + root = root:sub(1, -2) + return vim.fn.system("whoami") == "martins3\n" + end, + cmd = { "TransferInit", "TransferToggle" }, + opts = {}, + }, }, {}) diff --git a/nvim/lua/usr/lsp/mason.lua b/nvim/lua/usr/lsp/mason.lua index b252a4fbb..fec4cf3b3 100644 --- a/nvim/lua/usr/lsp/mason.lua +++ b/nvim/lua/usr/lsp/mason.lua @@ -39,7 +39,7 @@ if not lspconfig_status_ok then return end -local all_servers = {"ccls"} +local all_servers = {"ccls", "nixd"} for i = 1, #servers do all_servers[#all_servers + 1] = servers[i] end diff --git a/nvim/lua/usr/nvim-tree.lua b/nvim/lua/usr/nvim-tree.lua index d422cc5da..ca8325541 100644 --- a/nvim/lua/usr/nvim-tree.lua +++ b/nvim/lua/usr/nvim-tree.lua @@ -38,3 +38,10 @@ require("nvim-tree").setup({ }, }, }) + +vim.cmd([[ + :hi NvimTreeExecFile gui=bold guifg=#ffa0a0 + :hi NvimTreeSymlink gui=bold guifg=#ffff60 + :hi NvimTreeSpecialFile gui=bold,underline guifg=#ff80ff + :hi NvimTreeImageFile gui=bold guifg=#ff80ff + ]]) diff --git a/nvim/lua/usr/telescope.lua b/nvim/lua/usr/telescope.lua index 8e21d1576..981dc7815 100644 --- a/nvim/lua/usr/telescope.lua +++ b/nvim/lua/usr/telescope.lua @@ -37,8 +37,8 @@ require("telescope").setup({ -- To get fzf loaded and working with telescope, you need to call -- load_extension, somewhere after setup function: require("telescope").load_extension("fzf") -require("telescope").load_extension("emoji") require("telescope").load_extension("neoclip") -- require('telescope').load_extension("frecency") require("telescope").load_extension("lsp_handlers") require("telescope").load_extension("bookmarks") +require("telescope").load_extension("emoji") diff --git a/nvim/lua/usr/which-key.lua b/nvim/lua/usr/which-key.lua index 736c5be30..77ed6870c 100644 --- a/nvim/lua/usr/which-key.lua +++ b/nvim/lua/usr/which-key.lua @@ -10,10 +10,13 @@ wk.setup({ wk.register({ ["K"] = { "lua vim.lsp.buf.hover()", "document" }, ["g"] = { + a = { "Portal jumplist backward", "jumplist backward" }, + b = { "Portal jumplist forward", "jumplist forward" }, d = { "lua vim.lsp.buf.definition()", "go to definition" }, r = { "lua vim.lsp.buf.references()", "go to reference" }, w = { "Telescope diagnostics", "diagnostics" }, i = { "lua vim.lsp.buf.implementation()", "go to implementation" }, + j = { "lua require('barbecue.ui').navigate(-1)", "go to the head of function / struct"}, D = { "lua vim.lsp.buf.declaration()", "go to declaration" }, -- x 打开文件 -- s 用于 leap 跳转到下一个窗口 @@ -29,6 +32,7 @@ wk.register({ i = { "Telescope jumplist", "search jumplist" }, j = { "Telescope emoji", "search emoji" }, k = { "Telescope colorscheme", "colorscheme" }, + m = { "Telescope bookmarks", "search bookmarks" }, o = { "Telescope lsp_document_symbols", "search symbols in file" }, -- leader p used for paste from system clipboard s = { "Telescope lsp_dynamic_workspace_symbols ", "search symbols in project" }, @@ -124,9 +128,10 @@ wk.register({ s = { "set spell!", "spell check" }, w = { "set wrap!", "wrap line" }, h = { "noh", "Stop the highlighting" }, + H = { "Hardtime toggle", "toggle hardtime" }, m = { "TableModeToggle", "markdown table edit mode" }, t = { "set nocursorline TransparentToggle", "make background transparent" }, - r = { "RsyncSaveSync toggle", "toggle rsync on save" }, + r = { "TransferToggle", "toggle rsync on save" }, }, x = { "FloatermNew ipython", "calculated" }, }, diff --git a/nvim/snippets/c.snippets b/nvim/snippets/c.snippets index d8abd3bde..5678d5a1f 100644 --- a/nvim/snippets/c.snippets +++ b/nvim/snippets/c.snippets @@ -23,3 +23,51 @@ snippet import "template" ${0} return 0; } + +snippet sysfs "add monitor into sysfs" + int foo; + EXPORT_SYMBOL(foo); + static ssize_t foo_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) + { + return sysfs_emit(buf, "%d\n", foo); + } + + static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) + { + int ret; + + ret = kstrtoint(buf, 10, &foo); + if (ret < 0) + return ret; + + return count; + } + + static struct kobj_attribute foo_attribute = + __ATTR(foo, 0664, foo_show, foo_store); + + static struct attribute *attrs[] = { + &foo_attribute.attr, + NULL, + }; + + static struct attribute_group attr_group = { + .attrs = attrs, + }; + + static struct kobject *mymodule; + static int greeter_init(void) + { + int error = 0; + mymodule = kobject_create_and_add("hacking", kernel_kobj); + if (!mymodule) + return -ENOMEM; + + error = sysfs_create_group(mymodule, &attr_group); + if (error) + kobject_put(mymodule); + + return error; + } diff --git a/nvim/snippets/sh.snippets b/nvim/snippets/sh.snippets index 6d35ab8be..eca8b2ab0 100644 --- a/nvim/snippets/sh.snippets +++ b/nvim/snippets/sh.snippets @@ -465,6 +465,14 @@ snippet xxx_ext "extended template for any bash script" snippet note_split_string_to_array "split string to array" IFS=';' read -r -a ADDR <<< "$IN" +snippet note_split_cmd_output_to_array "split cmd output to array" + # 默认是换行 + mapfile -t array < <(git log --format=%h --since="24 hours ago") + printf "%s\n" "${array[@]}" + + # -d 来指定分隔符, -t 删除掉分隔符 + mapfile -t -d " " parent < <(git show --no-patch --format="%P" f80e8b) + printf "%s\n" "${array[@]}" snippet note_tee "如何 append" # 使用 -a @@ -472,8 +480,10 @@ snippet note_tee "如何 append" snippet note_awk "basic" - # 读取一行中的第二个 - awk -F '"' '{print \$2}' your_input_file + # 读取一行中的第二个,注意,使用小引号 + awk -F '"' '{print $2}' your_input_file + # 读取一行中的第二个和第三个,注意,使用小引号 + awk -F '"' '{printf "%s %s" , $2 , $3}' your_input_file # 1. awk 可以使用 printf # 2. awk 的 END 是处理完之后进行一个操作 echo "1\n2 " | awk '{sum+=$1}; END {printf "average is %f",sum/NR}' @@ -500,22 +510,6 @@ snippet note_awk_regex "awk 中的正则" awk '\$4~/hello/ { print "This field contains hello", $4}' test.txt awk '\$4 == "hello" { print "This field is hello:", $4}' test.txt - -snippet note_xargs "xargs" - # -t : 将要执行的命令打印出来 - # -I % : 设置参数为 % - # ls | xargs -t -I % sh -c 'echo %' - - # 将一个仓库中所有的 apples 替换为 oranges - # git grep -l 'apples' | xargs sed -i 's/apples/oranges/g' - - # 将 foo 下所有的 txt 都删除 - # find ./foo -type f -name "*.txt" -exec rm {} \; - # find ./foo -type f -name "*.txt" | xargs rm - - # find . -type f -print | xargs stat -c '%a %n' - - snippet note_basic "bash 基本内容" # 在 set -e 的时候,容忍一个 command 失败: # particular_script || true diff --git a/readme.md b/readme.md index 7abcc2d98..46f139e4d 100644 --- a/readme.md +++ b/readme.md @@ -8,17 +8,14 @@ ## 📚 Document * 软件篇 - * [2023 年 vim 的 C/C++ 配置](./docs/nvim.md) + * [2024 年 vim 的 C/C++ 配置](./docs/nvim.md) * [极简 Tmux 配置](./docs/tmux.md) * [Tabby, Tilix, Gnome Terminal, Alacritty 和 Kitty 使用体验对比](./docs/terminals.md) * [Rime 输入法配置](./docs/rime.md) * [tig 基于 vim 模式的快捷键介绍](./docs/tig.md) * [2023 年对比一下 ccls 和 clangd](./docs/ccls-vs-clangd.md) * 🚧 [NixOS 初步尝试](./docs/nix.md) - * 🚧 [如何彻底征服 bash](./shell/bash.md) -* 硬件篇 - * TODO -* 🚧 [题外话: 折腾 Linux 的一些经验之谈](./docs/why.md) +* [题外话: 为什么我要去折腾 Linux](./docs/why.md) ## ⚙ Install diff --git a/rime/linux-install.sh b/rime/linux-install.sh index 7ab06f3d7..75abb6a74 100755 --- a/rime/linux-install.sh +++ b/rime/linux-install.sh @@ -13,11 +13,10 @@ fi cd ~/core/ if [[ ! -d plum ]]; then git clone https://github.com/rime/plum + cd plum + # 使用 plum 安装基础组件 + rime_dir="$CONFIG_DIR" bash rime-install fi -cd plum - -# 使用 plum 安装基础组件 -rime_dir="$CONFIG_DIR" bash rime-install # 从雾凇拼音 中拷贝词库过来 function update_idct_from_ice() { diff --git a/scripts/anki.py b/scripts/anki.py new file mode 100755 index 000000000..81c948d1c --- /dev/null +++ b/scripts/anki.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +import json +import urllib.request +import argparse + +# Instantiate the parser +parser = argparse.ArgumentParser(description="Optional app description") +parser.add_argument("action", type=str) +parser.add_argument("-c", "--count") + +args = parser.parse_args() + + +def request(action, **params): + return {"action": action, "params": params, "version": 6} + + +def invoke(action, **params): + requestJson = json.dumps(request(action, **params)).encode("utf-8") + response = json.load( + urllib.request.urlopen( + urllib.request.Request("http://127.0.0.1:8765", requestJson) + ) + ) + if len(response) != 2: + raise Exception("response has an unexpected number of fields") + if "error" not in response: + raise Exception("response is missing required error field") + if "result" not in response: + raise Exception("response is missing required result field") + if response["error"] is not None: + raise Exception(response["error"]) + return response["result"] + + +match args.action: + case "add": + note = { + "deckName": "martins3", + "modelName": "Basic", + "fields": {"Front": "hihi", "Back": "hi"}, + "options": {"allowDuplicate": False}, + "tags": [], + } + result = invoke("addNote", note=note) + print("got list of decks: {}".format(result)) + case "show": + result = invoke("findNotes", query="deck:martins3") + for i in result: + note = invoke("notesInfo", notes=[i]) + print(f"{i} : {note[0]['fields']['Front']['value']}") + case "delete": + print(args.count) + note = invoke("deleteNotes", notes=[args.count]) + print(note) diff --git a/scripts/anki.sh b/scripts/anki.sh new file mode 100755 index 000000000..244e90521 --- /dev/null +++ b/scripts/anki.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -E -e -u -o pipefail +cd "$(dirname "$0")" diff --git a/scripts/c/fsync.c b/scripts/c/fsync.c deleted file mode 100644 index c12dcc950..000000000 --- a/scripts/c/fsync.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -int main(int argc, char *argv[]) { - int fd = open("/tmp/a.txt", O_RDWR | O_CREAT, 0644); - if (write(fd, "hi", sizeof("hi")) < 0) - goto err; - - if (fsync(fd) < 0) - goto err; - return EXIT_SUCCESS; -err: - printf("failed: %s\n", strerror(errno)); - return EXIT_FAILURE; -} diff --git a/scripts/c/getpid.c b/scripts/c/getpid.c deleted file mode 100644 index 537195493..000000000 --- a/scripts/c/getpid.c +++ /dev/null @@ -1,8 +0,0 @@ -#include -#include -#include - -int main(void) { - printf("%ld-%ld", (long)getpid(), (long)getppid()); - return 0; -} diff --git a/scripts/c/mmap.c b/scripts/c/mmap.c deleted file mode 100644 index 95a1ea3a4..000000000 --- a/scripts/c/mmap.c +++ /dev/null @@ -1,124 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -const unsigned long PAGE_SIZE = 4 * 1024; -unsigned long MAP_SIZE = 4000L * 1024 * 1024; - -#define MAPPING_PROT PROT_READ | PROT_WRITE - -int get_file() { - int fd; - /* fd = open("/dev/hugepages/", O_RDWR | O_CREAT, 0644); */ - fd = open("/home/martins3/qemu.ram", O_RDWR | O_CREAT, 0644); - /* fd = open("/root/hack/qemu.ram", O_RDWR | O_CREAT, 0644); */ - /* fd = open("/dev/shm/x", O_RDWR | O_CREAT, 0644); */ - if (fd == -1) - goto err; - - if (ftruncate(fd, MAP_SIZE) < 0) - goto err; - return fd; -err: - printf("%s\n", strerror(errno)); - exit(1); -} - -void *copy_files() { - void *ptr = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_SHARED, -1, 0); - size_t size = 0; - - if (ptr == MAP_FAILED) - goto err; - - char m = '1'; - for (unsigned long i = 0; i < MAP_SIZE; i += PAGE_SIZE) { - *((char *)(ptr + i)) = m; - } - - int fd = get_file(); - // TODO 调查一下,为什么 read 循环多少次就会被打断一次 - // 读一个 8G 文件必须使用 while - while (true) { - sleep(1); - lseek(fd, 0, SEEK_SET); - while (read(fd, ptr, MAP_SIZE) > 0) - ; - sleep(1); - - // TODO write 这个停顿真烦人,每次的最多写 7ffff000 - while (true) { - while (read(fd, ptr, MAP_SIZE) > 0) - ; - if (lseek(fd, 0, SEEK_SET) < 0) - goto err; - sleep(1); - } - - printf("[martins3:%s:%d] size=%lx\n", __FUNCTION__, __LINE__, size); - } - return ptr; - -err: - printf("%s\n", strerror(errno)); - exit(1); -} - -void *mmap_region() { - /* void *ptr = mmap(NULL, MAP_SIZE, MAPPING_PROT, MAP_ANONYMOUS | MAP_SHARED, -1, 0); */ - // void *ptr = mmap(NULL, MAP_SIZE, MAPPING_PROT, MAP_ANONYMOUS | MAP_PRIVATE, 1, 0); - // 这两个都是产生 page cache - void *ptr = mmap(NULL, MAP_SIZE, MAPPING_PROT, MAP_SHARED, get_file(), 0); - // void *ptr = mmap(NULL, MAP_SIZE, MAPPING_PROT, MAP_PRIVATE, get_file(), 0); - if (ptr == MAP_FAILED) - goto err; - - return ptr; -err: - printf("%s\n", strerror(errno)); - exit(1); -} - -int main() { - /* void *ptr = copy_files(); */ - void *ptr = mmap_region(); - - /* if (madvise(ptr, MAP_SIZE, MADV_HUGEPAGE) == -1) */ - /* goto err; */ - - if (madvise(ptr, MAP_SIZE, MADV_RANDOM) == -1) - goto err; - - char m = '1'; - for (unsigned long i = 0; i < MAP_SIZE; i += PAGE_SIZE) { - *((char *)(ptr + i)) = m; - } - printf("good\n"); - - while (1) { - for (unsigned long i = 0; i < MAP_SIZE; i += PAGE_SIZE) { - m += *((char *)(ptr + i)); - } - printf("loop %c\n", m); - } - sleep(1000); - - if (munmap(ptr, MAP_SIZE) == -1) - goto err; - - return 0; - -err: - printf("munmap failed: %s\n", strerror(errno)); - return 1; -} diff --git a/scripts/c/readme.md b/scripts/c/readme.md deleted file mode 100644 index a5b9b2395..000000000 --- a/scripts/c/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# 下一个系列,如何快速写 C 语言 - -## https://github.com/attractivechaos/klib diff --git a/scripts/c/shm.c b/scripts/c/shm.c deleted file mode 100644 index ed7b60f9f..000000000 --- a/scripts/c/shm.c +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include /* For O_* constants */ -#include -#include -#include -#include -#include -#include /* For mode constants */ -#include - -// 10G 大小 -#define MAP_SIZE (10000UL * 1024 * 1024) -int main(int argc, char *argv[]) { - int fd; - void *result; - char wait; - - fd = shm_open("shm1", O_RDWR | O_CREAT, 0644); - if (fd < 0) { - printf("shm_open failed\n"); - exit(1); - } - - if (ftruncate(fd, MAP_SIZE) < 0) { - printf("ftruncate failed\n"); - exit(1); - } - - result = mmap(NULL, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (result == MAP_FAILED) { - printf("mmap failed: %s\n", strerror(errno)); - return 1; - } - memset(result, 0, MAP_SIZE); - if (result == MAP_FAILED) { - printf("mapped failed\n"); - exit(1); - } - scanf("%c", &wait); - - while (true) - sleep(1); -} diff --git a/scripts/install.sh b/scripts/install.sh index 5a549af5b..1cdab8c44 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -18,12 +18,14 @@ mkdir -p ~/.config/atuin/ ln -sf ~/.dotfiles/config/tmux.conf ~/.tmux.conf ln -sf ~/.dotfiles/config/tigrc.conf ~/.tigrc ln -sf ~/.dotfiles/config/alacritty.yml ~/.alacritty.yml +ln -sf ~/.dotfiles/config/alacritty.toml ~/.alacritty.toml ln -sf ~/.dotfiles/config/wtf.yml ~/.config/wtf/config.yml ln -sf ~/.dotfiles/config/zathurarc ~/.config/zathura/zathurarc ln -sf ~/.dotfiles/config/starship.toml ~/.config/starship.toml ln -sf ~/.dotfiles/config/cargo.conf ~/.cargo/config ln -sf ~/.dotfiles/config/wezterm.lua ~/.config/wezterm/wezterm.lua ln -sf ~/.dotfiles/config/atuin.toml ~/.config/atuin/config.toml +ln -sf ~/.dotfiles/config/pueue.yml ~/.config/pueue/pueue.yml # dhruvmanila/browser-bookmarks.nvim ln -sf ~/.config/google-chrome-stable ~/.config/microsoft-edge @@ -35,3 +37,6 @@ if [[ ! -d ~/.tmux/plugins/tpm ]]; then git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm echo "tmux plugin install : prefix + I" fi + +/home/martins3/.dotfiles/rime/linux-install.sh +echo "Almost finished,open fcitx 5 Configiration" diff --git a/scripts/nix/begin.nix b/scripts/nix/begin.nix new file mode 100644 index 000000000..9dce2df58 --- /dev/null +++ b/scripts/nix/begin.nix @@ -0,0 +1,7 @@ +let + x = 1; + y = 2; +in +{ + inherit x y; +} # 结果是 { x = 1; y = 2; } diff --git a/scripts/nix/env/ccls.nix b/scripts/nix/env/ccls.nix deleted file mode 100644 index 601031f2d..000000000 --- a/scripts/nix/env/ccls.nix +++ /dev/null @@ -1,11 +0,0 @@ -with import {}; -let - -in stdenv.mkDerivation { - name = "llvm-env"; - nativeBuildInputs = [ cmake llvmPackages.llvm.dev ]; - buildInputs = with llvmPackages; [ libclang llvm rapidjson ]; -} - -# cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Debug -# cmake --build Release -j30 diff --git a/scripts/nix/env/fio.nix b/scripts/nix/env/fio.nix index 9f715cb33..b151f557c 100644 --- a/scripts/nix/env/fio.nix +++ b/scripts/nix/env/fio.nix @@ -5,7 +5,7 @@ pkgs.mkShell { nativeBuildInputs = with pkgs.buildPackages; [ libaio python3 zlib liburing - pkgconfig + pkg-config autoconf gettext autoconf-archive diff --git a/scripts/nix/env/grub.nix b/scripts/nix/env/grub.nix index b1be810d4..1da90a3d8 100644 --- a/scripts/nix/env/grub.nix +++ b/scripts/nix/env/grub.nix @@ -3,7 +3,7 @@ let in pkgs.mkShell rec { nativeBuildInputs = with pkgs.buildPackages; [ - pkgconfig + pkg-config autoconf gettext autoconf-archive diff --git a/scripts/nix/env/libiscsi.nix b/scripts/nix/env/libiscsi.nix index 14cb79d09..b675c9e60 100644 --- a/scripts/nix/env/libiscsi.nix +++ b/scripts/nix/env/libiscsi.nix @@ -3,7 +3,7 @@ let in pkgs.mkShell rec { nativeBuildInputs = with pkgs.buildPackages; [ - pkgconfig + pkg-config autoconf gettext autoconf-archive diff --git a/scripts/nix/env/linux.llvm.nix b/scripts/nix/env/linux.llvm.nix new file mode 100644 index 000000000..f74a9f516 --- /dev/null +++ b/scripts/nix/env/linux.llvm.nix @@ -0,0 +1,75 @@ +# 1. 之前的写法 +# { pkgs ? import { }, +# unstable ? import { } +# }: +with import {}; + +# TODO 很奇怪,LLVM 无法正常构建内核,需要将版本下移到 6.1 左右才可以 + +# 2. 之前的写法 +# pkgs.stdenv.mkDerivation { +pkgs.llvmPackages.stdenv.mkDerivation { + +# llvmPackages 是可以指定版本的 +# pkgs.llvmPackages_14.stdenv.mkDerivation { + name = "yyds"; + buildInputs = with pkgs; [ + + getopt + flex + bison + gcc + gnumake + bc + rpm + dpkg + pahole # bpf + pkg-config + binutils + + elfutils + ncurses + openssl + zlib + lld + llvm + # selftests + alsa-lib + libcap + libmnl + libcap_ng + liburing + + + # unstable.rustfmt + # unstable.rustc + # unstable.cargo + # unstable.rust-bindgen + + # Necessary for the openssl-sys crate: + pkgs.openssl + pkgs.pkg-config + + pkgs.graphviz + + (python3.withPackages (p: with p; [ + sphinx + # 修改 Documentation/conf.py 中 html_theme = 'sphinx_rtd_theme' + sphinx-rtd-theme + pyyaml + ])) + libopcodes + numactl + /* numa_num_possible_cpus */ + /* libperl */ + libunwind + lzma + zstd + perl + # @todo 不知道为什么现在 perf 缺少这个库 + libtraceevent + ]; + + # See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/3?u=samuela. + RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; +} diff --git a/scripts/nix/env/linux.nix b/scripts/nix/env/linux.nix index bb912a497..4136de901 100644 --- a/scripts/nix/env/linux.nix +++ b/scripts/nix/env/linux.nix @@ -1,4 +1,6 @@ -{ pkgs ? import { } }: +{ pkgs ? import { }, + unstable ? import { } +}: pkgs.stdenv.mkDerivation { name = "yyds"; @@ -27,12 +29,11 @@ pkgs.stdenv.mkDerivation { libcap_ng liburing - # rust language - # @todo 还没有太搞清楚如何索引 Rust 项目 - # 但是现在每次下载对应的库需要很长时间 - # pkgs.cargo - # pkgs.rustc - # pkgs.rustfmt + + # unstable.rustfmt + # unstable.rustc + # unstable.cargo + # unstable.rust-bindgen # Necessary for the openssl-sys crate: pkgs.openssl @@ -44,6 +45,7 @@ pkgs.stdenv.mkDerivation { sphinx # 修改 Documentation/conf.py 中 html_theme = 'sphinx_rtd_theme' sphinx-rtd-theme + pyyaml ])) libopcodes numactl diff --git a/scripts/nix/env/qemu-static.nix b/scripts/nix/env/qemu-static.nix index 5348718ce..ca2392537 100644 --- a/scripts/nix/env/qemu-static.nix +++ b/scripts/nix/env/qemu-static.nix @@ -5,7 +5,7 @@ pkgs.stdenv.mkDerivation { name = "martins3's QEMU"; buildInputs = with pkgs; [ zlib - pkgconfig + pkg-config ninja glib pixman diff --git a/scripts/nix/env/qemu.nix b/scripts/nix/env/qemu.nix index 3261ffc6b..b3e1c6830 100644 --- a/scripts/nix/env/qemu.nix +++ b/scripts/nix/env/qemu.nix @@ -6,7 +6,7 @@ pkgs.stdenv.mkDerivation { name = "martins3's QEMU"; buildInputs = with pkgs; [ zlib - pkgconfig + pkg-config ninja glib pixman diff --git a/scripts/nix/env/rasdaemon.nix b/scripts/nix/env/rasdaemon.nix index a893bf3ff..2cee1fede 100644 --- a/scripts/nix/env/rasdaemon.nix +++ b/scripts/nix/env/rasdaemon.nix @@ -15,7 +15,7 @@ pkgs.stdenv.mkDerivation { yacc bison flex - pkgconfig + pkg-config elfutils libelf autoconf diff --git a/scripts/nix/env/spdk.nix b/scripts/nix/env/spdk.nix index 616969f0b..2f6557c4c 100644 --- a/scripts/nix/env/spdk.nix +++ b/scripts/nix/env/spdk.nix @@ -24,7 +24,7 @@ pkgs.mkShell rec { python3.pkgs.setuptools autoconf automake - pkgconfig + pkg-config autoconf gettext autoconf-archive @@ -49,6 +49,7 @@ pkgs.mkShell rec { openssl ncurses zlib + fuse3 ]; # @todo 不知道这个是什么原理? @@ -60,6 +61,8 @@ pkgs.mkShell rec { } /** + * git clone https://github.com/spdk/spdk.git + * pushd spdk * git submodule update --init * ./configure * make diff --git a/scripts/nix/env/xdp.nix b/scripts/nix/env/xdp.nix new file mode 100644 index 000000000..440ded25f --- /dev/null +++ b/scripts/nix/env/xdp.nix @@ -0,0 +1,28 @@ +let +pkgs = import { }; +in +pkgs.llvmPackages.stdenv.mkDerivation { + name = "xdp"; + buildInputs = with pkgs; [ + pkg-config + bpftool + libllvm + elfutils + autoconf + automake + libtool + libpcap + glibc_multi + libbpf + + libcap + libbfd + ]; +} + + +# https://github.com/xdp-project/xdp-tutorial +# 似乎因为 clang 的升级,导致编译有报错 +# https://maskray.me/blog/2023-08-25-clang-wunused-command-line-argument +# 需要将将其中的 Werror 去掉 +# sed -i "s/-Werror//g" lib/Makefile common/common.mk lib/libbpf/src/Makefile diff --git a/scripts/nix/nix-channel.sh b/scripts/nix/nix-channel.sh index 0be44ab6c..ff5895810 100755 --- a/scripts/nix/nix-channel.sh +++ b/scripts/nix/nix-channel.sh @@ -1,9 +1,15 @@ #!/usr/bin/env bash set -x -sudo nix-channel --add https://nixos.org/channels/nixos-23.05 nixos -sudo nix-channel --add https://nixos.org/channels/nixos-23.05 nixpkgs -sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager +sudo nix-channel --add https://nixos.org/channels/nixos-23.11 nixos +sudo nix-channel --add https://nixos.org/channels/nixos-23.11 nixpkgs +sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.11.tar.gz home-manager sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable/ unstable sudo nix-channel --add https://nixos.org/channels/nixos-unstable/ nixos-unstable + +sudo nix-channel --add https://mirror.tuna.tsinghua.edu.cn/nix-channels/nixos-23.11 nixos +sudo nix-channel --add https://mirror.tuna.tsinghua.edu.cn/nix-channels/nixos-23.11 nixpkgs +sudo nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixpkgs-unstable unstable +sudo nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-unstable/ nixos-unstable + sudo nix-channel --update diff --git a/scripts/nix/pkg/static-qemu.nix b/scripts/nix/pkg/static-qemu.nix index 1e3b4d59f..51c018b13 100644 --- a/scripts/nix/pkg/static-qemu.nix +++ b/scripts/nix/pkg/static-qemu.nix @@ -166,7 +166,7 @@ let # nativeBuildInputs makeWrapper = pkgs.makeWrapper; python2 = pkgs.python2; - pkgconfig = pkgs.pkgconfig; + pkg-config = pkgs.pkg-config; flex = pkgs.flex; bison = pkgs.bison; perl = pkgs.perl; diff --git a/scripts/nix/vm/vm.nix b/scripts/nix/vm/vm.nix new file mode 100644 index 000000000..3488e6a36 --- /dev/null +++ b/scripts/nix/vm/vm.nix @@ -0,0 +1,3 @@ +{ pkgs, ... }: { + boot.kernelPackages = pkgs.linuxPackages_latest; +} diff --git a/scripts/nixos-install.sh b/scripts/nixos-install.sh index 27304e5fb..ae6be0b5e 100755 --- a/scripts/nixos-install.sh +++ b/scripts/nixos-install.sh @@ -2,12 +2,21 @@ set -E -e -u -o pipefail -ln -sf /home/martins3/.dotfiles/config/ /home/martins3/.config/home-manager +mkdir -p /home/martins3/.config +ln -sf /home/martins3/.dotfiles/nixpkgs /home/martins3/.config/home-manager mkdir -p /home/martins3/.config/nix/ ln -sf /home/martins3/.dotfiles/config/nix.conf /home/martins3/.config/nix/nix.conf line="/home/martins3/.config/home-manager/system.nix" sudo sed -i "/hardware-configuration.nix/a $line" /etc/nixos/configuration.nix -sudo ./nix/nix-channel.sh + +# shellcheck disable=SC2016 +hash='$6$Iehu.x9i7eiceV.q$X4INuNrrxGvdK546sxdt3IV9yHr90/Mxo7wuIzdowoN..jFSFjX8gHaXchfBxV4pOYM4h38pPJOeuI1X/5fon/' +line="users.users.root.hashedPassword = \"$hash\";" +echo "$line" >> /etc/nixos/configuration.nix +line="users.users.martins3.hashedPassword = \"$hash\";" +echo "$line" >> /etc/nixos/configuration.nix + +sudo /home/martins3/.dotfiles/scripts/nix/nix-channel.sh sudo nixos-rebuild switch nix-shell '' -A install home-manager switch diff --git a/scripts/qemu/choose.sh b/scripts/qemu/choose.sh new file mode 100755 index 000000000..25e5990a2 --- /dev/null +++ b/scripts/qemu/choose.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +set -E -e -u -o pipefail + +function choose_vm() { + option=$1 + readarray -d '' dirs_array < <(find /home/martins3/hack/vm/ -maxdepth 1 -type d -print0) + live_vms=() + for i in "${dirs_array[@]}"; do + if [[ $option == "valid" && -d $i/opt ]]; then + live_vms+=("$i") + fi + + if [[ $option == "active" && -f $i/pid ]]; then + # If qemu killed out of sigkill, pidfile won't be removed automatically, + # check it once again + if [[ -f /proc/$(cat "$i"/pid)/status ]]; then + live_vms+=("$i") + fi + fi + + if [[ $option == "hacking_kernel" && -f $i/initramfs && -s $i/opt/replace_kernel ]]; then + live_vms+=("$i") + fi + + if [[ $option == "inactive" && -d $i/opt ]]; then + if [[ ! -f $i/pid ]]; then + live_vms+=("$i") + fi + + # if vm killed unexpectly or qemu crashed, pidfile will not be cleand + # automatically. check the procfs to verify + if [[ -f $i/pid && ! -d /proc/$(cat "$i"/pid) ]]; then + live_vms+=("$i") + fi + fi + + done + + if [[ ${#live_vms[@]} == 0 ]]; then + return + fi + + if [[ ${#live_vms[@]} == 1 ]]; then + echo "${live_vms[0]}" + return + fi + + choice=$(printf "%s\n" "${live_vms[@]}" | fzf) + echo "$choice" +} + +choose_vm "$1" diff --git a/scripts/qemu/choose_launch.sh b/scripts/qemu/choose_launch.sh new file mode 100755 index 000000000..0035541cc --- /dev/null +++ b/scripts/qemu/choose_launch.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -E -e -u -o pipefail + +choose=$(/home/martins3/.dotfiles/scripts/qemu/choose.sh inactive) +if [[ -z $choose ]]; then + echo "No vm choosed 😸" + exit 0 +fi +rm -f ~/hack/martins3 +ln -s "$choose" ~/hack/martins3 +/home/martins3/core/vn/docs/qemu/sh/alpine.sh "$*" diff --git a/scripts/qemu/launch.sh b/scripts/qemu/launch.sh index c3bd66878..1b9744713 100755 --- a/scripts/qemu/launch.sh +++ b/scripts/qemu/launch.sh @@ -1,53 +1,120 @@ #!/usr/bin/env bash - set -E -e -u -o pipefail # QEMU 的 -pidfile 在 QEMU 被 pkill 的时候自动删除的,但是如果 QEMU 是 segv 之类的就不会 -pidfile=/tmp/martins3/qemu-pid + +function choose_vm() { + output=$(/home/martins3/.dotfiles/scripts/qemu/choose.sh "$1") + echo "$output" +} + +function kill_qemu() { + vm=$1 + # 不知道为什么,这种方法在 qemu 中失效了 + # gum confirm "Kill $vm ?" && echo "quit" | socat - unix-connect:"$vm/hmp" + gum confirm "Kill $vm ?" && kill -9 "$(cat "$vm"/pid)" +} function close_qemu() { - if [[ -f $pidfile ]]; then - qemu=$(cat $pidfile) - if ps -p "$qemu" >/dev/null; then - gum confirm "Kill the machine?" && kill -9 "$qemu" - fi - else - echo "No Qemu Process found" + vm=$(choose_vm active) + monitor=$vm/hmp + if [[ ! -e $monitor ]]; then + echo "已经豆沙了 🙀" + return fi + kill_qemu "$vm" } -# 使用 screen -r 来进入到 detach 的脚本 function debug_kernel() { - close_qemu + vm=$(choose_vm hacking_kernel) + if [[ -z $vm ]]; then + echo "No suitable vm found !" + exit 0 + fi + if [[ -f $vm/pid && -f /proc/$(cat "$vm"/pid)/cmdline ]]; then + if gum confirm "Kill the machine?"; then + kill_qemu "$vm" + else + echo "Give up" + exit 0 + fi + fi + # 使用 screen -r 来进入到 detach 的脚本 screen -d -m /home/martins3/core/vn/docs/qemu/sh/alpine.sh -s /home/martins3/core/vn/docs/qemu/sh/alpine.sh -k - close_qemu + kill_qemu "$vm" } -function login() { - close_qemu - screen -d -m /home/martins3/core/vn/docs/qemu/sh/alpine.sh - # 等 QEMU 将启动,将端口暴露出来,不然访问还是 host 的 5556, - # 会立刻得到一个 Connection refused - sleep 1 - ssh -p5556 root@localhost - close_qemu +function ssh_to_guest() { + vm=$(choose_vm active) + if [[ -z $vm ]]; then + echo "No active vm found 🐕" + exit 0 + fi + port=$(cat "$vm"/port) + if [[ -f "$vm"/user ]]; then + user=$(cat "$vm"/user) + else + user=root + fi + # @todo 似乎我的 tmux 配置有问题导致 ssh 前需要设置一下环境变量 + TERM=xterm-256color ssh -p"$port" "$user"@localhost +} + +function copy_ssh() { + vm=$(choose_vm active) + port=$(cat "$vm"/port) + if [[ -f "$vm"/user ]]; then + user=$(cat "$vm"/user) + else + user=root + fi + TERM=xterm-256color ssh-copy-id -p"$port" "$user"@localhost } -while getopts "dk" opt; do +function monitor() { + echo "TODO" +} + +function console() { + echo "TODO" +} + +function open_vnc() { + vm=$(choose_vm active) + if [[ -n $vm ]]; then + port=$(cat "$vm"/port) + id=$((port - 4000 + 6000)) + microsoft-edge http://127.0.0.1:$id/vnc.html + fi +} + +function qemu_top() { + pids=($(pgrep 'qemu')) + top "${pids[@]/#/-p }" +} + +while getopts "dkvsct" opt; do case $opt in d) debug_kernel - exit 0 ;; k) close_qemu - exit 0 + ;; + s) + ssh_to_guest + ;; + v) + open_vnc + ;; + c) + copy_ssh + ;; + t) + qemu_top ;; *) cat /home/martins3/.dotfiles/scripts/qemu/luanch.sh - exit 0 ;; esac done - -login diff --git a/scripts/systemd/debug-mem.config b/scripts/systemd/debug-mem.config deleted file mode 100644 index 2b3da091d..000000000 --- a/scripts/systemd/debug-mem.config +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG_CONSTRUCTORS=y -CONFIG_GENERIC_CSUM=y -CONFIG_KASAN_SHADOW_OFFSET=0xdffffc0000000000 -CONFIG_STACKDEPOT_ALWAYS_INIT=y -CONFIG_KASAN=y -CONFIG_KASAN_GENERIC=y -CONFIG_KASAN_OUTLINE=y -# CONFIG_KASAN_INLINE is not set -CONFIG_KASAN_STACK=y -# CONFIG_KASAN_VMALLOC is not set -# CONFIG_KASAN_MODULE_TEST is not set - -# 分析下 CONFIG_VMAP_STACK=y 是做什么的 -# 打开 KASAN 之后,这个选项就消失了 diff --git a/scripts/systemd/martins3.config b/scripts/systemd/martins3.config index b6ac21ab1..cb8913cc0 100644 --- a/scripts/systemd/martins3.config +++ b/scripts/systemd/martins3.config @@ -215,7 +215,7 @@ CONFIG_CRYPTO_LIB_CHACHA20POLY1305=y # soft lockup / hard lockup CONFIG_LOCKUP_DETECTOR=y CONFIG_SOFTLOCKUP_DETECTOR=y -CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC=y +# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set CONFIG_HARDLOCKUP_DETECTOR_PERF=y CONFIG_HARDLOCKUP_DETECTOR=y @@ -389,18 +389,6 @@ CONFIG_TRACER_SNAPSHOT=y CONFIG_TRACER_SNAPSHOT_PER_CPU_SWAP=y # CONFIG_MMIOTRACE_TEST is not set -CONFIG_RCU_EXPERT=y -# CONFIG_FORCE_TASKS_RCU is not set -# CONFIG_FORCE_TASKS_RUDE_RCU is not set -# CONFIG_FORCE_TASKS_TRACE_RCU is not set -CONFIG_RCU_FANOUT=64 -CONFIG_RCU_FANOUT_LEAF=16 -# CONFIG_RCU_BOOST is not set -CONFIG_RCU_NOCB_CPU=y -CONFIG_RCU_NOCB_CPU_DEFAULT_ALL=y -# CONFIG_TASKS_TRACE_RCU_READ_MB is not set -# CONFIG_RCU_LAZY is not set - CONFIG_PCI_STUB=y CONFIG_PCI_PF_STUB=y CONFIG_PCI_IOV=y @@ -592,3 +580,18 @@ CONFIG_HOTPLUG_PCI_ACPI=y CONFIG_NET_DEVLINK=y CONFIG_NETDEVSIM=y + +CONFIG_LWTUNNEL=y +CONFIG_LWTUNNEL_BPF=y + + +CONFIG_SCSI_SAS_LIBSAS=y +CONFIG_SCSI_SAS_ATA=y +CONFIG_SCSI_SAS_HOST_SMP=y + +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +CONFIG_IKHEADERS=y +CONFIG_HWLAT_TRACER=y + +# CONFIG_AUDIT is not set diff --git a/scripts/systemd/revert-build-fast.py b/scripts/systemd/revert-build-fast.py index f2a94d70c..6def521c4 100755 --- a/scripts/systemd/revert-build-fast.py +++ b/scripts/systemd/revert-build-fast.py @@ -22,6 +22,8 @@ def repalce_include_with_file(working_dir, file): r2 = re.findall(r"# include \"(.*\.c)\"", l) # kernel/rcu/tree.c 中最后的几个 .h 展开就是这个样子的 r3 = re.findall(r"#include \"(tree_.*\.h)\"", l) + # kernel/rcu/update.c 包含的 .h + r4 = re.findall(r"#include \"(tasks.h)\"", l) source_files = None if r1: @@ -30,6 +32,8 @@ def repalce_include_with_file(working_dir, file): source_files = r2[0] if r3: source_files = r3[0] + if r4: + source_files = r4[0] if source_files: l = "// ============> " + l @@ -64,6 +68,7 @@ def revert(working_dir: str, file: str) -> str: dir = "kernel/rcu/" reverted_file.append(revert(dir, "tree.c")) + reverted_file.append(revert(dir, "update.c")) for file in reverted_file: subprocess.run(["git", "add", file]) diff --git a/scripts/systemd/sync-kernel.sh b/scripts/systemd/sync-kernel.sh index 5f86b3761..fb4ca2c22 100755 --- a/scripts/systemd/sync-kernel.sh +++ b/scripts/systemd/sync-kernel.sh @@ -8,6 +8,9 @@ function finish { fi } +use_llvm="LLVM=1" +use_llvm="" + trap finish EXIT kcov=${ENABLE_KCOV-} @@ -20,8 +23,13 @@ else git clone https://github.com/torvalds/linux cd linux ln -sf /home/martins3/.dotfiles/scripts/nix/env/linux.nix default.nix + echo "use nix" >> .envrc && direnv allow fi +# 内核中很多位置都是存在 trailing whilespace 的,如果设置了这个选项 +# 很多文件会被自动修改,导致从头开始编译 +sed -i "s/trim_trailing_whitespace = true//" .editorconfig + cores=$(getconf _NPROCESSORS_ONLN) threads=$cores @@ -49,17 +57,25 @@ done cp /home/martins3/.dotfiles/scripts/systemd/martins3.config kernel/configs/martins3.config cp /home/martins3/.dotfiles/scripts/systemd/kconv.config kernel/configs/kconv.config +function run() { + if [[ -d /nix ]]; then + nix-shell --command "$1" + else + eval "$1" + fi +} + SECONDS=0 if [[ ${kcov} ]]; then - nix-shell --command "make mrproper" - nix-shell --command "make defconfig kvm_guest.config martins3.config kconv.config -j O=kcov" - nix-shell --command "nice -n 19 make -j$threads O=kcov" + run "make mrproper" + run "make defconfig kvm_guest.config martins3.config kconv.config -j O=kcov" + run "nice -n 19 make -j$threads O=kcov" else # make clean - nix-shell --command "make clean" - nix-shell --command "make defconfig kvm_guest.config martins3.config -j" - # nix-shell --command "chrt -i 0 make CC='ccache gcc' -j$threads" - nix-shell --command "chrt -i 0 make -j$threads" + # run "make clean" + run "make $use_llvm defconfig kvm_guest.config martins3.config -j" + # run "chrt -i 0 make CC='ccache gcc' -j$threads" + run "chrt -i 0 make $use_llvm -j$threads" # python3 /home/martins3/.dotfiles/scripts/systemd/revert-build-fast.py # scripts/systemd/expand-paging_tmpl.sh for i in "${special_files[@]}"; do @@ -79,11 +95,12 @@ fi # 编译文档的速度太慢了,不想每次都等那么久 if [[ ! -d /home/martins3/core/linux/Documentation/output ]]; then - nix-shell --command "make htmldocs -j$(($(getconf _NPROCESSORS_ONLN) - 1))" + run "make htmldocs -j$(($(getconf _NPROCESSORS_ONLN) - 1))" fi -nix-shell --command "./scripts/clang-tools/gen_compile_commands.py" +run "./scripts/clang-tools/gen_compile_commands.py" +sed -i 's/-mabi=lp64//g' compile_commands.json -# nix-shell --command "make binrpm-pkg -j$(($(getconf _NPROCESSORS_ONLN) - 1))" +# run "make binrpm-pkg -j$(($(getconf _NPROCESSORS_ONLN) - 1))" # Documentation/conf.py 中修改主题 html_theme = 'sphinx_rtd_theme' diff --git a/scripts/systemd/sync-qemu.sh b/scripts/systemd/sync-qemu.sh index 7125b5a3c..f3ee94954 100755 --- a/scripts/systemd/sync-qemu.sh +++ b/scripts/systemd/sync-qemu.sh @@ -28,8 +28,17 @@ if [[ $branch != master ]]; then echo "checkout to master" fi -git restore --staged .gitignore -git checkout -- .gitignore +special_files=( + .gitignore + hw/virtio/meson.build + hw/virtio/virtio.c +) +for i in "${special_files[@]}"; do + echo "$i" + git restore --staged "$i" + git checkout -- "$i" +done +rm -f hw/virtio/virtio-dummy.c git pull @@ -40,20 +49,27 @@ cat <<_EOF >>.gitignore compile_commands.json default.nix .envrc +perf.data _EOF +git apply /home/martins3/.dotfiles/scripts/systemd/virtio-dummy.diff +ln -f /home/martins3/core/vn/code/module/qemu-virtio-dummy.c hw/virtio/virtio-dummy.c + +special_files+=(hw/virtio/virtio-dummy.c) +for i in "${special_files[@]}"; do + git add "$i" +done cores=$(getconf _NPROCESSORS_ONLN) threads=$((cores - 1)) - # --disable-tcg # --enable-trace-backends=nop mkdir -p /home/martins3/core/qemu/instsall -QEMU_options=" --prefix=martins3 --target-list=x86_64-softmmu --disable-werror --enable-gtk --enable-libusb" +QEMU_options=" --target-list=$(uname -m)-softmmu --disable-werror --enable-gtk --enable-libusb" QEMU_options+=" --enable-virglrenderer --enable-opengl --enable-numa --enable-virtfs --enable-libiscsi" QEMU_options+=" --enable-virtfs" -# 使用 clang 构建内核存在两个问题 +# 使用 clang 构建 qemu 存在两个问题 # 1. 大量的警告,并且必须 -Wno-error=unused-command-line-argument # 2. 似乎之后在命令行中 make 就会失败 # diff --git a/scripts/systemd/virtio-dummy.diff b/scripts/systemd/virtio-dummy.diff new file mode 100644 index 000000000..ccf436a77 --- /dev/null +++ b/scripts/systemd/virtio-dummy.diff @@ -0,0 +1,26 @@ +diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build +index d7f18c96e60e..9b162756a2d9 100644 +--- a/hw/virtio/meson.build ++++ b/hw/virtio/meson.build +@@ -81,6 +81,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu-pci. + virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem-pci.c')) + virtio_pci_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev-pci.c')) + virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MD', if_true: files('virtio-md-pci.c')) ++virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MD', if_true: files('virtio-dummy.c')) + + specific_virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss) + +diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c +index d229755eae58..f2f5488dcfee 100644 +--- a/hw/virtio/virtio.c ++++ b/hw/virtio/virtio.c +@@ -193,7 +193,8 @@ const char *virtio_device_names[] = { + [VIRTIO_ID_PARAM_SERV] = "virtio-param-serv", + [VIRTIO_ID_AUDIO_POLICY] = "virtio-audio-pol", + [VIRTIO_ID_BT] = "virtio-bluetooth", +- [VIRTIO_ID_GPIO] = "virtio-gpio" ++ [VIRTIO_ID_GPIO] = "virtio-gpio", ++ [42] = "virtio-dummy" + }; + + static const char *virtio_id_to_name(uint16_t device_id) diff --git a/sheet.md b/sheet.md index 5ec3f9681..83bb759db 100644 --- a/sheet.md +++ b/sheet.md @@ -1,3 +1,4 @@ +## edit - "| 单位 | 向左移动 | 向右移动 | 向左删除 | 向右删除 |" - "| 字符 | Ctrl + B | Ctrl + F | Ctrl + H | Ctrl + D |" @@ -33,12 +34,27 @@ - git ls-files --others --exclude-standard >> .gitignore - 将没有被跟踪的文件添加到 .gitignore 中 - git reset : 将所有的内容 unstage -- git checkout -- fs/ : 将 unstage 的修改删除掉 +- git restore . : 将 unstage 的修改删除掉 + +### 如何修改一个特定的 commit + +参考: https://stackoverflow.com/questions/1186535/how-do-i-modify-a-specific-commit + +简而言之就是: +```sh +git rebase --interactive bbc643cd~ +# pick 修改为 edit +# 推出 vim +# 修改内容,并且 git add +git commit --amend --signoff +git rebase --continue +``` ### submodule + - git submodule update --recursive -### git log +### log - git log --format="%h --> %B" - git log -S path/to/file : 如果 git blame 一个已经被删除的内容 @@ -65,7 +81,7 @@ - -> 在一个特定的 commit 上打 tag - git tag tagname fb24344513a2ce7dd870c8b002485ded9758d475 -### git patch +### patch 将 patch 直接作为一个 commit,而不是 diff 信息 -v 是参数个数。 @@ -76,19 +92,25 @@ - git format-patch -1 -v # 说明 patch 的版本 - git am -### git fuzzy am +### fuzzy am git am /path/to/some.patch patch -p1 < /path/to/some.patch git add . git am --continue +或者 +git apply --rej -### git checkout to remote branch +### checkout to remote branch git fetch git switch dev +### autostash + +git pull --rebase --autostash + ## redirect - https://wizardzines.com/comics/redirects/ @@ -125,8 +147,7 @@ git switch dev ## dd -- dd if=/dev/zero of=pmem count=4 bs=10M # 基本测试 -- dd if=ubuntu-22.04.2-desktop-amd64.iso of=/dev/sdc # 使用 dd 安装系统 +- dd if=/dev/zero of=pmem oflag=direct count=4 bs=10M # 基本测试 ## ps @@ -141,10 +162,10 @@ git switch dev - "调试方法 echom 然后 :message 查看,注意不能是 echo" -## nvim: +## nvim - vim.api.nvim_err_writeln("hello \n") -- 不要忘记 \n -- nvim "+let g:auto_session_enabled = v:false" -c ":e mm/gup.c" -c "lua vim.loop.new_timer():start(1000 _ 60 _ 30, 0, vim.schedule_wrap(function() vim.api.nvim_command(\"exit\") end))" +- nvim "+let g:auto*session_enabled = v:false" -c ":e mm/gup.c" -c "lua vim.loop.new_timer():start(1000 * 60 \_ 30, 0, vim.schedule_wrap(function() vim.api.nvim_command(\"exit\") end))" - \r 是换行 - :%s/$/abc/ 来给每一行的最后增加 abc @@ -192,19 +213,45 @@ git switch dev - 让 sudo https://unix.stackexchange.com/questions/83191/how-to-make-sudo-preserve-path ## ssh + - kill unresponsive hung SSH session : `~.` ## rg -rg -l blk_update_request +rg -l blk_update_request ## wget + 递归拷贝: https://stackoverflow.com/questions/273743/using-wget-to-recursively-fetch-a-directory-with-arbitrary-files-in-it - ## fd + fd 使用的是 regex + ```sh fd ".*\.md" | wc -l ``` + +## xargs + +-t : 将要执行的命令打印出来 +-I % : 设置参数为 % + +```sh +ls | xargs -t -I % sh -c 'echo %' +``` + +将一个仓库中所有的 apples 替换为 oranges + +```sh +git grep -l 'apples' | xargs sed -i 's/apples/oranges/g' +``` + +将 foo 下所有的 txt 都删除 + +```sh +find ./foo -type f -name "*.txt" -exec rm {} \; +find ./foo -type f -name "*.txt" | xargs rm +find . -type f -print | xargs stat -c '%a %n' +``` diff --git a/shell/awk.md b/shell/awk.md deleted file mode 100644 index 9bdfb6e8d..000000000 --- a/shell/awk.md +++ /dev/null @@ -1,21 +0,0 @@ -## awk - -https://awk.readthedocs.io/en/latest/chapter-one.html -[官方文档](https://www.gnu.org/software/gawk/manual/gawk.html) - - -```txt -➜ tldr awk -➜ cheat awk -``` - -[极客学院](http://wiki.jikexueyuan.com/project/awk/) - -[正确的教程](https://gregable.com/2010/09/why-you-should-know-just-little-awk.html) - -https://news.ycombinator.com/item?id=23048054 : 20min 分钟的 awk - - -## https://github.com/learnbyexample/learn_gnuawk - -/home/shen/Downloads/learn_gnuawk/gnu_awk.md diff --git a/shell/bash.md b/shell/bash.md deleted file mode 100644 index b7c28e528..000000000 --- a/shell/bash.md +++ /dev/null @@ -1,479 +0,0 @@ -# 如何彻底征服 bash script - -![](https://preview.redd.it/8a7tpszpdgj41.png?width=640&height=360&crop=smart&auto=webp&s=04e05726a9bb67ff47a8599101931409953859a0) - -## 我很忙,不想听这么多废话 - - -## 背景 -大一升大二的暑假中,一个大佬帮我安装了 Linux,之后的几周时间逐渐熟悉并喜欢上了 shell 的使用, -但是我最近发现自己的对于 shell 下水平还是停留在那个暑假,干什么都需要 stackoverflow 一下, -一个问题总是在重复的查询,写一个 100 行的 bash script 需要一个上午。这种状况真的让人暴跳如雷。 - -我的之前的对于 bash 错误认识: -1. bash 不重要。人的手动操作是不可靠的,不可复现的,难以快速复制给其他人的,对于大多数人来说,批处理脚本非常重要,尤其是你打算写几十年的代码的时候。 -2. bash 自然而然就会掌握,无需额外的花时间掌握。至少对于我来说,不是,必须刻意学习才可以。 -3. 不要使用 Python C 语言和 bash 类比。 - -## bash script 的设计思想 -对于 shell 编程,大致可以分为两个部分: -- 具体的工具,例如 git ipcs 之类的 -- bash script - -一个工具做好一件事情,而 bash 将工具粘合起来,高效的完成各种事情。 - -bash 的设计思想: -- bash 处理的是各种命令的组合,而且需要足够简洁 - - 命令的输入输出都是 string - - bash 中几乎没有数据类型,任何内容都是 string - - 对于数值需要特殊的语法和命令 - - `[[ -eq ]]`,`$(())` 以及 `bc` - - bash 将字符串处理的工作都交给 awk, sed,grep 和 cut 了 -- bash 需要足够简洁 - - 利用 pipe - - 没有异常处理 - - 没有面向对象 - - 没有结构体 - - 数据结构支持优先,只有 array 和 associated array - - 使用了大量的缩写,例如 !! !$ $! - -bash 没有设计出来过多的错误防护机制,几乎没什么人用 bash 写打项目。 - -## bash 奇怪的地方 -局部变量 : 只有函数中的局部变量,但是没有 for 循环中的局部变量 - -## bash 设计失误 -也许是我理解不到位 - -1. bash 使用 = 来作为相等判断,这导致bash 的赋值 `=` 两侧不能有空格。 - -## 1. 打好基础 -[Bash 脚本教程](https://wangdoc.com/bash/index.html) - -## 问题 -1. pstree -p - -注意到你可以控制每行参数个数(-L)和最大并行数(-P) - -最有用的大概就是 !$, 它用于指代上次键入的参数,而 !! 可以指代上次键入的命令了 - -## [ ] http://mywiki.wooledge.org/BashPitfalls - -1. Filenames with leading dashes - - cp -- "$file" "$target" : 使用 -- 来处理 - -2. 不可以同时打开和重定向同一个文件 - - cat file | sed s/foo/bar/ > file :这个会导致 file 中的内容为空,最简单的是使用一个中间符号来代替。 - -3. & 本身就是一个结束符号 - - `for i in {1..10}; do ./something &; done` : 将 & 后的 ; 去掉 - -@todo 从这里继续吧 -```txt -34. if [[ $foo = $bar ]] (depending on intent) -``` - -## [ ] https://mywiki.wooledge.org/BashFAQ - -## echo 的额外用法 -1. -n 参数可以取消末尾的回车符 -2. -e 参数会解释引号(双引号和单引号)里面的特殊字符(比如换行符\n - -## 如何输出一个字符串 -在 bash 中 \ 会让下一行和上一行放到一起来解释,体会一下下面的两个命令的差别: -```sh -echo "one two - three" - -echo "one two \ - three" - -echo one two \ - three - -echo one two - three -``` - -- https://stackoverflow.com/questions/13335516/how-to-determine-whether-a-string-contains-newlines-by-using-the-grep-command - -## 变量 -- [indirect expansion](https://unix.stackexchange.com/questions/41292/variable-substitution-with-an-exclamation-mark-in-bash) -```sh -hello_world="value" -# Create the variable name. -var="world" -ref="hello_$var" -# Print the value of the variable name stored in 'hello_$var'. -printf '%s\n' "${!ref}" -``` - -```sh -var="world" -declare "hello_$var=value" -printf '%s\n' "$hello_world" -``` - -## 有用的变量 - -## 一个括号是不是足够逆天 -https://unix.stackexchange.com/questions/306111/what-is-the-difference-between-the-bash-operators-vs-vs-vs - -## eval 和 exec 的区别 -https://unix.stackexchange.com/questions/296838/whats-the-difference-between-eval-and-exec/296852 - -功能都非常变态: -- eval 相当于执行这个字符串 -- exec 将当前的 bash 替换为执行程序 - -## 常用工具 - -### awk -### pushd 和 popd -- https://unix.stackexchange.com/questions/77077/how-do-i-use-pushd-and-popd-commands - -- 从左边进入 -- 最左边的就是当前的目录 -- pushd x 会进入到 x 中 - -在 zsh 中,是自动打开 `setopt autopushd` -https://serverfault.com/questions/35312/unable-to-understand-the-benefit-of-zshs-autopushd 的, -这导致 cd 的行为和 pushd 相同。 - - -### [ ] https://effective-shell.com/part-2-core-skills/job-control/ - -## 一些资源 -- [forgit](https://github.com/wfxr/forgit) A utility tool powered by fzf for using git interactively -- [Bash web server](https://github.com/dzove855/Bash-web-server/) : 只有几百行的 web server 使用 bash 写的 :star: -- [Write a shell in C](https://brennan.io/2015/01/16/write-a-shell-in-c/) : 自己动手写一个 shell -- [Pure bash bible](https://github.com/dylanaraps/pure-bash-bible) - -## 一些博客 -- [window powershell 和 bash 的对比](https://vedipen.com/2020/linux-bash-vs-windows-powershell/) - -## shell 资源推荐 -1. https://devhints.io/bash : 语法清单 -2. https://explainshell.com/ : 给出一个 shell 命令,对于其进行解释 -3. https://wangchujiang.com/linux-command/ -## 一些小技巧 -- [alias](https://thorsten-hans.com/5-types-of-zsh-aliases) -- [自动回答交互式的 shell script](https://askubuntu.com/questions/338857/automatically-enter-input-in-command-line) - -## zsh 的技巧 -- take 创建并且进入目录 -- ctrl-x e 进入编辑模式 - -## 一些库 -- [gum](https://github.com/charmbracelet/gum) -- https://github.com/bats-core/bats-core : bash 测试框架 - -## 冷知识 -- [locate vs find](https://unix.stackexchange.com/questions/60205/locate-vs-find-usage-pros-and-cons-of-each-other) - - locate 只是比 find 更快而已 -- 使用 mv /tmp/gafsdfa/fadafsdf{aaa,bb}.png 来实现 rename -- [根据 shell 启动的不同,加载的配置的文件不同](https://cjting.me/2020/08/16/shell-init-type/) - - 存在 login 和 non-login ,interactive 和 non-interactive 之分 -- [Shell 启动类型探究](https://cjting.me/2020/08/16/shell-init-type/) : 不错不错,讲解 bash 的启动 - -## 获取帮助 -1. whatis -2. tldr -3. cheat.sh -4. apropos 模糊查询 man - -## 有趣 -- https://github.com/mydzor/bash2048/blob/master/bash2048.sh : 300 行的 2048 - - -- 输入 top 10 的命令,但是没看懂 -```sh -history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10 -``` - -## shellcheck 也是有问题的 -1. common.sh 可以解决一下吗? - -## [ ] 整理一下 coprocess 的内容 - -## glob 中和字符串当时是使用的正则表达式吧 - -1. glob 中是否支持 [a,b]* -2. glob 只能处理文件是吗? - 3. 字符串比较的时候也是可以的 - -## 任何时候都不要使用 [ -https://stackoverflow.com/questions/3427872/whats-the-difference-between-and-in-bash - -## 整理下如下内容 -- bash 的替代品: https://github.com/oilshell/oil/wiki/Alternative-Shells - -真的见过无数个 bash 最佳实践的文章,说实话,为什么一个语言如此放纵非最佳实践。 - -## shellcheck 让我必须将所有的变量全部使用双引号包含进来 -- http://www.oilshell.org/release/latest/doc/idioms.html#new-long-flags-on-the-read-builtin - -## 迷茫啊,这个会因为双引号警告的 -```txt - if [[ ! $i =~ ".*debug.*" ]]; then - rpm_extract $i - fi -``` - -## 高级话题 -### 如何理解这个 -```sh -bash <(curl -L zellij.dev/launch) 这个命令如何理解? -``` - -## grep 和 egrep 的差别 -- https://stackoverflow.com/questions/18058875/difference-between-egrep-and-grep - - [ ] 对于 regex 的理解又成为了问题。 -- https://unix.stackexchange.com/questions/17949/what-is-the-difference-between-grep-egrep-and-fgrep - - 还有 fgrep - -## 等于号叫我再次做人 -```c -if ! [[ $number =~ $re ]] ; then - echo "not a number" -fi -``` -可以写成这个吗? -```c -if [[ ! $number =~ $re ]] ; then - echo "not a number" -fi -``` - -多个链接到一起,如何 -```c -if [[ ! $number =~ $re ]] ; then - echo "not a number" -fi -``` - -## 整理一下: - - 为什么这里必须存在一个双引号! - -## 实际上,我们发现 bash 的一个 philosophy -- 很多常用命令不是熟练使用,还是痛苦面具 - - https://dashdash.io/ - - -## 一个 AWK 痛苦面具问题 -```sh -set -E -e -u -o pipefail -grep vendor_id /proc/cpuinfo | awk 'NR==1{print $0; exit}' -grep flags /proc/cpuinfo | awk 'NR==1{print $0; exit}' -``` -我发现第一个 awk 不会让 exit non-zero,而第二个会。 - - -## 重点分析下 find 命令 -### 如何 flatten 一个目录 -- https://unix.stackexchange.com/questions/52814/flattening-a-nested-directory -- find . -type f -exec ls '{}' + - - 所有的参数一次执行 -- find . -type f -exec ls '{}' \; - - 对于每一个文件,分别 fork 出来执行 -- find . -type f -execdir ls '{}' + - - 切换到对应的目录执行 - -```txt - -exec command ; - Execute command; true if 0 status is returned. All following arguments to find are taken to be arguments to - the command until an argument consisting of `;' is encountered. The string `{}' is replaced by the current - file name being processed everywhere it occurs in the arguments to the command, not just in arguments where - it is alone, as in some versions of find. Both of these constructions might need to be escaped (with a `\') - or quoted to protect them from expansion by the shell. See the EXAMPLES section for examples of the use of - the -exec option. The specified command is run once for each matched file. The command is executed in the - starting directory. There are unavoidable security problems surrounding use of the -exec action; you should - use the -execdir option instead. - - -exec command {} + - This variant of the -exec action runs the specified command on the selected files, but the command line is - built by appending each selected file name at the end; the total number of invocations of the command will be - much less than the number of matched files. The command line is built in much the same way that xargs builds - its command lines. Only one instance of `{}' is allowed within the command, and it must appear at the end, - immediately before the `+'; it needs to be escaped (with a `\') or quoted to protect it from interpretation - by the shell. The command is executed in the starting directory. If any invocation with the `+' form re‐ - turns a non-zero value as exit status, then find returns a non-zero exit status. If find encounters an er‐ - ror, this can sometimes cause an immediate exit, so some pending commands may not be run at all. For this - reason -exec my-command ... {} + -quit may not result in my-command actually being run. This variant of - -exec always returns true. -``` - -## 神奇的双引号 -如果是在 ${} 和 $() 中,是可以继续使用双引号的 - -## https://stackoverflow.com/questions/7442417/how-to-sort-an-array-in-bash - -## dirname 和 basename - -## 文件处理 - -了解如何使用 sort 和 uniq,包括 uniq 的 -u 参数和 -d 参数,具体内容在后文单行脚本节中。另外可以了解一下 comm。 - -了解如何使用 cut,paste 和 join 来更改文件。很多人都会使用 cut,但遗忘了 join。 - -了解如何运用 wc 去计算新行数(-l),字符数(-m),单词数(-w)以及字节数(-c)。 - -了解 sort 的参数。显示数字时,使用 -n 或者 -h 来显示更易读的数(例如 du -h 的输出)。明白排序时关键字的工作原理(-t 和 -k)。例如,注意到你需要 -k1,1 来仅按第一个域来排序,而 -k1 意味着按整行排序。稳定排序(sort -s)在某些情况下很有用。例如,以第二个域为主关键字,第一个域为次关键字进行排序,你可以使用 sort -k1,1 | sort -s -k2,2。 - -## awk - - awk '{ x += $3 } END { print x }' myfile - - egrep -o 'acct_id=[0-9]+' access.log | cut -d= -f2 | sort | uniq -c | sort -rn - -## 总结 job control -- hohup command & -- fg -- bg - -## ~ 和 $HOME 的区别 -https://askubuntu.com/questions/1177464/difference-between-home-and - -- $HOME is an environment variable -- ~ is a shell expansion symbol - -让我们回忆一下: - -> 这种特殊字符的扩展,称为模式扩展(globbing)。其中有些用到通配符,又称为通配符扩展(wildcard expansion)。Bash 一共提供八种扩展。 - -启动第一个扩展就是波浪线扩展。 - -所以,区别就是: -arg_virtio="-drive aio=native,,file=~/hack/iso/virtio-win-0.1.208.iso,media=cdrom,index=2" -中的 ~ 是无法被展开的。 - -所以,你不能在 C 语言中使用 -```c -int fd = open("~/abc.txt", O_RDWR | O_CREAT, 0644); -``` - -## bash 一个复杂的原因 - -有些功能是 bash 内置的, -但是外部工具也可以做的。 - -例如: https://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script - -但是,实际上,也可以用 sed - -## https://github.com/johnkerl/miller - -## subshell - -```txt -COMMAND EXECUTION ENVIRONMENT - The shell has an execution environment, which consists of the following: - - • open files inherited by the shell at invocation, as modified by redirections supplied to the exec builtin - - • the current working directory as set by cd, pushd, or popd, or inherited by the shell at invocation - - • the file creation mode mask as set by umask or inherited from the shell's parent - - • current traps set by trap - - • shell parameters that are set by variable assignment or with set or inherited from the shell's parent in the environment - - • shell functions defined during execution or inherited from the shell's parent in the environment - - • options enabled at invocation (either by default or with command-line arguments) or by set - - • options enabled by shopt - - • shell aliases defined with alias - - • various process IDs, including those of background jobs, the value of $$, and the value of PPID - - When a simple command other than a builtin or shell function is to be executed, it is invoked in a separate execution environment that consists of the following. Unless otherwise noted, the values are inherited from the shell. - - • the shell's open files, plus any modifications and additions specified by redirections to the command - - • the current working directory - - • the file creation mode mask - - • shell variables and functions marked for export, along with variables exported for the command, passed in the environment - - • traps caught by the shell are reset to the values inherited from the shell's parent, and traps ignored by the shell are ignored - - A command invoked in this separate environment cannot affect the shell's execution environment. - - Command substitution, commands grouped with parentheses, and asynchronous commands are invoked in a subshell environment that is a duplicate of the shell environment, except that traps caught by the shell are reset to the values that the - shell inherited from its parent at invocation. Builtin commands that are invoked as part of a pipeline are also executed in a subshell environment. Changes made to the subshell environment cannot affect the shell's execution environment. - - Subshells spawned to execute command substitutions inherit the value of the -e option from the parent shell. When not in posix mode, bash clears the -e option in such subshells. - - If a command is followed by a & and job control is not active, the default standard input for the command is the empty file /dev/null. Otherwise, the invoked command inherits the file descriptors of the calling shell as modified by redi‐ - rections. - -``` - -```sh -set -e -function b() { - cat /abc - cat /abc -} - -function a() { - cat abc || true - - b # 如果直接调用 b ,那么 b 中第一个就失败 - a=$(b) # 但是如果是这种调用方法,b 中失败可以继续 -} - -a -``` -## 看看这个 -https://www.panix.com/~elflord/unix/grep.html#why - -## 一个符号,多种场景语义不同的 - -https://unix.stackexchange.com/questions/47584/in-a-bash-script-using-the-conditional-or-in-an-if-statement - -```txt -if [ "$fname" = "a.txt" ] || [ "$fname" = "c.txt" ] -``` - -但是 `ls a || ls` 中的 `||` 则是表示第一个命令失败,那么执行第二个。 - - -## bash 中没有 bool -但是存在 true 和 false command - -但是 a=true 这个时候 true 是 string 而已 -https://stackoverflow.com/questions/2953646/how-can-i-declare-and-use-boolean-variables-in-a-shell-script - - -## glob 自动失败的是偶 - -```sh -QEMU_PID_DIR="/var/run/libvirt/qemu" - -for i in "$QEMU_PID_DIR"/*.pid; do - echo $i -done -``` -如果一个文件都没有,echo $i 得到 -/var/run/libvirt/qemu/*.pid - - -## glob 语法和 regex 的差别让人真的很烦 -```sh -disk=nvme0n1 -disk=${disk%%[0-9]*} -echo $disk # 得到的居然是 nvme ,因为 * 表示拼配任何字符 -``` - -## TODO : nvim/snippets/sh.snippets 中的 note_cmpstring 需要重写下 - -## 看看这个 blog ,深入理解下 shell -https://a-wing.top/shell/2021/05/01/sh-compatibles-history : 一共三篇 - -## 哈哈,的确,bash 只是适合原型验证而已 -https://benjamincongdon.me/blog/2023/10/29/Avoid-Load-bearing-Shell-Scripts/ diff --git a/shell/free.sh b/shell/free.sh deleted file mode 100755 index 5f4bcf15c..000000000 --- a/shell/free.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -E -e -u -o pipefail - -fff=fa - -[[ "fafafa" =~ ^$fff ]] && echo "1" -[[ "fafafa" =~ "^$fff" ]] && echo "2" -[[ "fafafa" == "$fff" ]] && echo "3" -[[ "fafafa" == $fff ]] && echo "4" -[[ "fafafa" =~ "$fff" ]] && echo "5" diff --git a/shell/nu.md b/shell/nu.md deleted file mode 100644 index fb29b0151..000000000 --- a/shell/nu.md +++ /dev/null @@ -1,143 +0,0 @@ -我是一个 hn 的忠实粉丝, 时不时可以看到 nushell 相关的文章, -https://hn.algolia.com/?q=nushell -尝试之后,感觉问题很多。 - -## 问题 -1. 没有 linter 将静态检查集成到 nvim 中 -2. && || 之后被 and 和 or 替代才对 -3. 自动补全中,man 无法处理 -4. () 的文档找到一下 - -## 差别 -1. 没有 &&,任何错误都是导致返回,如果想要容忍,增加 nu - - https://github.com/nushell/nushell/issues/4139 -2. 获取命令的输出 () 而不是 $() - - print $"(ls)" -- 这个会执行 ls 命令的 - print $"($command)" -- 这个才是 - print $"$command" -- 输出 $command - print "($command)" - print "$command" - -```nu - $"username : (git config user.name)" - $"email : (git config user.email)" -``` - -## 可以提的问题 -zoxide 的初始化脚本有问题 - -## 常见问题 -- string : $"$(name)" - - 小括号存在特殊含义的 - -> It's easy to pipe text-speaking tools into Nu pipelines, and there's a built-in `lines` command that will split line-break-delimited text into a list of strings. - -## let 的赋值似乎让代码非常难以理解了 - -```nu -let name = [] -for n in $database { - # $name | append $n.name - # echo $n.name - name = ($name | prepend $n.name) -} -``` - -## 没有 format,没有 shellcheck ,好难受 -- [ ] 不能贴着函数名字 - -## [ ] 为什么 module 不可以使用啊 -比如这个官方的例子: -```nu -module commands { - def animals [] { - ["cat", "dog", "eel" ] - } - - export def my-command [animal: string@animals] { - print $animal - } -} -``` - -## [ ] 如何实现多级命令的自动补全 -- 例如 sx switch how-to-go - -## 没有 switch - -## record 获取数值 -如果 record 的参数是一个下标,这个无法通过检查的 -```c -$images.$i # 不可以 -let image_name = ($images | select $i) # 不可以 -``` -## nu-check --debug 结果完全是错的 - -## parse 的正则完全无法理解 -- https://www.nushell.sh/commands/docs/parse.html -- "a b c" 都无法轻易的处理 - - 还是得靠 awk - - -## 这个功能无法实现的特别丑 -```c -make -j`nproc` bindeb-pkg -``` -这就是 bash 的灵活之处。 - -## 这个命令无法支持 - -git am --keep-cr --signoff < ../b.diff - -nushell 正则无法自动补全 - -## 内置的 mv 无法 move 多个成员 -- mv a.diff a.sh b.diff `2023-3-14/` 这个代码是会报错的 - -## 内置的 ps 不知道如何替换回来 -而且内置的 ps 功能很弱 - -## kill -l 这个命令会出错 - -## 命令不存在的时候,zsh 下的提示更加科学 - -## ps 命令的替换,实在是太傲慢了 -- ps 的复杂程度,不是他可以理解的 - -## 似乎 python 的这个也不支持 - -```txt -python -m venv .venv -source .venv/bin/activate -``` -https://github.com/nushell/nushell/issues/852 - -## 返回值和常规语言不同 -```nu -def foo [] { return 12 } - -foo -``` - -## 如果一个命令返回为 non-zero ,那么必须借助 complete 非常烦人 - -## 没有 nufmt -https://github.com/nushell/nushell/issues/3938 - -## 其实补全系统其实还行 -相比而言,zsh 的补全似乎复杂很多 -- https://unix.stackexchange.com/questions/239528/dynamic-zsh-autocomplete-for-custom-commands -- https://zsh.sourceforge.io/Doc/Release/Completion-System.html - -## 报错提示有问题 - -zsh 可以实现如下效果,但是 nu 不可以 -```txt -🧀 cpuid -1 -The program 'cpuid' is not in your PATH. It is provided by several packages. -You can make it available in an ephemeral shell by typing one of the following: - nix-shell -p cpuid - nix-shell -p haskellPackages.hlibcpuid - nix-shell -p msr-tools -``` diff --git a/shell/regex.md b/shell/regex.md deleted file mode 100644 index b8378156c..000000000 --- a/shell/regex.md +++ /dev/null @@ -1,91 +0,0 @@ -# Regex -## 基本学习路线 -阅读[这个文档](https://github.com/ziishaned/learn-regex/blob/master/translations/README-cn.md) - -但是更加推荐[交互式的教程](https://regexlearn.com/zh-cn) 和 [图形化演示](https://devtoolcafe.com/tools/regex#!flags=img&re=) - -学习完成之后,通过这个[教程配套的 checksheet](https://regexlearn.com/zh-cn/cheatsheet) 来复习 - -用于[测试和解释 regex 的网站](https://regexr.com/) - -[将 regex 转化为](https://www.autoregex.xyz/) - - -## https://matt.might.net/articles/sculpting-text - -grep 默认情况下是 BRE -- the operators {}, (), +, | and ? must be escaped with \ - -- basic regular expressions (BRE); -- extended regular expressions (ERE); and -- Perl-compatible regular expressions (PCRE). - -## 问题 -1. 直接 - -## 笔记 -一些特殊字符用来指定一个字符在文本中重复的次数。它们分别是加号 +、星号 * 和问号 ?。 - - 我们在字符后面加上 *,表示一个字符完全不匹配或可以匹配多次。 - - 为了表示一个字符出现的确切次数,我们在该字符的末尾,将它出现的次数写进大括号 {} 中,如 {n} - -- 单词 ha 和 haa 分组如下。第一组用 \1 来避免重复书写。这里的 1 表示分组的顺序。请在表达式的末尾键入 \2 以引用第二组。 - - 括号 (?: ): 非捕获分组 - - 竖线 : 出现在 () 中,表示多个的或,和 [] 不同,那个只是表示为字符集合 -- ^ 在 [] 中表示取反,在整个表达式中表示开始 -- \w 表示数字 字母 和 下划线 -- \d 数值 -- \s 空白字符 -- 正向先行断言: (?=) -- 负向先行断言: (?!) -- 正向后行断言: (?<=) -- 标志: global multiline insensitive -- * 是默认的贪婪匹配,但是 *? 是 lazy 匹配 -- `[[:space:]]` - -## vim 的差别 -vim 中使用 regex 参考[这个总结](https://learnbyexample.gitbooks.io/vim-reference/content/Regular_Expressions.html) - -注意默认的时候,`+` `?` `{}` 需要通过 `\+` `\?` `\{}` 来访问,而 `()` 和 `|` 是不支持的。 - -就需要使用 magic ooption, 通过 `:h \v` 查询[^1]。 - -https://thevaluable.dev/vim-advanced/ - -vim 中删除 trailing space 的命令 `:%s/\s\+$/` - -## bash 的扩展模式的差别 - -| | regex | expansion | -|----|--------------------------|----------------------------------------------------------| -| ? | 让表达式可选 | 一个字符 | -| * | 零个或者多个 | 字符代表文件路径里面的任意数量的任意字符,包括零个字符。 | -| [] | 括号之中的任意一个字符。 | 相同 | -| {} | 描述个数 | 大括号扩展{...}表示分别扩展成大括号里面的所有值 | - -在字符串的替换使用的是 expansion -```c -str=aaabbb -echo ${str/?/sss} -``` - -## 有趣的文摘 -- [使用 swift 打造一个自己的 regex 引擎](https://kean.blog/post/lets-build-regex) -- [melody : 一个可以编译为 regex 的语言](https://github.com/yoav-lavi/melody) - -## 实在不行,使用 gpt 吧 - -## \d -ag "smartx.\d+," 可以使用 \d ,但是 sed 不可以 - -## 才意识到,vim 的 regex 和其他的都不同 -https://vi.stackexchange.com/questions/2268/are-vims-regex-magics-compatible-with-well-known-regex-classes - -感觉默认是 PCRE,但是只是在 \ 上存在一些操作。 -## 搞清楚 sed 的基本用法 -- -i : 本地替换 - -## 那么请问 -- telescope 中的正则是什么样子的,可以调整吗? - -## find 也是可以调整的为 regex 的 -https://stackoverflow.com/questions/6844785/how-to-use-regex-with-find-command diff --git a/shell/regex.sh b/shell/regex.sh deleted file mode 100644 index 9adb77ef1..000000000 --- a/shell/regex.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash - -set -E -e -u -o pipefail -# shopt -s inherit_errexit -# PROGNAME=$(basename "$0") -# PROGDIR=$(readlink -m "$(dirname "$0")") -for i in "$@"; do - echo "$i" -done -cd "$(dirname "$0")" - -testfile=./test.txt - -function slash() { - printf "%030d\n" "0" -} - -function egrep_vs_grep() { - # \1 来捕获第一个,也就是 () 的第一次匹配的内容 - grep -e '^\(.*\)\1$' $testfile - # 如果使用 -E 无需 - grep -E '^(.*)\1\(\)$' $testfile -} - -function capture() { - grep -E '(ab){2}' $testfile - # FIXME 非捕获组 ? - # 这个运行会出错 - grep -E '(?:ab){2}' $testfile -} - -function learn_sed() { - sed -E 's/[ch]at/ball/g' $testfile - slash - sed -E 's/(emacs)/\1 is bad/g' $testfile - - # 增加是在下一行的 - slash - lines="abc\n" - lines+="cde" - sed -E "/(emacs)/a $lines" $testfile - - # 增加整个文件 - sed "/cdef/r nu.md" $testfile -} - -function learn_rg() { - rg "[0-9]" $testfile - rg "\d" $testfile - grep -E "[0-9]" $testfile - grep -E "\d" $testfile - grep -P "\d" $testfile -} - -function learn_find() { - # find 使用的是 glob - find "*regex.sh" -} - -egrep_vs_grep diff --git a/shell/systhesis.md b/shell/systhesis.md deleted file mode 100644 index 7cf66c805..000000000 --- a/shell/systhesis.md +++ /dev/null @@ -1,112 +0,0 @@ -# 如何战胜 bash - - -为什么是"战胜"而不是"学会" bash ,我们先来学几个 bash 基本语法。 - -1. 非常相似的语法? -2. 这也可以,那也可以 -3. 和主流出入过大 -4. 默认行为不可控 - - -[官方文档](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html) 几乎没有什么意义 - -stackoverflow 是有一个问题: [如何将 string 拆分为数组](https://stackoverflow.com/questions/10586153/how-to-split-a-string-into-an-array-in-bash), -看完各个回答之后,我的感受就是为什么要设计的这么复杂。 - -[oh my zsh](https://github.com/ohmyzsh/ohmyzsh),我强烈推荐使用 zsh - - -## 各种工具也非常难 -[modern unix](https://github.com/ibraheemdev/modern-unix) 的项目也是总结了一大堆。 -- https://github.com/agarrharr/awesome-cli-apps -- https://github.com/alebcay/awesome-shell - -## 很多简单的 -1. 浮点加减 - -## 其他的替代项目 -实际上,不过谢天 -https://github.com/xonsh/xonsh - - -最近注意到了 nushell ,然后大约花费了两三个小时将以前的 oh-my-zsh 脚本切换过来,现在总结下这些年在 - -https://news.ycombinator.com/item?id=34588340 - -开发环境搭建: -- https://github.com/LhKipp/nvim-nu - -## [ ] 命令和符号的区别 - -## if -比较字符串,数值 和 文件使用 -```sh -if [[ "$a" == "$b" ]];then - echo "same" -fi -``` - -静态类型系统中,一个比较符号可以在不同操作数下存在不同的含义,例如 `>` 可以表示数字大于,也可以表示字符串排序。 -但是 bash 没有类型系统,需要使用不同的比较符来区分比较对象。 - -但是判断命令是否成功的标志的形式是: -```sh -if cat somefile; then - echo "same" -fi -``` - -## 数值类型太弱了 -仅仅支持整数,不然就是 awk 或者 bc -$((1 + 2)) - -还需要手动判断是不是整数: -is_uint() { case $1 in '' | *[!0-9]*) return 1 ;; esac } - -### 如果你确实希望使用 regex ,但是又不想 bash 报错 -a=$(echo *.md) -echo "$a" - -## 恐怖的双引号 -在对于含有空格的可以采用双引号包围,但是 $var 的时候自动去掉双引号 - -可以使用这个成员: -```txt -var="cpu family" -grep "$var" /proc/cpuinfo # 这个没有问题,被展开为 grep 'cpu family' /proc/cpuinfo -grep $var /proc/cpuinfo # 这个有问题,被展开为 grep cpu family /proc/cpuinfo -``` - -## 关键参考 -- https://mywiki.wooledge.org/BashFAQ -- http://mywiki.wooledge.org/BashPitfalls - - - -## 方法 - -### 一个 template -其他的都比较容易理解,但是除了 -[set -E ](https://stackoverflow.com/questions/64852814/in-bash-shell-e-option-explanation-what-does-any-trap-inherited-by-a-subshell) - -1. shell functions -2. command substitutions -3. subshell - -bash 在 subshell 中会去掉 set -e 的属性,但是可以 `inherit_errexit` 将 - -```txt -inherit_errexit - If set, command substitution inherits the value of the errexit option, instead of unsetting it in the subshell environment. This option is enabled when posix mode is enabled. -``` - -### 不要被 posix 分心 - -bash 才是标准,posix 不是! - -bash 中的 --posix 也不用理会。 - -## 看看这个 -https://www.micahlerner.com/2021/07/14/unix-shell-programming-the-next-50-years.html -https://medium.com/fundbox-engineering/cheating-at-a-company-group-activity-using-unix-tools-5c1d706f3d58 diff --git a/shell/test.txt b/shell/test.txt deleted file mode 100644 index 321159eed..000000000 --- a/shell/test.txt +++ /dev/null @@ -1,9 +0,0 @@ -abc -cde -abab -abab() -hat -cat -emacs -abcefg -1234 diff --git a/shell/text.md b/shell/text.md deleted file mode 100644 index 5ff9cbf67..000000000 --- a/shell/text.md +++ /dev/null @@ -1,28 +0,0 @@ -# unix 文本处理 - -学一次,忘一次 - -- https://learnbyexample.github.io/cli_text_processing_coreutils/tr.html : 讲解各种 text processing 的事情,值得单独作为一个章节来分析。 - -## tr - -- 大小写转换 -```sh -tr '[:lower:]' '[:upper:]'