mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-25 09:28:27 +02:00
feat: refactor, hyprland - greet with autologin
This commit is contained in:
10
modules/nixos/desktop/default.nix
Normal file
10
modules/nixos/desktop/default.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
imports = [
|
||||
./fonts.nix
|
||||
./graphic.nix
|
||||
./misc.nix
|
||||
./peripherals.nix
|
||||
./security.nix
|
||||
./visualisation.nix
|
||||
];
|
||||
}
|
||||
69
modules/nixos/desktop/fonts.nix
Normal file
69
modules/nixos/desktop/fonts.nix
Normal file
@@ -0,0 +1,69 @@
|
||||
{pkgs, ...}: {
|
||||
# all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts
|
||||
fonts = {
|
||||
# use fonts specified by user rather than default ones
|
||||
enableDefaultPackages = false;
|
||||
fontDir.enable = true;
|
||||
|
||||
packages = with pkgs; [
|
||||
# icon fonts
|
||||
material-design-icons
|
||||
font-awesome
|
||||
|
||||
# Noto 系列字体是 Google 主导的,名字的含义是「没有豆腐」(no tofu),因为缺字时显示的方框或者方框被叫作 tofu
|
||||
# Noto 系列字族名只支持英文,命名规则是 Noto + Sans 或 Serif + 文字名称。
|
||||
# 其中汉字部分叫 Noto Sans/Serif CJK SC/TC/HK/JP/KR,最后一个词是地区变种。
|
||||
noto-fonts # 大部分文字的常见样式,不包含汉字
|
||||
noto-fonts-cjk # 汉字部分
|
||||
noto-fonts-emoji # 彩色的表情符号字体
|
||||
noto-fonts-extra # 提供额外的字重和宽度变种
|
||||
|
||||
# 思源系列字体是 Adobe 主导的。其中汉字部分被称为「思源黑体」和「思源宋体」,是由 Adobe + Google 共同开发的
|
||||
source-sans # 无衬线字体,不含汉字。字族名叫 Source Sans 3 和 Source Sans Pro,以及带字重的变体,加上 Source Sans 3 VF
|
||||
source-serif # 衬线字体,不含汉字。字族名叫 Source Code Pro,以及带字重的变体
|
||||
source-han-sans # 思源黑体
|
||||
source-han-serif # 思源宋体
|
||||
|
||||
# nerdfonts
|
||||
(nerdfonts.override {
|
||||
fonts = [
|
||||
"FiraCode"
|
||||
"JetBrainsMono"
|
||||
"Iosevka"
|
||||
];
|
||||
})
|
||||
|
||||
# added by my custom overlays, custom icon font for hyprland/i3's tray/bar
|
||||
icomoon-feather-icon-font
|
||||
];
|
||||
|
||||
# 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 = ["Noto Serif CJK SC" "Noto Serif CJK TC" "Noto Serif CJK JP" "Noto Color Emoji"];
|
||||
sansSerif = ["Noto Sans CJK SC" "Noto Sans CJK TC" "Noto Sans CJK JP" "Noto Color Emoji"];
|
||||
monospace = ["JetBrainsMono Nerd Font" "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 = "Source Code Pro";
|
||||
package = pkgs.source-code-pro;
|
||||
}
|
||||
];
|
||||
extraOptions = "--term xterm-256color";
|
||||
extraConfig = "font-size=12";
|
||||
# Whether to use 3D hardware acceleration to render the console.
|
||||
hwRender = true;
|
||||
};
|
||||
}
|
||||
30
modules/nixos/desktop/graphic.nix
Normal file
30
modules/nixos/desktop/graphic.nix
Normal file
@@ -0,0 +1,30 @@
|
||||
{pkgs, ...}: {
|
||||
xdg.portal = {
|
||||
enable = true;
|
||||
|
||||
config = {
|
||||
common = {
|
||||
# Use xdg-desktop-portal-gtk for every portal interface...
|
||||
default = [
|
||||
"gtk"
|
||||
];
|
||||
# except for the secret portal, which is handled by gnome-keyring
|
||||
"org.freedesktop.impl.portal.Secret" = [
|
||||
"gnome-keyring"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
# Sets environment variable NIXOS_XDG_OPEN_USE_PORTAL to 1
|
||||
# This will make xdg-open use the portal to open programs,
|
||||
# which resolves bugs involving programs opening inside FHS envs or with unexpected env vars set from wrappers.
|
||||
# xdg-open is used by almost all programs to open a unknown file/uri
|
||||
# alacritty as an example, it use xdg-open as default, but you can also custom this behavior
|
||||
# and vscode has open like `External Uri Openers`
|
||||
xdgOpenUsePortal = false;
|
||||
extraPortals = with pkgs; [
|
||||
xdg-desktop-portal-gtk # for gtk
|
||||
# xdg-desktop-portal-kde # for kde
|
||||
];
|
||||
};
|
||||
}
|
||||
51
modules/nixos/desktop/misc.nix
Normal file
51
modules/nixos/desktop/misc.nix
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
# add user's shell into /etc/shells
|
||||
environment.shells = with pkgs; [
|
||||
bash
|
||||
nushell
|
||||
];
|
||||
# set user's default shell system-wide
|
||||
users.defaultUserShell = pkgs.nushell;
|
||||
|
||||
environment.variables = {
|
||||
# fix https://github.com/NixOS/nixpkgs/issues/238025
|
||||
TZ = "${config.time.timeZone}";
|
||||
};
|
||||
|
||||
# List packages installed in system profile. To search, run:
|
||||
# $ nix search wget
|
||||
environment.systemPackages = with pkgs; [
|
||||
ventoy
|
||||
gnumake
|
||||
|
||||
colmena # nixos's remote deployment tool
|
||||
];
|
||||
|
||||
services = {
|
||||
gvfs.enable = true; # Mount, trash, and other functionalities
|
||||
tumbler.enable = true; # Thumbnail support for images
|
||||
};
|
||||
|
||||
programs = {
|
||||
# The OpenSSH agent remembers private keys for you
|
||||
# so that you don’t have to type in passphrases every time you make an SSH connection.
|
||||
# Use `ssh-add` to add a key to the agent.
|
||||
ssh.startAgent = true;
|
||||
# dconf is a low-level configuration system.
|
||||
dconf.enable = true;
|
||||
|
||||
# thunar file manager(part of xfce) related options
|
||||
thunar = {
|
||||
enable = true;
|
||||
plugins = with pkgs.xfce; [
|
||||
thunar-archive-plugin
|
||||
thunar-volman
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
75
modules/nixos/desktop/peripherals.nix
Normal file
75
modules/nixos/desktop/peripherals.nix
Normal file
@@ -0,0 +1,75 @@
|
||||
{pkgs, ...}: {
|
||||
#============================= Audio(PipeWire) =======================
|
||||
|
||||
# List packages installed in system profile. To search, run:
|
||||
# $ nix search wget
|
||||
environment.systemPackages = with pkgs; [
|
||||
pulseaudio # provides `pactl`, which is required by some apps(e.g. sonic-pi)
|
||||
];
|
||||
|
||||
# PipeWire is a new low-level multimedia framework.
|
||||
# It aims to offer capture and playback for both audio and video with minimal latency.
|
||||
# It support for PulseAudio-, JACK-, ALSA- and GStreamer-based applications.
|
||||
# PipeWire has a great bluetooth support, it can be a good alternative to PulseAudio.
|
||||
# https://nixos.wiki/wiki/PipeWire
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
# package = pkgs-unstable.pipewire;
|
||||
alsa.enable = true;
|
||||
alsa.support32Bit = true;
|
||||
pulse.enable = true;
|
||||
# If you want to use JACK applications, uncomment this
|
||||
jack.enable = true;
|
||||
wireplumber.enable = true;
|
||||
};
|
||||
# rtkit is optional but recommended
|
||||
security.rtkit.enable = true;
|
||||
# Remove sound.enable or turn it off if you had it set previously, it seems to cause conflicts with pipewire
|
||||
sound.enable = false;
|
||||
# Disable pulseaudio, it conflicts with pipewire too.
|
||||
hardware.pulseaudio.enable = false;
|
||||
|
||||
#============================= Bluetooth =============================
|
||||
|
||||
# enable bluetooth & gui paring tools - blueman
|
||||
# or you can use cli:
|
||||
# $ bluetoothctl
|
||||
# [bluetooth] # power on
|
||||
# [bluetooth] # agent on
|
||||
# [bluetooth] # default-agent
|
||||
# [bluetooth] # scan on
|
||||
# ...put device in pairing mode and wait [hex-address] to appear here...
|
||||
# [bluetooth] # pair [hex-address]
|
||||
# [bluetooth] # connect [hex-address]
|
||||
# Bluetooth devices automatically connect with bluetoothctl as well:
|
||||
# [bluetooth] # trust [hex-address]
|
||||
hardware.bluetooth.enable = true;
|
||||
services.blueman.enable = true;
|
||||
|
||||
#================================= Misc =================================
|
||||
|
||||
services = {
|
||||
printing.enable = true; # Enable CUPS to print documents.
|
||||
geoclue2.enable = true; # Enable geolocation services.
|
||||
|
||||
udev.packages = with pkgs; [
|
||||
gnome.gnome-settings-daemon
|
||||
platformio # udev rules for platformio
|
||||
openocd # required by paltformio, see https://github.com/NixOS/nixpkgs/issues/224895
|
||||
android-udev-rules # required by adb
|
||||
openfpgaloader
|
||||
];
|
||||
|
||||
# A key remapping daemon for linux.
|
||||
# https://github.com/rvaiya/keyd
|
||||
keyd = {
|
||||
enable = true;
|
||||
keyboards.default.settings = {
|
||||
main = {
|
||||
# overloads the capslock key to function as both escape (when tapped) and control (when held)
|
||||
capslock = "overload(control, esc)";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
10
modules/nixos/desktop/security.nix
Normal file
10
modules/nixos/desktop/security.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
# security with polkit
|
||||
services.power-profiles-daemon = {
|
||||
enable = true;
|
||||
};
|
||||
security.polkit.enable = true;
|
||||
# security with gnome-kering
|
||||
services.gnome.gnome-keyring.enable = true;
|
||||
security.pam.services.greetd.enableGnomeKeyring = true;
|
||||
}
|
||||
43
modules/nixos/desktop/visualisation.nix
Normal file
43
modules/nixos/desktop/visualisation.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{pkgs, ...}: {
|
||||
###################################################################################
|
||||
#
|
||||
# Visualisation - Libvirt(QEMU/KVM) / Docker / LXD / WayDroid
|
||||
#
|
||||
###################################################################################
|
||||
|
||||
boot.kernelModules = ["kvm-amd" "kvm-intel" "vfio-pci"];
|
||||
# Enable nested virsualization, required by security containers and nested vm.
|
||||
boot.extraModprobeConfig = "options kvm_intel nested=1"; # for intel cpu
|
||||
# boot.extraModprobeConfig = "options kvm_amd nested=1"; # for amd cpu
|
||||
|
||||
virtualisation = {
|
||||
libvirtd = {
|
||||
enable = true;
|
||||
# hanging this option to false may cause file permission issues for existing guests.
|
||||
# To fix these, manually change ownership of affected files in /var/lib/libvirt/qemu to qemu-libvirtd.
|
||||
qemu.runAsRoot = true;
|
||||
};
|
||||
waydroid.enable = true;
|
||||
lxd.enable = true;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
# Need to add [File (in the menu bar) -> Add connection] when start for the first time
|
||||
virt-manager
|
||||
|
||||
# QEMU/KVM, provides:
|
||||
# qemu-storage-daemon qemu-edid qemu-ga
|
||||
# qemu-pr-helper qemu-nbd elf2dmp qemu-img qemu-io
|
||||
# qemu-kvm qemu-system-x86_64 qemu-system-aarch64 qemu-system-i386
|
||||
qemu_kvm
|
||||
|
||||
# Install all packages about QEMU, provides:
|
||||
# ......
|
||||
# qemu-loongarch64 qemu-system-loongarch64
|
||||
# qemu-riscv64 qemu-system-riscv64 qemu-riscv32 qemu-system-riscv32
|
||||
# qemu-system-arm qemu-arm qemu-armeb qemu-system-aarch64 qemu-aarch64 qemu-aarch64_be
|
||||
# qemu-system-xtensa qemu-xtensa qemu-system-xtensaeb qemu-xtensaeb
|
||||
# ......
|
||||
qemu_full
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user