From 8f9fdda2bb28b0991450dec61fce979b8fcf5757 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ryan4yin=20=7C=20=E4=BA=8C=E8=8A=B1?= Date: Thu, 1 Oct 2026 19:42:20 +0800 Subject: [PATCH] refactor: trim unused virtualisation config and packages (#332) --- home/base/core/core.nix | 5 -- home/base/tui/cloud/default.nix | 22 ++---- home/base/tui/container.nix | 18 ++--- home/base/tui/dev-tools.nix | 15 +--- home/base/tui/editors/packages.nix | 1 - home/linux/gui/base/creative.nix | 49 +++---------- home/linux/gui/base/desktop-tools.nix | 6 +- hosts/12kingdoms-shoryu/preservation.nix | 4 +- hosts/12kingdoms-youko/default.nix | 3 + hosts/idols-ai/default.nix | 3 + hosts/idols-ai/preservation.nix | 6 +- lib/genVmHostModule.nix | 4 ++ modules/README.md | 2 +- modules/base/packages.nix | 17 +---- modules/nixos/base/packages.nix | 7 -- modules/nixos/desktop/containers.nix | 24 +++++++ modules/nixos/desktop/virtualisation.nix | 88 ------------------------ 17 files changed, 71 insertions(+), 203 deletions(-) create mode 100644 modules/nixos/desktop/containers.nix delete mode 100644 modules/nixos/desktop/virtualisation.nix diff --git a/home/base/core/core.nix b/home/base/core/core.nix index 94fe50bf..4f6e2b66 100644 --- a/home/base/core/core.nix +++ b/home/base/core/core.nix @@ -6,16 +6,11 @@ # it provides the command `nom` works just like `nix # with more details log output nix-output-monitor - hydra-check # check hydra(nix's build farm) for the build status of a package nix-index # A small utility to index nix store paths - nix-init # generate nix derivation from url - # https://github.com/nix-community/nix-melt - nix-melt # A TUI flake.lock viewer # https://github.com/utdemir/nix-tree nix-tree # A TUI to visualize the dependency graph of a nix derivation # misc - cowsay gnupg caddy # A webserver with automatic HTTPS via Let's Encrypt(replacement of nginx) # A fast and polyglot tool for code searching, linting, rewriting at large scale diff --git a/home/base/tui/cloud/default.nix b/home/base/tui/cloud/default.nix index 808e9868..d57153b3 100644 --- a/home/base/tui/cloud/default.nix +++ b/home/base/tui/cloud/default.nix @@ -9,25 +9,13 @@ home.file.".terraformrc".source = ./terraformrc; home.packages = with pkgs; [ - # infrastructure as code - # pulumi - # pulumictl - # tf2pulumi - # crd2pulumi - # pulumiPackages.pulumi-random - # pulumiPackages.pulumi-command - # pulumiPackages.pulumi-aws-native - # pulumiPackages.pulumi-language-go - # pulumiPackages.pulumi-language-python - # pulumiPackages.pulumi-language-nodejs - # doctl # digitalocean aliyun-cli # aws awscli2 - ssm-session-manager-plugin # Amazon SSM Session Manager Plugin + # ssm-session-manager-plugin # Amazon SSM Session Manager Plugin aws-iam-authenticator - eksctl + # eksctl # google cloud (pkgs-stable.google-cloud-sdk.withExtraComponents ( @@ -36,12 +24,12 @@ gke-gcloud-auth-plugin ] )) - google-cloud-sql-proxy + # google-cloud-sql-proxy google-alloydb-auth-proxy # cloud tools that nix do not have cache for. terraform - terraformer # generate terraform configs from existing cloud resources - packer # machine image builder + # terraformer # generate terraform configs from existing cloud resources + # packer # machine image builder ]; } diff --git a/home/base/tui/container.nix b/home/base/tui/container.nix index 7744137c..f8f859d1 100644 --- a/home/base/tui/container.nix +++ b/home/base/tui/container.nix @@ -8,9 +8,16 @@ home.packages = with pkgs; [ podman-compose dive # explore docker layers - lazydocker # Docker terminal UI. - skopeo # copy/sync images between registries and local storage - go-containerregistry # provides `crane` & `gcrane`, it's similar to skopeo + + # `skopeo`: inspect/move images between registries and local formats + # (oci / dir / docker-archive) without a daemon; also supports sync + signing. + # skopeo list-tags docker://nginx # list tags + # skopeo inspect docker://nginx:latest # inspect, no pull + # skopeo copy docker://src:1 docker://dst:1 # registry -> registry + # skopeo copy --all docker://src:1 docker://dst:1 # every architecture + # skopeo copy docker://nginx:latest oci:/tmp/n:latest + # skopeo sync --src docker --dest dir nginx /tmp/n + skopeo kubectl kustomize @@ -18,19 +25,14 @@ kubectx # kubectx & kubens kubie # same as kubectl-ctx, but per-shell (won’t touch kubeconfig). kubectl-view-secret # kubectl view-secret - kubectl-tree # kubectl tree kubectl-node-shell # exec into node kubepug # kubernetes pre upgrade checker kubectl-cnpg # cloudnative-pg's cli tool - kubebuilder istioctl - clusterctl # for kubernetes cluster-api pkgs-2505.kubernetes-helm fluxcd # argocd - - ko # build go project to container image ]; programs.k9s.enable = true; diff --git a/home/base/tui/dev-tools.nix b/home/base/tui/dev-tools.nix index ab3f6fd3..9c0db845 100644 --- a/home/base/tui/dev-tools.nix +++ b/home/base/tui/dev-tools.nix @@ -20,14 +20,14 @@ [ colmena # nixos's remote deployment tool - tokei # count lines of code, alternative to cloc - # db related # mycli pgcli - mongosh sqlite + # spreadsheets / data files: interactive viewer for csv, xlsx, tsv, json, sqlite + visidata + # embedded development minicom @@ -35,18 +35,9 @@ python313Packages.huggingface-hub # huggingface-cli yt-dlp # youtube/bilibili/soundcloud/... video/music downloader - # misc - devbox - bfg-repo-cleaner # remove large files from git history - k6 # load testing tool - - # solve coding extercises - learn by doing - exercism - # Automatically trims your branches whose tracking remote refs are merged or gone # It's really useful when you work on a project for a long time. git-trim - gitleaks ] # conda is not available on macOS ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ diff --git a/home/base/tui/editors/packages.nix b/home/base/tui/editors/packages.nix index 0fc28836..ce60bf08 100644 --- a/home/base/tui/editors/packages.nix +++ b/home/base/tui/editors/packages.nix @@ -30,7 +30,6 @@ #-- markdown marksman # language server for markdown - glow # markdown previewer pandoc # document converter pkgs-master.hugo # static site generator diff --git a/home/linux/gui/base/creative.nix b/home/linux/gui/base/creative.nix index f71c7d46..4b275a40 100644 --- a/home/linux/gui/base/creative.nix +++ b/home/linux/gui/base/creative.nix @@ -1,5 +1,4 @@ { - lib, pkgs, pkgs-stable, pkgs-master, @@ -19,46 +18,14 @@ let }; in { - home.packages = - with pkgs-stable; - [ - # creative - # gimp # image editing, I prefer using figma in browser instead of this one - inkscape # vector graphics - krita # digital painting - musescore # music notation - pkgs-master.orca-slicer # 3d printer slicer app - bambu-studio # bambu 3d printer slicer app - pkgs-blender.blender # 3d modeling - # reaper # audio production - # sonic-pi # music programming - - # 2d game design - # aseprite # Animated sprite editor & pixel art tool - - # this app consumes a lot of storage, so do not install it currently - # kicad # 3d printing, electrical engineering - - # Astronomy - stellarium # See what you can see with your eyes, binoculars or a small telescope. - celestia # Real-time 3D simulation of space, travel throughout the solar system. - - # office - libreoffice-qt-still - hunspell # spell check for libreoffice - hunspellDicts.en_US # USA English - hyphenDicts.en_GB # British English - ] - ++ (lib.optionals pkgs.stdenv.hostPlatform.isx86_64 [ - ldtk # A modern, versatile 2D level editor - - # fpga - # python313Packages.apycula # gowin fpga - # yosys # fpga synthesis - # nextpnr # fpga place and route - # openfpgaloader # fpga programming - # nur-ryan4yin.packages.${pkgs.stdenv.hostPlatform.system}.gowin-eda-edu-ide # app: `gowin-env` => `gw_ide` / `gw_pack` / ... - ]); + home.packages = with pkgs-stable; [ + # creative + krita # digital painting + musescore # music notation + pkgs-master.orca-slicer # 3d printer slicer app + bambu-studio # bambu 3d printer slicer app + pkgs-blender.blender # 3d modeling + ]; programs = { # live streaming diff --git a/home/linux/gui/base/desktop-tools.nix b/home/linux/gui/base/desktop-tools.nix index 4c34f7f5..1a4e6f99 100644 --- a/home/linux/gui/base/desktop-tools.nix +++ b/home/linux/gui/base/desktop-tools.nix @@ -17,14 +17,12 @@ home.packages = with pkgs; [ wl-clipboard # copying and pasting - hyprpicker # color picker brightnessctl - # audio - alsa-utils # provides amixer/alsamixer/... # screen recording wf-recorder # screen recording - virt-viewer # vnc connect to the libvirt VMs + virt-manager # manage the libvirt VMs + virt-viewer # vnc/spice console for the libvirt VMs ]; # Emergency session-menu fallback; the normal flow uses Noctalia's session panel. diff --git a/hosts/12kingdoms-shoryu/preservation.nix b/hosts/12kingdoms-shoryu/preservation.nix index d01ff513..11daf975 100644 --- a/hosts/12kingdoms-shoryu/preservation.nix +++ b/hosts/12kingdoms-shoryu/preservation.nix @@ -17,8 +17,8 @@ in boot.initrd.systemd.enable = true; environment.systemPackages = [ - # `sudo ncdu -x /` - pkgs.ncdu + # `sudo gdu -x /` + pkgs.gdu ]; # NOTE: `preservation` only mounts the directory/file list below to /persistent diff --git a/hosts/12kingdoms-youko/default.nix b/hosts/12kingdoms-youko/default.nix index 2ae8d79e..34fab148 100644 --- a/hosts/12kingdoms-youko/default.nix +++ b/hosts/12kingdoms-youko/default.nix @@ -59,6 +59,9 @@ in modules.btrbk.enable = true; + # HDD tuning/diagnostics for the two spinning disks behind the USB-SATA bridge. + environment.systemPackages = [ pkgs.hdparm ]; + # Beelink GTR5: Radeon iGPU. The ROCm build of btop shows the GPU panel; # node_exporter's drm collector exposes its utilization/VRAM. modules.btop.package = pkgs.btop-rocm; diff --git a/hosts/idols-ai/default.nix b/hosts/idols-ai/default.nix index e6324701..2abdd882 100644 --- a/hosts/idols-ai/default.nix +++ b/hosts/idols-ai/default.nix @@ -62,6 +62,9 @@ in modules.btrbk.enable = true; + # QEMU/KVM(HostCpuOnly) for local VMs. + environment.systemPackages = [ pkgs.qemu_kvm ]; + powerManagement.resumeCommands = '' # Insta360 Link may stay enumerated with a stalled UVC endpoint after S3 resume. ${pkgs.coreutils}/bin/sleep 1 diff --git a/hosts/idols-ai/preservation.nix b/hosts/idols-ai/preservation.nix index bfc08805..84e5c992 100644 --- a/hosts/idols-ai/preservation.nix +++ b/hosts/idols-ai/preservation.nix @@ -18,8 +18,10 @@ in boot.initrd.systemd.enable = true; environment.systemPackages = [ - # `sudo ncdu -x /` - pkgs.ncdu + # Whole-filesystem disk usage (`-x` stays on one filesystem): + # sudo gdu -n -x / # non-interactive, plain text + # sudo gdu -o /tmp/gdu.json / # JSON export + pkgs.gdu ]; # There are two ways to clear the root filesystem on every boot: diff --git a/lib/genVmHostModule.nix b/lib/genVmHostModule.nix index 2b2c0b28..a1d62d0a 100644 --- a/lib/genVmHostModule.nix +++ b/lib/genVmHostModule.nix @@ -60,6 +60,10 @@ in # Validate Hardware Virtualization Support via: # virt-host-validate qemu libvirt + + # QEMU/KVM(HostCpuOnly) for the libvirt domains and the microVMs; provides + # qemu-kvm, qemu-img, qemu-nbd, ... + qemu_kvm ]; networking = { diff --git a/modules/README.md b/modules/README.md index 70609583..dd5d5ea0 100644 --- a/modules/README.md +++ b/modules/README.md @@ -56,7 +56,7 @@ modules/ │ ├── power.nix # Power management │ ├── security.nix # Desktop security settings │ ├── ssh.nix # Desktop SSH configuration - │ ├── virtualisation.nix # Virtualization support + │ ├── containers.nix # Container engines (podman/docker) │ └── xdg.nix # XDG base directory settings └── server/ # Server-specific modules ├── qemu-guest-hardware-configuration.nix diff --git a/modules/base/packages.nix b/modules/base/packages.nix index 757b2b04..2a717dd2 100644 --- a/modules/base/packages.nix +++ b/modules/base/packages.nix @@ -19,11 +19,6 @@ git # used by nix flakes git-lfs # used by huggingface models - # system monitoring - procs # a moreden ps - # btop is provided per host: the GPU-aware `modules.btop` build on NixOS, or - # Home Manager on macOS. Not listed here to avoid a second, plain copy. - # archives zip xz @@ -41,7 +36,6 @@ jq # A lightweight and flexible command-line JSON processor yq-go # yaml processor https://github.com/mikefarah/yq - jc # converts the output of popular cli tools & file-types to JSON, YAML # Interactively filter its input using fuzzy searching, not limit to filenames. fzf @@ -52,26 +46,19 @@ (ripgrep.override { withPCRE2 = true; }) duf # Disk Usage/Free Utility - a better 'df' alternative - dust # A more intuitive version of `du` in rust - gdu # disk usage analyzer(replacement of `du`) - ncdu # analyzer your disk usage Interactively, via TUI(replacement of `du`) + gdu # disk usage analyzer, non-interactive (`-n`) & JSON (`-o`) # networking tools mtr # A network diagnostic tool(traceroute) gping # ping, but with a graph(TUI) dnsutils # `dig` + `nslookup` - ldns # replacement of `dig`, it provide the command `drill` doggo # DNS client for humans - wget curl - curlie # curl with httpie - httpie + xh # friendly, fast curl-like HTTP client (Rust) aria2 # A lightweight multi-protocol & multi-source command-line download utility socat # replacement of openbsd-netcat nmap # A utility for network discovery and security auditing - ipcalc # it is a calculator for the IPv4/v6 addresses iperf3 # network performance test - hyperfine # command-line benchmarking tool tcpdump # network sniffer # file transfer diff --git a/modules/nixos/base/packages.nix b/modules/nixos/base/packages.nix index 6d76311f..0ad80e22 100644 --- a/modules/nixos/base/packages.nix +++ b/modules/nixos/base/packages.nix @@ -5,22 +5,16 @@ environment.systemPackages = with pkgs; [ # system call monitoring strace # system call monitoring - ltrace # library call monitoring lsof # list open files # ebpf related tools # https://github.com/bpftrace/bpftrace bpftrace # powerful tracing tool - bpftop # monitor BPF programs - bpfmon # BPF based visual packet rate monitor # system monitoring sysstat iotop-c - iftop - nmon sysbench - systemctl-tui pv # pipe view # system tools @@ -29,7 +23,6 @@ ethtool pciutils # lspci usbutils # lsusb - hdparm # for disk performance, command dmidecode # a tool that reads information about your system's hardware from the BIOS according to the SMBIOS/DMI standard parted smartmontools # smartctl -a /dev/nvme0n1 diff --git a/modules/nixos/desktop/containers.nix b/modules/nixos/desktop/containers.nix new file mode 100644 index 00000000..3f12e63f --- /dev/null +++ b/modules/nixos/desktop/containers.nix @@ -0,0 +1,24 @@ +{ ... }: +{ + ################################################################################### + # + # Containers - Podman + # + ################################################################################### + + virtualisation = { + podman = { + enable = true; + # Create a `docker` alias for podman, to use it as a drop-in replacement + dockerCompat = true; + # Required for containers under podman-compose to be able to talk to each other. + defaultNetwork.settings.dns_enabled = true; + # Periodically prune Podman resources + autoPrune = { + enable = true; + dates = "weekly"; + flags = [ "--all" ]; + }; + }; + }; +} diff --git a/modules/nixos/desktop/virtualisation.nix b/modules/nixos/desktop/virtualisation.nix deleted file mode 100644 index fee0b9e9..00000000 --- a/modules/nixos/desktop/virtualisation.nix +++ /dev/null @@ -1,88 +0,0 @@ -{ - pkgs, - # nur-ataraxiasjel, - ... -}: -{ - ################################################################################### - # - # Virtualisation - Libvirt(QEMU/KVM) / Docker / LXD / WayDroid - # - ################################################################################### - - # Enable nested virtualization, required by security containers and nested vm. - # This should be set per host in /hosts, not here. - # - ## For AMD CPU, add "kvm-amd" to kernelModules. - # boot.kernelModules = ["kvm-amd"]; - # boot.extraModprobeConfig = "options kvm_amd nested=1"; # for amd cpu - # - ## For Intel CPU, add "kvm-intel" to kernelModules. - # boot.kernelModules = ["kvm-intel"]; - # boot.extraModprobeConfig = "options kvm_intel nested=1"; # for intel cpu - - boot.kernelModules = [ "vfio-pci" ]; - - services.flatpak.enable = true; - - virtualisation = { - docker.enable = false; - podman = { - enable = true; - # Create a `docker` alias for podman, to use it as a drop-in replacement - dockerCompat = true; - # Required for containers under podman-compose to be able to talk to each other. - defaultNetwork.settings.dns_enabled = true; - # Periodically prune Podman resources - autoPrune = { - enable = true; - dates = "weekly"; - flags = [ "--all" ]; - }; - }; - - oci-containers = { - backend = "podman"; - }; - - # Usage: https://wiki.nixos.org/wiki/Waydroid - # waydroid.enable = true; - - # libvirtd = { - # enable = true; - # # hanging this option to false may cause file permission issues for existing guests. - # # To fix these, manually change ownership of affected files in /var/lib/libvirt/qemu to qemu-libvirtd. - # qemu.runAsRoot = true; - # }; - - # lxd.enable = true; - }; - - environment.systemPackages = with pkgs; [ - # This script is used to install the arm translation layer for waydroid - # so that we can install arm apks on x86_64 waydroid - # - # https://github.com/casualsnek/waydroid_script - # https://github.com/AtaraxiaSjel/nur/tree/master/pkgs/waydroid-script - # https://wiki.archlinux.org/title/Waydroid#ARM_Apps_Incompatible - # nur-ataraxiasjel.packages.${pkgs.stdenv.hostPlatform.system}.waydroid-script - - # Need to add [File (in the menu bar) -> Add connection] when start for the first time - # virt-manager - - # QEMU/KVM(HostCpuOnly), provides: - # qemu-storage-daemon qemu-edid qemu-ga - # qemu-pr-helper qemu-nbd elf2dmp qemu-img qemu-io - # qemu-kvm qemu-system-x86_64 qemu-system-aarch64 qemu-system-i386 - qemu_kvm - - # Install QEMU(other architectures), provides: - # ...... - # qemu-loongarch64 qemu-system-loongarch64 - # qemu-riscv64 qemu-system-riscv64 qemu-riscv32 qemu-system-riscv32 - # qemu-system-arm qemu-arm qemu-armeb qemu-system-aarch64 qemu-aarch64 qemu-aarch64_be - # qemu-system-xtensa qemu-xtensa qemu-system-xtensaeb qemu-xtensaeb - # ...... - qemu - ]; -}