Trika

NixOS简单桌面配置

NixOS比预计的简单好用,作为桌面很合适,简单设置了一个以桌面浏览为主的配置。

configuration.nix

{ config, pkgs, ... }:
{
  imports = [
    ./hardware-configuration.nix
  ];

  networking.hostName = "Hostname";
  #networking.proxy.default = "socks5h://1.1.1.1:11";
  system.stateVersion = "24.05";
  time.timeZone = "PRC";

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.grub.devices = [ "nodev" ];

  system.autoUpgrade.enable = true;
  nix.gc.automatic = true;
  nix.gc.dates = "daily";
  nix.gc.options = "--delete-older-than 3d";

  networking.firewall.enable = true;
  networking.firewall.allowedTCPPorts = [];
  networking.firewall.allowedUDPPorts = [];
  networking.networkmanager.enable = true;
  i18n.defaultLocale = "en_US.UTF-8";
  services.xserver.enable = true;
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
  services.gnome.core-utilities.enable = false;

  # modify below drivers
  hardware.opengl = {
    enable = true;
    driSupport = true;
    extraPackages = with pkgs; [
      intel-media-driver
      vaapiVdpau
      libvdpau-va-gl
    ];
  };
  hardware.pulseaudio.enable = true;
  security.rtkit.enable = true;

  users.users.foobar = {
    isNormalUser = true;
    description = "FooBar";
    extraGroups = [ "networkmanager" "wheel" ];
  };
  services.displayManager.autoLogin.enable = true;
  services.displayManager.autoLogin.user = "foobar";
  systemd.services."getty@tty1".enable = false;
  systemd.services."autovt@tty1".enable = false;

  programs.firefox.enable = true;
  environment.gnome.excludePackages = with pkgs; [ gnome-tour ];
  environment.systemPackages = with pkgs; [
    gnome-console gnome.nautilus gnome-text-editor gnome.gnome-system-monitor
  ];
}

一些简单的命令:

nixos-rebuild switch #修改配置后重新构建
nix-collect-garbage -d #删除所有旧的构建
nix-channel --list #列出当前源
nix-channel --update #更新当前源
nix-channel --add https://mirrors.ustc.edu.cn/nix-channels/nixos-24.05 nixos
nix.settings.substituters = lib.mkForce [ "https://mirrors.ustc.edu.cn/nix-channels/store" ];