commit ca023da65527ef0a5c8193d15c041db54b12e3b7 Author: duynguyen Date: Wed Aug 5 23:58:32 2026 +0700 init: NixOS flake config with home-manager and Vietnamese input diff --git a/README.md b/README.md new file mode 100644 index 0000000..6c8fa99 --- /dev/null +++ b/README.md @@ -0,0 +1,94 @@ +# nixos-config + +Personal NixOS configuration using flakes and home-manager. + +## Structure + +``` +nixos-config/ +├── flake.nix # Entry point — inputs and outputs +├── hosts/ +│ └── nixos/ +│ ├── configuration.nix # System configuration +│ └── hardware-configuration.nix # Auto-generated, machine-specific +└── home/ + └── duynguyen/ + └── default.nix # Home-manager config (user packages, dotfiles) +``` + +## What's configured + +- **KDE Plasma 6** on Wayland via SDDM +- **Vietnamese input** via fcitx5 + unikey (Telex/VNI) + - After switching, go to System Settings → Virtual Keyboard → select "Fcitx 5" +- **Locale**: English UI, Vietnamese formats (currency, time, etc.), Asia/Ho_Chi_Minh timezone +- **Pipewire** for audio +- **Packages**: firefox, kate, claude-code, git + +## Reproducing on a fresh machine + +### 1. Install NixOS + +Boot the NixOS ISO, partition, and install as normal. During install, choose KDE Plasma if prompted. + +### 2. Enable flakes temporarily + +```bash +nix-shell -p git --command "bash" +# or just proceed if git is already available +``` + +### 3. Clone this repo + +```bash +git clone ~/nixos-config +cd ~/nixos-config +``` + +### 4. Replace the hardware config + +The `hardware-configuration.nix` inside `hosts/nixos/` is machine-specific. Replace it with your own: + +```bash +cp /etc/nixos/hardware-configuration.nix ~/nixos-config/hosts/nixos/hardware-configuration.nix +``` + +### 5. Apply the configuration + +```bash +sudo nixos-rebuild switch --flake ~/nixos-config#nixos +``` + +### 6. Lock the flake inputs + +```bash +nix flake update +``` + +Commit the resulting `flake.lock` so future rebuilds use the exact same package versions. + +## Daily usage + +| Task | Command | +|------|---------| +| Apply system + home changes | `sudo nixos-rebuild switch --flake ~/nixos-config#nixos` | +| Update all inputs | `nix flake update` | +| Roll back last switch | `sudo nixos-rebuild switch --rollback` | +| Search packages | `nix search nixpkgs ` | + +## Adding packages + +- **System-wide** (available to all users): `hosts/nixos/configuration.nix` → `environment.systemPackages` +- **User-level** (home-manager managed): `home/duynguyen/default.nix` → `home.packages` +- **Per-user via NixOS**: `hosts/nixos/configuration.nix` → `users.users.duynguyen.packages` + +## Vietnamese input setup (fcitx5) + +After first build: +1. Go to **System Settings → Input Devices → Virtual Keyboard** +2. Select **Fcitx 5** and apply +3. In the system tray, right-click the fcitx5 icon → **Configure** +4. Add **Unikey** as an input method +5. Switch between English/Vietnamese with **Super+Space** + +Unikey supports both **Telex** (default) and **VNI** — configure in the Unikey settings. diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..21558c3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,26 @@ +{ + description = "duynguyen's NixOS configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05"; + home-manager = { + url = "github:nix-community/home-manager/release-26.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, home-manager, ... }: { + nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./hosts/nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.duynguyen = import ./home/duynguyen/default.nix; + } + ]; + }; + }; +} diff --git a/home/duynguyen/default.nix b/home/duynguyen/default.nix new file mode 100644 index 0000000..c4c5154 --- /dev/null +++ b/home/duynguyen/default.nix @@ -0,0 +1,21 @@ +{ config, pkgs, ... }: + +{ + home.username = "duynguyen"; + home.homeDirectory = "/home/duynguyen"; + home.stateVersion = "26.05"; + + home.packages = with pkgs; [ + # Add user-level packages here + ]; + + programs.bash.enable = true; + + programs.git = { + enable = true; + userName = "duynguyen"; + userEmail = "huonghaiduynhim@gmail.com"; + }; + + programs.home-manager.enable = true; +} diff --git a/hosts/nixos/configuration.nix b/hosts/nixos/configuration.nix new file mode 100644 index 0000000..a053ada --- /dev/null +++ b/hosts/nixos/configuration.nix @@ -0,0 +1,81 @@ +{ config, pkgs, ... }: + +{ + imports = [ ./hardware-configuration.nix ]; + + # Bootloader + boot.loader.grub.enable = true; + boot.loader.grub.device = "/dev/sda"; + boot.loader.grub.useOSProber = true; + + # Enable flakes and nix-command + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + networking.hostName = "nixos"; + networking.networkmanager.enable = true; + + time.timeZone = "Asia/Ho_Chi_Minh"; + + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.inputMethod = { + enable = true; + type = "fcitx5"; + fcitx5.addons = with pkgs; [ + qt6Packages.fcitx5-unikey + fcitx5-gtk + ]; + }; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "vi_VN"; + LC_IDENTIFICATION = "vi_VN"; + LC_MEASUREMENT = "vi_VN"; + LC_MONETARY = "vi_VN"; + LC_NAME = "vi_VN"; + LC_NUMERIC = "vi_VN"; + LC_PAPER = "vi_VN"; + LC_TELEPHONE = "vi_VN"; + LC_TIME = "vi_VN"; + }; + + services.xserver.enable = true; + services.displayManager.sddm.enable = true; + services.desktopManager.plasma6.enable = true; + + services.xserver.xkb = { + layout = "us"; + variant = ""; + }; + + services.printing.enable = true; + + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + users.users.duynguyen = { + isNormalUser = true; + description = "duynguyen"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + kdePackages.kate + ]; + }; + + programs.firefox.enable = true; + + nixpkgs.config.allowUnfree = true; + + environment.systemPackages = with pkgs; [ + claude-code + git + ]; + + system.stateVersion = "26.05"; +} diff --git a/hosts/nixos/hardware-configuration.nix b/hosts/nixos/hardware-configuration.nix new file mode 100644 index 0000000..75cb776 --- /dev/null +++ b/hosts/nixos/hardware-configuration.nix @@ -0,0 +1,26 @@ +# 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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/51da3f97-16fa-4ed5-a12f-a4466b66359f"; + fsType = "ext4"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/7a05616d-d8d8-4fa5-9810-49118204c9f2"; } + ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +}