Today, I will

[Linux, nixOS] NixOS에서 한글(Hangul) 입력 설정하기 본문

Computer Science/운영체제

[Linux, nixOS] NixOS에서 한글(Hangul) 입력 설정하기

Lv.Forest 2025. 4. 18. 21:06

NixOS에서 한글 입력을 위해 필요한 설정 과정입니다:

1. 필요한 패키지 설치 및 설정

cd /etc/nixos/

sudo nano /etc/nixos/configuration.nix

# /etc/nixos/configuration.nix 파일 수정, 수정한 부분은 아래와 같습니다.
  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "kr";
    variant = "kr104";
  };

  i18n.inputMethod = {
    enabled = null; # IBus 입력기 프레임워크 활성화\
    type = "ibus";
    enable = true;
    ibus.engines = with pkgs.ibus-engines; [
      hangul # 한글 입력 엔진 사용
      # 여기에 다른 엔진 추가 가능 (예: libpinyin)
    ];
  };
  i18n.defaultLocale = "ko_KR.UTF-8";

  # 한글 폰트 설치
  fonts.packages = with pkgs; [
     nanum
     noto-fonts-cjk-sans
];

environment.systemPackages = with pkgs; [
  ibus
];

2. 시스템 설정 적용

sudo nixos-rebuild switch

3. 사용자 환경 설정

# ibus 데몬 실행
ibus-daemon -drx

# 입력 엔진을 한글로 설정
ibus engine hangul

# 자동 시작 파일 설정
echo 'export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
ibus-daemon -drx' > ~/.xprofile
chmod +x ~/.xprofile

# 자동 시작 등록
mkdir -p ~/.config/autostart
echo '[Desktop Entry]
Type=Application
Name=IBus
Comment=Start IBus Input Method
Exec=ibus-daemon -drx
Icon=ibus
Terminal=false
Categories=System;Utility;' > ~/.config/autostart/ibus.desktop

# 입력기 설정
gsettings set org.freedesktop.ibus.general preload-engines "['hangul']"
gsettings set org.freedesktop.ibus.general.hotkey triggers "['<Alt>space']"
gsettings set org.freedesktop.ibus.general use-system-keyboard-layout false

 

4. 문제 해결

오류가 있는 경우, 아래 과정을 확인해보세요:

  1. ibus가 실행 중인지 확인: ps aux | grep ibus
  2. 현재 ibus 엔진 확인: ibus engine
  3. 한글로 전환: ibus engine hangul

이상하게도 때로는 설정이 완벽하지 않더라도 한글 입력이 되는 경우가 있습니다만, 시스템 재시작 후에도 설정이 유지되도록 위 설정을 완료하는 것이 좋습니다.

이 방법으로 NixOS에서 한글 입력을 성공적으로 설정할 수 있습니다!

 

5. 전문 공유

유저 명만 가려서 전문 공개하니, 대조해보시면서 시도해보셔도 좋을 것 같습니다.

# NOTE: 'urname' 은 예시 사용자명입니다. 자신의 계정명으로 바꿔주세요.

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "Asia/Seoul";

  # Select internationalisation properties.

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "ko_KR.UTF-8";
    LC_IDENTIFICATION = "ko_KR.UTF-8";
    LC_MEASUREMENT = "ko_KR.UTF-8";
    LC_MONETARY = "ko_KR.UTF-8";
    LC_NAME = "ko_KR.UTF-8";
    LC_NUMERIC = "ko_KR.UTF-8";
    LC_PAPER = "ko_KR.UTF-8";
    LC_TELEPHONE = "ko_KR.UTF-8";
    LC_TIME = "ko_KR.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the Budgie Desktop environment.
  services.xserver.displayManager.lightdm.enable = true;
  services.xserver.desktopManager.budgie.enable = true;

  # Configure keymap in X11
  services.xserver.xkb = {
    layout = "kr";
    variant = "kr104";
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.urname = {
    isNormalUser = true;
    description = "urname";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
    #  thunderbird
    ];
  };

  i18n.inputMethod = {
    enabled = null; # IBus 입력기 프레임워크 활성화\
    type = "ibus";
    enable = true;
    ibus.engines = with pkgs.ibus-engines; [
      hangul # 한글 입력 엔진 사용
      # 여기에 다른 엔진 추가 가능 (예: libpinyin)
    ];
  };
  i18n.defaultLocale = "ko_KR.UTF-8";
  # Install firefox.
  programs.firefox.enable = true;
  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;
  
  # 한글 폰트 설치
  fonts.packages = with pkgs; [
     nanum
     noto-fonts-cjk-sans
];

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
     ibus
     vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #  wget
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # 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 = "24.11"; # Did you read the comment?

}