Commit a78403d

HPCesia <me@hpcesia.com>
2025-05-30 12:29:22
init: First commit
Reference https://github.com/ryan4yin/nix-config/ Only basic configs.
home/base/core/editors/helix/default.nix
@@ -0,0 +1,5 @@
+{pkgs, ...}: {
+  programs.helix = {
+    enable = true;
+  };
+}
home/base/core/editors/micro/default.nix
@@ -0,0 +1,5 @@
+{pkgs, ...}: {
+  programs.micro = {
+    enable = true;
+  };
+}
home/base/core/editors/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/base/core/shells/default.nix
@@ -0,0 +1,14 @@
+{
+  config,
+  pkgs,
+  ...
+}: {
+  programs.bash = {
+    enable = true;
+    enableCompletion = true;
+  };
+
+  programs.fish = {
+    enable = true;
+  };
+}
home/base/core/core.nix
@@ -0,0 +1,31 @@
+{pkgs, ...}: {
+  home.packages = with pkgs; [
+    gnupg
+
+    fzf # Interactively filter its input using fuzzy searching, not limit to filenames.
+    fd # search for files by name, faster than find
+    ripgrep # search for files by its content, replacement of grep
+
+    yq-go # yaml processor https://github.com/mikefarah/yq
+    delta # A viewer for git and diff output
+    lazygit # Git terminal UI.
+  ];
+
+  programs = {
+    # A command-line fuzzy finder
+    fzf = {
+      enable = true;
+    };
+
+    # zoxide is a smarter cd command, inspired by z and autojump.
+    # It remembers which directories you use most frequently,
+    # so you can "jump" to them in just a few keystrokes.
+    # zoxide works on all major shells.
+    zoxide = {
+      enable = true;
+      enableBashIntegration = true;
+      enableZshIntegration = true;
+      enableNushellIntegration = true;
+    };
+  };
+}
home/base/core/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/base/core/git.nix
@@ -0,0 +1,53 @@
+{
+  config,
+  lib,
+  pkgs,
+  myvars,
+  ...
+}: {
+  # `programs.git` will generate the config file: ~/.config/git/config
+  # to make git use this config file, `~/.gitconfig` should not exist!
+  #
+  #    https://git-scm.com/docs/git-config#Documentation/git-config.txt---global
+  home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
+    rm -f ${config.home.homeDirectory}/.gitconfig
+  '';
+
+  home.packages = with pkgs; [
+  ];
+
+  programs.git = {
+    enable = true;
+    lfs.enable = true;
+
+    userName = myvars.userfullname;
+    userEmail = myvars.useremail;
+
+    extraConfig = {
+      init.defaultBranch = "main";
+      trim.bases = "develop,master,main"; # for git-trim
+      push.autoSetupRemote = true;
+      pull.rebase = true;
+
+      # replace https with ssh
+      url = {
+        "ssh://git@github.com/HPCesia" = {
+          insteadOf = "https://github.com/HPCesia";
+        };
+        "ssh://git@codeberg.org/HPCesia" = {
+          insteadOf = "https://codeberg.org/HPCesia";
+        };
+      };
+    };
+
+    # A syntax-highlighting pager in Rust(2019 ~ Now)
+    delta = {
+      enable = true;
+      options = {
+        diff-so-fancy = true;
+        line-numbers = true;
+        true-color = "always";
+      };
+    };
+  };
+}
home/base/core/yazi.nix
@@ -0,0 +1,13 @@
+{pkgs, ...}: {
+  programs.yazi = {
+    enable = true;
+    enableBashIntegration = true;
+    enableFishIntegration = true;
+    settings = {
+      manager = {
+        show_hidden = true;
+        sort_dir_first = true;
+      };
+    };
+  };
+}
home/base/gui/terminals/alacritty/default.nix
@@ -0,0 +1,5 @@
+{pkgs, ...}: {
+  programs.alacritty = {
+    enable = true;
+  };
+}
home/base/gui/terminals/wezterm/default.nix
@@ -0,0 +1,5 @@
+{pkgs, ...}: {
+  programs.wezterm = {
+    enable = true;
+  };
+}
home/base/gui/terminals/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/base/gui/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/base/tui/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/base/tui/ssh.nix
@@ -0,0 +1,5 @@
+{...}: {
+  programs.ssh = {
+    enable = true;
+  };
+}
home/base/home.nix
@@ -0,0 +1,17 @@
+{myvars, ...}: {
+  # Home Manager needs a bit of information about you and the
+  # paths it should manage.
+  home = {
+    inherit (myvars) username;
+
+    # This value determines the Home Manager release that your
+    # configuration is compatible with. This helps avoid breakage
+    # when a new Home Manager release introduces backwards
+    # incompatible changes.
+    #
+    # You can update Home Manager without changing this value. See
+    # the Home Manager release notes for a list of state version
+    # changes in each release.
+    stateVersion = "25.05";
+  };
+}
home/linux/base/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/linux/base/shell.nix
@@ -0,0 +1,25 @@
+{
+  config,
+  myvars,
+  ...
+}: let
+  d = config.xdg.dataHome;
+  c = config.xdg.configHome;
+  cache = config.xdg.cacheHome;
+in rec {
+  home.homeDirectory = "/home/${myvars.username}";
+
+  # environment variables that always set at login
+  home.sessionVariables = {
+    # clean up ~
+    LESSHISTFILE = cache + "/less/history";
+    LESSKEY = c + "/less/lesskey";
+    WINEPREFIX = d + "/wine";
+
+    # set default applications
+    BROWSER = "firefox";
+
+    # enable scrolling in git diff
+    DELTA_PAGER = "less -R";
+  };
+}
home/linux/gui/fcitx5/default.nix
@@ -0,0 +1,22 @@
+{pkgs, ...}: {
+  xdg.configFile = {
+    "fcitx5/profile" = {
+      source = ./profile;
+      # every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile,
+      # so we need to force replace it in every rebuild to avoid file conflict.
+      force = true;
+    };
+  };
+
+  i18n.inputMethod = {
+    enable = true;
+    type = "fcitx5";
+    fcitx5.addons = with pkgs; [
+      fcitx5-rime
+      # needed enable rime using configtool after installed
+      fcitx5-configtool
+      fcitx5-chinese-addons
+      fcitx5-gtk # gtk im module
+    ];
+  };
+}
home/linux/gui/fcitx5/profile
@@ -0,0 +1,17 @@
+[Groups/0]
+# Group Name
+Name=Other
+# Layout
+Default Layout=us
+# Default Input Method
+DefaultIM=rime
+
+[Groups/0/Items/0]
+# Name
+Name=rime
+# Layout
+Layout=
+
+[GroupOrder]
+0=Other
+
home/linux/gui/plasma/apps/firefox/default.nix
@@ -0,0 +1,15 @@
+{pkgs, ...}: {
+  programs.firefox = {
+    enable = true;
+    languagePacks = ["zh-CN" "en-US"];
+
+    policies = {
+      DisableTelemetry = true;
+      DontCheckDefaultBrowser = true;
+    };
+
+    profiles.default = {
+      settings = {};
+    };
+  };
+}
home/linux/gui/plasma/apps/vscode/default.nix
@@ -0,0 +1,5 @@
+{...}: {
+  programs.vscode = {
+    enable = true;
+  };
+}
\ No newline at end of file
home/linux/gui/plasma/apps/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/linux/gui/plasma/options/configs.nix
@@ -0,0 +1,10 @@
+{...}: {
+  programs.plasma.configFile = {
+    kdeglobals = {
+      General = {
+        TerminalApplication = "wezterm start --cwd .";
+        TerminalService = "org.wezfurlong.wezterm.desktop";
+      };
+    };
+  };
+}
home/linux/gui/plasma/options/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/linux/gui/plasma/options/fonts.nix
@@ -0,0 +1,30 @@
+{...}: {
+  # Fonts used here should be added to
+  # [flakeRoot]/modules/nixos/desktop/fonts.nix
+  programs.plasma.fonts = {
+    general = {
+      family = "Source Han Sans SC";
+      pointSize = 11;
+    };
+    fixedWidth = {
+      family = "Maple Mono NF CN";
+      pointSize = 11;
+    };
+    menu = {
+      family = "Source Han Sans SC";
+      pointSize = 11;
+    };
+    small = {
+      family = "Source Han Sans SC";
+      pointSize = 9;
+    };
+    toolbar = {
+      family = "Source Han Sans SC";
+      pointSize = 11;
+    };
+    windowTitle = {
+      family = "Source Han Sans SC";
+      pointSize = 11;
+    };
+  };
+}
home/linux/gui/plasma/default.nix
@@ -0,0 +1,11 @@
+{plasma-manager, ...}: {
+  imports = [
+    plasma-manager.homeManagerModules.plasma-manager
+    ./options
+    ./apps
+  ];
+
+  programs.plasma = {
+    enable = true;
+  };
+}
home/linux/gui/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
home/linux/gui/misc.nix
@@ -0,0 +1,8 @@
+{pkgs, ...}: {
+  home.packages = with pkgs; [
+  ];
+
+  # allow fontconfig to discover fonts and configurations installed through home.packages
+  # Install fonts at system-level, not user-level
+  fonts.fontconfig.enable = false;
+}
home/linux/core.nix
@@ -0,0 +1,8 @@
+{
+  imports = [
+    ../base/core
+    ../base/home.nix
+
+    ./base
+  ];
+}
home/linux/gui.nix
@@ -0,0 +1,11 @@
+{
+  imports = [
+    ../base/core
+    ../base/tui
+    ../base/gui
+    ../base/home.nix
+
+    ./base
+    ./gui
+  ];
+}
home/linux/tui.nix
@@ -0,0 +1,9 @@
+{
+  imports = [
+    ../base/core
+    ../base/tui
+    ../base/home.nix
+
+    ./base
+  ];
+}
hosts/chaser-kevin/boot.nix
@@ -0,0 +1,14 @@
+{...}: {
+  boot.loader = {
+    grub = {
+      enable = true;
+      device = "nodev";
+      efiSupport = true;
+      gfxmodeEfi = "1024x768";
+    };
+    efi = {
+      canTouchEfiVariables = true;
+      efiSysMountPoint = "/boot";
+    };
+  };
+}
hosts/chaser-kevin/default.nix
@@ -0,0 +1,41 @@
+{
+  nixos-hardware,
+  myvars,
+  ...
+}:
+#############################################################
+#
+#  Kevin - NixOS running on ThinkBook 16P 2024
+#  My main computer, with I7-14650HX + RTX4060 Laptop GPU + 48GB memory, for daily use.
+#
+#############################################################
+let
+  hostName = "kevin"; # Define your hostname.
+in {
+  imports = [
+    nixos-hardware.nixosModules.common-cpu-intel
+    nixos-hardware.nixosModules.common-hidpi
+    nixos-hardware.nixosModules.common-pc-laptop
+    nixos-hardware.nixosModules.common-pc-laptop-ssd
+    ./nvidia.nix
+    ./hardware-configuration.nix
+    ./miscs.nix
+    ./boot.nix
+  ];
+
+  networking = {
+    inherit hostName;
+    inherit (myvars.networking) nameservers;
+
+    # desktop need its cli for status bar
+    networkmanager.enable = true;
+  };
+
+  # This value determines the NixOS release from which the default
+  # settings for stateful data, like file locations and database versions
+  # on your system were taken. Itโ€˜s perfectly fine and recommended to leave
+  # this value at the release version of the first install of this system.
+  # Before changing this value read the documentation for this option
+  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
+  system.stateVersion = "25.05"; # Did you read the comment?
+}
hosts/chaser-kevin/hardware-configuration.nix
@@ -0,0 +1,57 @@
+# Do not modify this file!  It was generated by โ€˜nixos-generate-configโ€™
+# and may be overwritten by future invocations.  Please make changes
+# to /etc/nixos/configuration.nix instead.
+{
+  config,
+  lib,
+  pkgs,
+  modulesPath,
+  ...
+}: {
+  imports = [
+    (modulesPath + "/installer/scan/not-detected.nix")
+  ];
+
+  boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "thunderbolt" "usb_storage" "sd_mod" "sdhci_pci"];
+  boot.initrd.kernelModules = [];
+  boot.kernelModules = ["kvm-intel"];
+  boot.extraModulePackages = [];
+
+  fileSystems."/" = {
+    device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
+    fsType = "btrfs";
+    options = ["subvol=root"];
+  };
+
+  fileSystems."/home" = {
+    device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
+    fsType = "btrfs";
+    options = ["subvol=home"];
+  };
+
+  fileSystems."/nix" = {
+    device = "/dev/disk/by-uuid/d1fb32f2-1dc0-435d-ad0f-1de0a121dbef";
+    fsType = "btrfs";
+    options = ["subvol=nix"];
+  };
+
+  fileSystems."/boot" = {
+    device = "/dev/disk/by-uuid/D032-DF36";
+    fsType = "vfat";
+    options = ["fmask=0022" "dmask=0022"];
+  };
+
+  swapDevices = [
+    {device = "/dev/disk/by-uuid/39640e68-8296-4cdb-ab16-b9dfcd4ae743";}
+  ];
+
+  # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
+  # (the default) this is the recommended approach. When using systemd-networkd it's
+  # still possible to use this option, but it's recommended to use it in conjunction
+  # with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
+  networking.useDHCP = lib.mkDefault true;
+  # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
+
+  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
+  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
+}
hosts/chaser-kevin/home.nix
@@ -0,0 +1,1 @@
+{...}: {}
hosts/chaser-kevin/miscs.nix
@@ -0,0 +1,33 @@
+{lib, pkgs, ...}: {
+  # Lid Settings
+  services.logind = {
+    lidSwitch = "hibernate";
+    lidSwitchExternalPower = "lock";
+    lidSwitchDocked = "ignore";
+  };
+
+  # Fingerprint
+  services.fprintd.enable = true;
+  systemd.services.fprintd = {
+    wantedBy = ["multi-user.target"];
+    serviceConfig.Type = "simple";
+  };
+
+  # Bluetooth
+  hardware.bluetooth = {
+    enable = true;
+    powerOnBoot = true;
+  };
+
+  # Cooling management
+  services.thermald.enable = lib.mkDefault true;
+
+  # Touchpad
+  services.libinput.enable = true;
+
+  # Network Manager
+	environment.systemPackages = with pkgs; [ networkmanagerapplet ];
+
+  # โˆš(3200ยฒ + 2000ยฒ) px / 16 in โ‰ƒ 235 dpi
+  services.xserver.dpi = 235;
+}
hosts/chaser-kevin/nvidia.nix
@@ -0,0 +1,38 @@
+{
+  nixos-hardware,
+  config,
+  lib,
+  ...
+}: let
+  nvidiaPackage = config.hardware.nvidia.package; # Nvidia ada lovelace
+in {
+  imports = [
+    nixos-hardware.nixosModules.common-gpu-nvidia
+  ];
+
+  services.xserver.videoDrivers = ["nvidia"]; # will install nvidia-vaapi-driver by default
+  boot.initrd.kernelModules = ["nvidia"];
+  boot.extraModulePackages = [config.boot.kernelPackages.nvidia_x11];
+
+  # Nvidia ada lovelace
+  hardware.nvidia = {
+    modesetting.enable = true;
+    powerManagement.enable = lib.mkDefault true;
+    prime = {
+      intelBusId = "PCI:00:02:0";
+      nvidiaBusId = "PCI:01:00:0";
+    };
+    open = lib.mkOverride 990 (nvidiaPackage ? open && nvidiaPackage ? firmware);
+  };
+
+  hardware.nvidia-container-toolkit.enable = true;
+  hardware.graphics = {
+    enable = true;
+    # needed by nvidia-docker
+    enable32Bit = true;
+  };
+
+  # disable cudasupport before this issue get fixed:
+  # https://github.com/NixOS/nixpkgs/issues/338315
+  nixpkgs.config.cudaSupport = false;
+}
hosts/README.md
lib/attrs.nix
@@ -0,0 +1,46 @@
+# https://github.com/NixOS/nixpkgs/blob/master/lib/attrsets.nix
+{lib, ...}: {
+  # Generate an attribute set from a list.
+  #
+  #   lib.genAttrs [ "foo" "bar" ] (name: "x_" + name)
+  #     => { foo = "x_foo"; bar = "x_bar"; }
+  listToAttrs = lib.genAttrs;
+
+  # Update only the values of the given attribute set.
+  #
+  #   mapAttrs
+  #   (name: value: ("bar-" + value))
+  #   { x = "a"; y = "b"; }
+  #     => { x = "bar-a"; y = "bar-b"; }
+  inherit (lib.attrsets) mapAttrs;
+
+  # Update both the names and values of the given attribute set.
+  #
+  #   mapAttrs'
+  #   (name: value: nameValuePair ("foo_" + name) ("bar-" + value))
+  #   { x = "a"; y = "b"; }
+  #     => { foo_x = "bar-a"; foo_y = "bar-b"; }
+  inherit (lib.attrsets) mapAttrs';
+
+  # Merge a list of attribute sets into one. smilar to the operator `a // b`, but for a list of attribute sets.
+  # NOTE: the later attribute set overrides the former one!
+  #
+  #   mergeAttrsList
+  #   [ { x = "a"; y = "b"; } { x = "c"; z = "d"; } { g = "e"; } ]
+  #   => { x = "c"; y = "b"; z = "d"; g = "e"; }
+  inherit (lib.attrsets) mergeAttrsList;
+
+  # Generate a string from an attribute set.
+  #
+  #   attrsets.foldlAttrs
+  #   (acc: name: value: acc + "\nexport ${name}=${value}")
+  #   "# A shell script"
+  #   { x = "a"; y = "b"; }
+  #     =>
+  #     ```
+  #     # A shell script
+  #     export x=a
+  #     export y=b
+  #    ````
+  inherit (lib.attrsets) foldlAttrs;
+}
lib/default.nix
@@ -0,0 +1,16 @@
+{lib, ...}: {
+  nixosSystem = import ./nixosSystem.nix;
+
+  attrs = import ./attrs.nix {inherit lib;};
+
+  relativeToRoot = lib.path.append ../.;
+  scanPaths = path:
+    builtins.map (f: (path + "/${f}")) (
+      builtins.attrNames (
+        lib.attrsets.filterAttrs (
+          path: _type:
+            (_type == "directory") || ((path != "default.nix") && (lib.strings.hasSuffix ".nix" path))
+        ) (builtins.readDir path)
+      )
+    );
+}
lib/nixosSystem.nix
@@ -0,0 +1,32 @@
+{
+  inputs,
+  lib,
+  system,
+  genSpecialArgs,
+  nixos-modules,
+  home-modules ? [],
+  specialArgs ? (genSpecialArgs system),
+  myvars,
+  ...
+}: let
+  inherit (inputs) nixpkgs home-manager;
+in
+  nixpkgs.lib.nixosSystem {
+    inherit system specialArgs;
+    modules =
+      nixos-modules
+      ++ (
+        lib.optionals ((lib.lists.length home-modules) > 0)
+        [
+          home-manager.nixosModules.home-manager
+          {
+            home-manager.useGlobalPkgs = true;
+            home-manager.useUserPackages = true;
+            home-manager.backupFileExtension = "home-manager.backup";
+
+            home-manager.extraSpecialArgs = specialArgs;
+            home-manager.users."${myvars.username}".imports = home-modules;
+          }
+        ]
+      );
+  }
modules/nixos/base/core.nix
@@ -0,0 +1,18 @@
+{lib, ...}: {
+  boot.loader.systemd-boot = {
+    # we use Git for version control, so we don't need to keep too many generations.
+    configurationLimit = lib.mkDefault 10;
+    # pick the highest resolution for systemd-boot's console.
+    consoleMode = lib.mkDefault "max";
+  };
+
+  boot.loader.timeout = lib.mkDefault 8; # wait for x seconds to select the boot entry
+
+  # for power management
+  services = {
+    power-profiles-daemon = {
+      enable = true;
+    };
+    upower.enable = true;
+  };
+}
modules/nixos/base/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
modules/nixos/base/i18n.nix
@@ -0,0 +1,19 @@
+{
+  # Set your time zone.
+  time.timeZone = "Asia/Shanghai";
+
+  # Select internationalisation properties.
+  i18n.defaultLocale = "en_US.UTF-8";
+
+  i18n.extraLocaleSettings = {
+    LC_ADDRESS = "zh_CN.UTF-8";
+    LC_IDENTIFICATION = "zh_CN.UTF-8";
+    LC_MEASUREMENT = "zh_CN.UTF-8";
+    LC_MONETARY = "zh_CN.UTF-8";
+    LC_NAME = "zh_CN.UTF-8";
+    LC_NUMERIC = "zh_CN.UTF-8";
+    LC_PAPER = "zh_CN.UTF-8";
+    LC_TELEPHONE = "zh_CN.UTF-8";
+    LC_TIME = "zh_CN.UTF-8";
+  };
+}
modules/nixos/base/networking.nix
@@ -0,0 +1,21 @@
+{
+  # Network discovery, mDNS
+  # With this enabled, you can access your machine at <hostname>.local
+  # it's more convenient than using the IP address.
+  # https://avahi.org/
+  services.avahi = {
+    enable = true;
+    nssmdns4 = true;
+    publish = {
+      enable = true;
+      domain = true;
+      userServices = true;
+    };
+  };
+
+  # Use an NTP server located in the mainland of China to synchronize the system time
+  networking.timeServers = [
+    "ntp.aliyun.com" # Aliyun NTP Server
+    "ntp.tencent.com" # Tencent NTP Server
+  ];
+}
modules/nixos/base/nix.nix
@@ -0,0 +1,21 @@
+{
+  lib,
+  nixpkgs,
+  ...
+}: {
+  # to install chrome, you need to enable unfree packages
+  nixpkgs.config.allowUnfree = lib.mkForce true;
+
+  # do garbage collection weekly to keep disk usage low
+  nix.gc = {
+    automatic = lib.mkDefault true;
+    dates = lib.mkDefault "weekly";
+    options = lib.mkDefault "--delete-older-than 7d";
+  };
+
+  # Manual optimise storage: nix-store --optimise
+  # https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
+  nix.settings.auto-optimise-store = true;
+
+  nix.channel.enable = false; # remove nix-channel related tools & configs, we use flakes instead.
+}
modules/nixos/base/user-group.nix
@@ -0,0 +1,31 @@
+{
+  myvars,
+  config,
+  ...
+}: {
+  # Don't allow mutation of users outside the config.
+  users.mutableUsers = false;
+
+  users.groups = {
+    "${myvars.username}" = {};
+  };
+
+  users.users."${myvars.username}" = {
+    # generated by `mkpasswd -m scrypt`
+    # we have to use initialHashedPassword here when using tmpfs for /
+    inherit (myvars) initialHashedPassword;
+    home = "/home/${myvars.username}";
+    isNormalUser = true;
+    extraGroups = [
+      myvars.username
+      "users"
+      "networkmanager"
+      "wheel"
+    ];
+  };
+
+  # root's ssh key are mainly used for remote deployment
+  users.users.root = {
+    inherit (myvars) initialHashedPassword;
+  };
+}
modules/nixos/desktop/default.nix
@@ -0,0 +1,3 @@
+{mylib, ...}: {
+  imports = mylib.scanPaths ./.;
+}
modules/nixos/desktop/fonts.nix
@@ -0,0 +1,53 @@
+{pkgs, ...}: {
+  fonts = {
+    enableDefaultPackages = false;
+    fontDir.enable = true;
+
+    packages = with pkgs; [
+      # noto-fonts
+      # noto-fonts-cjk
+      noto-fonts-emoji
+      # noto-fonts-extra
+
+      source-sans
+      source-serif
+      source-han-sans
+      source-han-serif
+
+      # nerdfonts
+      # https://github.com/NixOS/nixpkgs/blob/nixos-unstable-small/pkgs/data/fonts/nerd-fonts/manifests/fonts.json
+      nerd-fonts.symbols-only # symbols icon only
+
+      maple-mono.NF-CN
+    ];
+
+    # user defined fonts
+    # the reason there's Noto Color Emoji everywhere is to override DejaVu's
+    # B&W emojis that would sometimes show instead of some Color emojis
+    fontconfig.defaultFonts = {
+      serif = ["Source Han Serif SC" "Source Han Serif TC" "Noto Color Emoji"];
+      sansSerif = ["Source Han Sans SC" "Source Han Sans TC" "Noto Color Emoji"];
+      monospace = ["Maple Mono NF CN" "Noto Color Emoji"];
+      emoji = ["Noto Color Emoji"];
+    };
+  };
+
+  # https://wiki.archlinux.org/title/KMSCON
+  services.kmscon = {
+    # Use kmscon as the virtual console instead of gettys.
+    # kmscon is a kms/dri-based userspace virtual terminal implementation.
+    # It supports a richer feature set than the standard linux console VT,
+    # including full unicode support, and when the video card supports drm should be much faster.
+    enable = true;
+    fonts = [
+      {
+        name = "JetBrains Mono";
+        package = pkgs.jetbrains-mono;
+      }
+    ];
+    extraOptions = "--term xterm-256color";
+    extraConfig = "font-size=12";
+    # Whether to use 3D hardware acceleration to render the console.
+    hwRender = true;
+  };
+}
modules/nixos/desktop/misc.nix
@@ -0,0 +1,28 @@
+{
+  config,
+  lib,
+  pkgs,
+  pkgs-unstable,
+  ...
+}: {
+  # add user's shell into /etc/shells
+  environment.shells = with pkgs; [
+    bashInteractive
+    pkgs.fish
+  ];
+  # set user's default shell system-wide
+  users.defaultUserShell = pkgs.bashInteractive;
+
+  # fix for `sudo xxx` in kitty/wezterm/foot and other modern terminal emulators
+  security.sudo.keepTerminfo = true;
+
+  environment.variables = {
+    # fix https://github.com/NixOS/nixpkgs/issues/238025
+    TZ = "${config.time.timeZone}";
+  };
+
+  services = {
+    gvfs.enable = true; # Mount, trash, and other functionalities
+    tumbler.enable = true; # Thumbnail support for images
+  };
+}
modules/nixos/desktop.nix
@@ -0,0 +1,36 @@
+{
+  pkgs,
+  config,
+  lib,
+  myvars,
+  ...
+}:
+with lib; let
+  cfgWayland = config.modules.desktop.wayland;
+  cfgXorg = config.modules.desktop.xorg;
+in {
+  imports = [
+    ./base
+    ../base.nix
+
+    ./desktop
+  ];
+
+  services = {
+    gvfs.enable = true; # Mount, trash, and other functionalities
+    tumbler.enable = true; # Thumbnail support for images
+    xserver = {
+      enable = true;
+      xkb.layout = "us";
+    };
+    displayManager = {
+      sddm.enable = true;
+      autoLogin = {
+        enable = true;
+        user = myvars.username;
+      };
+      defaultSession = "plasma";
+    };
+    desktopManager.plasma6.enable = true;
+  };
+}
modules/base.nix
@@ -0,0 +1,51 @@
+{
+  pkgs,
+  myvars,
+  ...
+}: {
+  environment.variables.EDITOR = "helix";
+  environment.systemPackages = with pkgs; [
+    fastfetch
+    helix
+    micro
+    fish
+    git
+
+    # archives
+    zip
+    xz
+    zstd
+    unzipNLS
+    p7zip
+    gnutar
+
+    # networking tools
+    wget
+    curl
+
+    # misc
+    file
+    tree
+  ];
+
+  users.users.${myvars.username} = {
+    description = myvars.userfullname;
+  };
+
+  nix.settings = {
+    experimental-features = ["nix-command" "flakes"];
+    trusted-users = [myvars.username];
+    substituters = [
+      # cache mirror located in China
+      # "https://mirrors.ustc.edu.cn/nix-channels/store"
+      "https://mirror.sjtu.edu.cn/nix-channels/store"
+      "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
+
+      "https://nix-community.cachix.org"
+    ];
+    trusted-public-keys = [
+      "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
+    ];
+    builders-use-substitutes = true;
+  };
+}
outputs/x86_64-linux/src/kevin.nix
@@ -0,0 +1,33 @@
+{
+  # NOTE: the args not used in this file CAN NOT be removed!
+  # because haumea pass argument lazily,
+  # and these arguments are used in the functions `mylib.nixosSystem`.
+  inputs,
+  lib,
+  myvars,
+  mylib,
+  system,
+  genSpecialArgs,
+  ...
+} @ args: let
+  # Kevin - Codename "Deliverance", 1st of Flame-Chasers
+  name = "kevin";
+  base-modules = {
+    nixos-modules = map mylib.relativeToRoot [
+      # common
+      "modules/nixos/desktop.nix"
+      # host specific
+      "hosts/chaser-${name}"
+    ];
+    home-modules = map mylib.relativeToRoot [
+      # common
+      "home/linux/gui.nix"
+      # host specific
+      "hosts/chaser-${name}/home.nix"
+    ];
+  };
+in {
+  nixosConfigurations = {
+    "${name}" = mylib.nixosSystem (base-modules // args);
+  };
+}
outputs/x86_64-linux/default.nix
@@ -0,0 +1,25 @@
+{
+  lib,
+  inputs,
+  ...
+} @ args: let
+  inherit (inputs) haumea;
+
+  # Contains all the flake outputs of this system architecture.
+  data = haumea.lib.load {
+    src = ./src;
+    inputs = args;
+  };
+  # nix file names is redundant, so we remove it.
+  dataWithoutPaths = builtins.attrValues data;
+
+  # Merge all the machine's data into a single attribute set.
+  outputs = {
+    nixosConfigurations = lib.attrsets.mergeAttrsList (map (it: it.nixosConfigurations or {}) dataWithoutPaths);
+    packages = lib.attrsets.mergeAttrsList (map (it: it.packages or {}) dataWithoutPaths);
+  };
+in
+  outputs
+  // {
+    inherit data;
+  }
outputs/default.nix
@@ -0,0 +1,75 @@
+{
+  self,
+  nixpkgs,
+  ...
+} @ inputs: let
+  inherit (inputs.nixpkgs) lib;
+  mylib = import ../lib {inherit lib;};
+  myvars = import ../vars {inherit lib;};
+
+  # Add my custom lib, vars, nixpkgs instance, and all the inputs to specialArgs,
+  # so that I can use them in all my nixos/home-manager modules.
+  genSpecialArgs = system:
+    inputs
+    // {
+      inherit mylib myvars;
+
+      # use unstable branch for some packages to get the latest updates
+      pkgs-unstable = import inputs.nixpkgs-unstable {
+        inherit system; # refer the `system` parameter form outer scope recursively
+        config.allowUnfree = true;
+      };
+      pkgs-stable = import inputs.nixpkgs-stable {
+        inherit system;
+        config.allowUnfree = true;
+      };
+    };
+
+  # This is the args for all the haumea modules in this folder.
+  args = {
+    inherit
+      inputs
+      lib
+      mylib
+      myvars
+      genSpecialArgs
+      ;
+  };
+
+  nixosSystems = {
+    x86_64-linux = import ./x86_64-linux (args // {system = "x86_64-linux";});
+  };
+
+  darwinSystems = {};
+  allSystems = nixosSystems // darwinSystems;
+  allSystemNames = builtins.attrNames allSystems;
+  nixosSystemValues = builtins.attrValues nixosSystems;
+  darwinSystemValues = builtins.attrValues darwinSystems;
+  allSystemValues = nixosSystemValues ++ darwinSystemValues;
+
+  # Helper function to generate a set of attributes for each system
+  forAllSystems = func: (nixpkgs.lib.genAttrs allSystemNames func);
+in {
+  # Add attribute sets into outputs, for debugging
+  debugAttrs = {
+    inherit
+      nixosSystems
+      darwinSystems
+      allSystems
+      allSystemNames
+      ;
+  };
+
+  # NixOS Hosts
+  nixosConfigurations = lib.attrsets.mergeAttrsList (
+    map (it: it.nixosConfigurations or {}) nixosSystemValues
+  );
+
+  # macOS Hosts
+  darwinConfigurations = lib.attrsets.mergeAttrsList (
+    map (it: it.darwinConfigurations or {}) darwinSystemValues
+  );
+
+  # Packages
+  packages = forAllSystems (system: allSystems.${system}.packages or {});
+}
vars/default.nix
@@ -0,0 +1,8 @@
+{lib}: {
+  username = "hpcesia";
+  userfullname = "HPCesia";
+  useremail = "me@hpcesia.com";
+  networking = import ./networking.nix {inherit lib;};
+  # generated by `mkpasswd -m scrypt`
+  initialHashedPassword = "$7$CU..../....xQnray7Ah6GYybfmtsxmF.$k0F/eaOC2.9gXwXp0jgMrFM.fnMtFqYi3GZFaaJGsl3";
+}
vars/networking.nix
@@ -0,0 +1,6 @@
+{lib}: rec {
+  nameservers = [
+    "119.29.29.29" # DNSPod
+    "223.5.5.5" # AliDNS
+  ];
+}
.gitignore
@@ -0,0 +1,1 @@
+.DS_Store
\ No newline at end of file
flake.lock
@@ -0,0 +1,146 @@
+{
+  "nodes": {
+    "haumea": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1685133229,
+        "narHash": "sha256-FePm/Gi9PBSNwiDFq3N+DWdfxFq0UKsVVTJS3cQPn94=",
+        "owner": "nix-community",
+        "repo": "haumea",
+        "rev": "34dd58385092a23018748b50f9b23de6266dffc2",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "ref": "v0.2.2",
+        "repo": "haumea",
+        "type": "github"
+      }
+    },
+    "home-manager": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1748487945,
+        "narHash": "sha256-e9zc/rHdoH9i+sFFhhQiKoF6IuD+T2rB/nUyPaO7CCg=",
+        "owner": "nix-community",
+        "repo": "home-manager",
+        "rev": "0d13ea58d565d3c1c1468ddae1f623316dc395d9",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "ref": "release-25.05",
+        "repo": "home-manager",
+        "type": "github"
+      }
+    },
+    "nixos-hardware": {
+      "locked": {
+        "lastModified": 1747900541,
+        "narHash": "sha256-dn64Pg9xLETjblwZs9Euu/SsjW80pd6lr5qSiyLY1pg=",
+        "owner": "NixOS",
+        "repo": "nixos-hardware",
+        "rev": "11f2d9ea49c3e964315215d6baa73a8d42672f06",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "master",
+        "repo": "nixos-hardware",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1748437600,
+        "narHash": "sha256-hYKMs3ilp09anGO7xzfGs3JqEgUqFMnZ8GMAqI6/k04=",
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "rev": "7282cb574e0607e65224d33be8241eae7cfe0979",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nixos",
+        "ref": "nixos-25.05",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs-stable": {
+      "locked": {
+        "lastModified": 1748437600,
+        "narHash": "sha256-hYKMs3ilp09anGO7xzfGs3JqEgUqFMnZ8GMAqI6/k04=",
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "rev": "7282cb574e0607e65224d33be8241eae7cfe0979",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nixos",
+        "ref": "nixos-25.05",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs-unstable": {
+      "locked": {
+        "lastModified": 1748370509,
+        "narHash": "sha256-QlL8slIgc16W5UaI3w7xHQEP+Qmv/6vSNTpoZrrSlbk=",
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "rev": "4faa5f5321320e49a78ae7848582f684d64783e9",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nixos",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "plasma-manager": {
+      "inputs": {
+        "home-manager": [
+          "home-manager"
+        ],
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1748196248,
+        "narHash": "sha256-1iHjsH6/5UOerJEoZKE+Gx1BgAoge/YcnUsOA4wQ/BU=",
+        "owner": "nix-community",
+        "repo": "plasma-manager",
+        "rev": "b7697abe89967839b273a863a3805345ea54ab56",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "repo": "plasma-manager",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "haumea": "haumea",
+        "home-manager": "home-manager",
+        "nixos-hardware": "nixos-hardware",
+        "nixpkgs": "nixpkgs",
+        "nixpkgs-stable": "nixpkgs-stable",
+        "nixpkgs-unstable": "nixpkgs-unstable",
+        "plasma-manager": "plasma-manager"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
flake.nix
@@ -0,0 +1,29 @@
+{
+  description = "NixOS configuration of HPCesia.";
+
+  outputs = inputs: import ./outputs inputs;
+
+  inputs = {
+    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
+    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
+    nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-25.05";
+
+    nixos-hardware.url = "github:NixOS/nixos-hardware/master";
+
+    home-manager = {
+      url = "github:nix-community/home-manager/release-25.05";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
+
+    haumea = {
+      url = "github:nix-community/haumea/v0.2.2";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
+
+    plasma-manager = {
+      url = "github:nix-community/plasma-manager";
+      inputs.nixpkgs.follows = "nixpkgs";
+      inputs.home-manager.follows = "home-manager";
+    };
+  };
+}