{ config, lib, pkgs, ... }:
{
  networking.networkmanager.enable = lib.mkDefault true;
  time.timeZone = "Asia/Tokyo";

  i18n = {
    defaultLocale = "en_US.UTF-8";
    defaultCharset = "UTF-8";
    extraLocales = [
      "ja_JP.UTF-8/UTF-8"
      "ja_JP.EUC-JP/EUC-JP"
    ];
  };

  console.useXkbConfig = true;
  services.xserver.xkb.options = "ctrl:swapcaps";

  services.pipewire = {
    enable = true;
    pulse.enable = true;
  };

  services.openssh = {
    enable = true;
  };

  programs.mtr.enable = true;
  programs.gnupg = {
    agent = {
      enable = true;
      enableSSHSupport = true;
    };
  };
  services.pcscd.enable = true;

  hardware.gpgSmartcards.enable = true;

  users.users.bitbang = {
    isNormalUser = true;
    extraGroups = [ "wheel" "video" "audio" "nix" "dialout" "networkmanager" "libvirtd" "podman" ];
  };

  programs.nix-ld = {
    enable = true;
    libraries = with pkgs; [
      SDL
      SDL2_image
      acl
      atk
      attr
      bzip2
      cairo
      cups
      curl
      dbus
      dbus-glib
      e2fsprogs
      ffmpeg
      flac
      fontconfig
      fuse
      glew
      glib
      gtk2
      gtk3
      icu
      libGL
      libcap
      libcxx
      libelf
      libjpeg
      libnotify
      libpng
      libsodium
      libssh
      libtiff
      libusb1
      libxkbcommon
      libxml2
      nss
      openssl
      pango
      stdenv.cc.cc
      systemd
      util-linux
      xorg.libICE
      xorg.libSM
      xorg.libX11
      xorg.libXcomposite
      xorg.libXcursor
      xorg.libXdamage
      xorg.libXext
      xorg.libXfixes
      xorg.libXi
      xorg.libXmu
      xorg.libXrandr
      xorg.libXrender
      xorg.libXt
      xorg.libXtst
      xorg.libXxf86vm
      xorg.libxcb
      xorg.libxshmfence
      xz
      zlib
      zstd
    ];
  };

  nix.gc = {
    automatic = true;
    dates = "monthly";
    persistent = true;
  };

  nix.settings = {
    cores = lib.mkDefault 8;
    sandbox = true;
    allowed-users = [ "@wheel" ];
    trusted-users = [ "@wheel" ];
    log-lines = 50;
    auto-optimise-store = true;
    experimental-features = [ "nix-command" "flakes" ];
    substituters = [
      "https://cache.nixos.org"
    ];
    accept-flake-config = true;
  };

  environment.systemPackages = with pkgs; [
    micro
    wget
    git
    btop
    fastfetch
    stow
    yubikey-manager
    alsa-utils
    pulseaudio
  ];
}
