This commit is contained in:
Elias Gasparis 2025-06-02 21:14:01 +08:00
parent 98f309e72a
commit 8a32e2f31b
16 changed files with 645 additions and 271 deletions

158
mods/base.nix Normal file
View file

@ -0,0 +1,158 @@
# base.nix
# configuration for all my computers
{ pkgs, config, ... }:
{
imports =
[
./gnome.nix
./systemd.nix
./fonts.nix
./gpu.nix
];
# Housekeeping: Garbage collection
nix.optimise.automatic = true;
nix.gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 7d";
};
nix.settings.auto-optimise-store = true;
# Increase buffer size for NixOS-Rebuild
nix.settings.download-buffer-size = "4G";
# Enable networking
networking.networkmanager.enable = true;
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [ 22 ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# Disable sudo password for the wheel group
security.sudo.wheelNeedsPassword = false;
# Set your time zone.
time.timeZone = "Asia/Taipei";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "zh_TW.UTF-8";
LC_IDENTIFICATION = "zh_TW.UTF-8";
LC_MEASUREMENT = "zh_TW.UTF-8";
LC_MONETARY = "zh_TW.UTF-8";
LC_NAME = "zh_TW.UTF-8";
LC_NUMERIC = "zh_TW.UTF-8";
LC_PAPER = "zh_TW.UTF-8";
LC_TELEPHONE = "zh_TW.UTF-8";
LC_TIME = "zh_TW.UTF-8";
};
# Traditional Chinese input
i18n.inputMethod = {
enable = true;
type = "fcitx5";
fcitx5.addons = with pkgs; [
fcitx5-chewing
fcitx5-chinese-addons
fcitx5-table-extra
];
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
# remove xterm
services.xserver.excludePackages = [ pkgs.xterm ];
services.xserver.desktopManager.xterm.enable = false;
# Configure keymap in X11
services.xserver.xkb = {
layout = "us";
variant = "";
};
# Enable CUPS to print documents.
services.printing.enable = false;
# Enable touchpad support (enabled default in most desktop>
services.libinput.enable = true;
# Enable automatic login for the user.
services.displayManager.autoLogin.enable = true;
services.displayManager.autoLogin.user = "elias";
# PROGRAMS
# ================
# Install Firefox.
programs.firefox.enable = true;
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
nix.settings.experimental-features = [ "nix-command" "flakes" ];
environment.systemPackages = with pkgs; [
# MOVE MOST TO HOME.NIX
# terminal apps
wget
curl
fastfetch
gnome-tweaks
btop
htop
tree
restic # backup program
lm_sensors
hddtemp
f3
unzip
git
# terminal editors
neovim
ptyxis
# nix helper apps
nh
];
# Services
# =========================
# Enable OpenSSH
services.openssh = {
enable = true;
# require public key authentication for better security
settings.PasswordAuthentication = true;
settings.KbdInteractiveAuthentication = false;
settings.PermitRootLogin = "no";
};
# Enable Flatpak
services.flatpak.enable = true;
# Enable Tailscale
services.tailscale.enable = true;
# Enable Docker
#virtualisation.docker.enable = true;
# Enable Firmware Updater
services.fwupd.enable = true;
# fwupdmgr refresh
# fwupdmgr get-updates
}

32
mods/fonts.nix Normal file
View file

@ -0,0 +1,32 @@
{ config, pkgs, ... }:
{
# Fonts
fonts.packages = with pkgs; [
corefonts
vistafonts
noto-fonts
# cjk fonts
noto-fonts-cjk-sans
noto-fonts-cjk-serif
noto-fonts-emoji
vistafonts-cht
source-han-serif
source-han-sans-vf-otf
source-han-sans-vf-ttf
source-han-mono
# coding/terminal fonts
liberation_ttf
fira-code
fira-code-symbols
mplus-outline-fonts.githubRelease
dina-font
proggyfonts
iosevka
#nerdfonts
];
fonts.fontDir.enable = true;
}

63
mods/gnome.nix Normal file
View file

@ -0,0 +1,63 @@
{ config, pkgs, lib, ... }:
{
# Auto unlock GNOME keyring
services.gnome.gnome-keyring.enable = true;
security.pam.services.sddm.enableGnomeKeyring = true;
# also need to install pkgs.seahorse, set keyring key to blank password
# Remove default packages from GNOME
environment.gnome.excludePackages = with pkgs; [
baobab # disk usage analyzer
cheese # photo booth
eog # image viewer
epiphany # web browser
#gedit # text editor
simple-scan # document scanner
totem # video player
yelp # help viewer
file-roller # archive manager
geary # email client
seahorse # password manager
gnome-contacts
gnome-weather
gnome-maps
gnome-music
gnome-software
gnome-extension-manager
gnome-shell-extensions
gnome-photos
gnome-connections
snapshot
gnome-logs
gnome-system-monitor
gnome-calculator
gnome-tour
];
# Install GNOME Extensions
# Logout and login again after rebuilding to see changes in GNOME
environment.systemPackages = with pkgs; [
gnomeExtensions.appindicator
gnomeExtensions.caffeine
gnomeExtensions.gsconnect
gnomeExtensions.hot-edge
gnomeExtensions.alphabetical-app-grid
gnomeExtensions.kimpanel
gnomeExtensions.tailscale-qs
];
# Set User 'elias' icon to tootbrute.png image
system.activationScripts.script.text = ''
mkdir -p /var/lib/AccountsService/{icons,users}
cp /home/elias/nixos-config/files/tootbrute.png /var/lib/AccountsService/icons/elias
echo -e "[User]\nIcon=/var/lib/AccountsService/icons/elias\n" > /var/lib/AccountsService/users/elias
chown root:root /var/lib/AccountsService/users/elias
chmod 0600 /var/lib/AccountsService/users/elias
chown root:root /var/lib/AccountsService/icons/elias
chmod 0444 /var/lib/AccountsService/icons/elias
'';
}

22
mods/gpu.nix Normal file
View file

@ -0,0 +1,22 @@
{ config, pkgs, lib, ... }:
{
# add comments back in later from forgejo
nixpkgs.config.allowUnfree = true;
nixpkgs.config.nvidia.acceptLicense = true;
hardware.graphics.enable = true;
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
modesetting.enable = true;
powerManagement.enable = false;
open = false;
nvidiaSettings = true;
package = config.boot.kernelPackages.nvidiaPackages.legacy_340;
};
}

26
mods/systemd.nix Normal file
View file

@ -0,0 +1,26 @@
{ config, pkgs, lib, ... }:
{
# update flatpaks everyday upon bootup
systemd.timers."update-flatpak" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "1m";
OnCalendar = "daily";
Unit = "update-flatpak.service";
};
};
systemd.services."update-flatpak" = {
script = ''
set -eu
${pkgs.flatpak}/bin/flatpak update --noninteractive --assumeyes
'';
serviceConfig = {
Type = "oneshot";
User = "root";
};
wantedBy = [ "multi-user.target" ]; # Ensure the service starts after rebuild
};
}