reorganizing files

This commit is contained in:
Elias Gasparis 2025-02-09 20:22:46 +08:00
parent c51bc454bc
commit 6c99ced7fe
10 changed files with 33 additions and 31 deletions

231
mods/base.nix Normal file
View file

@ -0,0 +1,231 @@
# base.nix
# configuration for all my computers
{ pkgs, config, lib, ... }:
{
imports =
[
./gnome.nix
./systemd.nix
./fonts.nix
./intel-gpu.nix
./neovim-config.nix
];
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.loader.grub.configurationLimit = 10;
# Clear /tmp during boot
boot.tmp.cleanOnBoot = true;
# 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
nix.settings.download-buffer-size = "2G";
# Enable networking
networking.networkmanager.enable = true;
# 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.supportedLocales = [ "en_US.UTF-8/UTF-8" "zh_CN.UTF-8/UTF-8" "zh_TW.UTF-8/UTF-8" ];
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
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 sound with pipewire.
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 >
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# Enable automatic login for the user.
services.displayManager.autoLogin.enable = true;
services.displayManager.autoLogin.user = "elias";
# Workaround for GNOME autologin: https://github.com/NixOS/nixpk>
systemd.services."getty@tty1".enable = false;
systemd.services."autovt@tty1".enable = false;
# 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; [
# terminal apps
wget
curl
fastfetch
git
btop
htop
tree
restic # backup program
# terminal editors
neovim
ptyxis
# nix helper apps
nh
# core apps
iotas # nextcloud compatible notes app
curl
keepassxc # password client
nextcloud-client
libreoffice-fresh # word docs
hunspell # dictionaries for libreoffice
hunspellDicts.en_CA
hunspellDicts.en_US
xreader # pdf viewer
# creative apps
kdePackages.kdenlive
audacity
gimp
pkgs.krita
element-desktop
#gaming
dosbox
#gpu tools
intel-gpu-tools
#nvtopPackages.full not working right now
# archive programs
zip
xz
unzip
p7zip
# utils
ripgrep # recursively searches directories for a regex >
#jq # A lightweight and flexible command-line JSON proc>
#yq-go # yaml processor https://github.com/mikefarah/yq
eza # A modern replacement for ls
#fzf # A command-line fuzzy finder
nnn # terminal file manager
# networking tools
mtr # A network diagnostic tool
iperf3
dnsutils # `dig` + `nslookup`
#ldns # replacement of `dig`, it provide the command `drill`
#aria2 # A lightweight multi-protocol & multi-source command-line download utility
#socat # replacement of openbsd-netcat
nmap # A utility for network discovery and security auditing
#ipcalc # it is a calculator for the IPv4/v6 addresses
# system tools
sysstat
lm_sensors # for `sensors` command
ethtool
pciutils # lspci
usbutils # lsusb
# system call monitoring
strace # system call monitoring
ltrace # library call monitoring
lsof # list open files
iotop # io monitoring
iftop # network monitoring
];
# Services
# =========================
# Enable OpenSSH
services.openssh.enable = true;
# 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
}

13
mods/docker.nix Normal file
View file

@ -0,0 +1,13 @@
{ pkgs, lib, config, ... }:
# enable docker
{
# Enable Docker
virtualisation.docker = {
enable = true;
autoPrune = {
enable = true;
};
};
}

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;
}

48
mods/gnome.nix Normal file
View file

@ -0,0 +1,48 @@
{ config, pkgs, lib, ... }:
{
# Auto unlock gnome keyring
services.gnome.gnome-keyring.enable = true;
security.pam.services.sddm.enableGnomeKeyring = true;
# 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
];
environment.systemPackages = with pkgs; [
#Gnome tweak tools
gnome-tweaks
gnomeExtensions.appindicator
gnomeExtensions.caffeine
gnomeExtensions.gsconnect
gnomeExtensions.hot-edge
gnomeExtensions.alphabetical-app-grid
gnomeExtensions.kimpanel
];
}

155
mods/home.nix Normal file
View file

@ -0,0 +1,155 @@
{ config, pkgs, ... }:
{
home.username = "elias";
home.homeDirectory = "/home/elias";
# link the configuration file in current directory to the specified location in home directory
# home.file.".config/i3/wallpaper.jpg".source = ./wallpaper.jpg;
# link all files in `./scripts` to `~/.config/i3/scripts`
# home.file.".config/i3/scripts" = {
# source = ./scripts;
# recursive = true; # link recursively
# executable = true; # make all files executable
# };
# encode the file content in nix configuration file directly
# home.file.".xxx".text = ''
# xxx
# '';
# Packages that should be installed to the user profile.
home.packages = with pkgs; [
];
# Environment
home.sessionVariables = {
EDITOR = "nano";
BROWSER = "firefox";
TERMINAL = "alacritty";
};
# Basic configuration of git, please change to your own
programs.git = {
enable = true;
userName = "Tootbrute";
userEmail = "tootbrute@tutamail.com";
extraConfig = {
init.defaultBranch = "main";
};
};
# Starship - an customizable prompt for any shell
programs.starship = {
enable = true;
# custom settings
settings = {
add_newline = false;
aws.disabled = true;
gcloud.disabled = true;
line_break.disabled = true;
};
};
# alacritty - a cross-platform, GPU-accelerated terminal emulator
programs.alacritty = {
enable = true;
# custom settings
settings = {
env.TERM = "xterm-256color";
font = {
normal = {
family = "JetBrains Mono Nerd Font";
style = "Regular";
};
bold = {
family = "JetBrains Mono Nerd Font";
style = "Bold";
};
italic = {
family = "JetBrains Mono Nerd Font";
style = "Italic";
};
};
font = {
size = 20;
};
window.dimensions = {
lines = 40;
columns = 200;
};
scrolling.multiplier = 5;
selection.save_to_clipboard = true;
};
};
#GNOME desktop settings
dconf.settings = {
"org/gnome/desktop/interface" = {
color-scheme = "prefer-dark";
};
};
gtk = {
enable = true;
gtk3.extraConfig = {
Settings = ''
gtk-application-prefer-dark-theme=1
'';
};
gtk4.extraConfig = {
Settings = ''
gtk-application-prefer-dark-theme=1
'';
};
};
programs.bash = {
enable = true;
enableCompletion = true;
bashrcExtra = ''
export PATH="$PATH:$HOME/bin:$HOME/.local/bin:$HOME/go/bin"
'';
};
# neovim setup
vim = {
theme = {
enable = true;
name = "gruvbox";
style = "dark";
};
statusLine.lualine.enable = true;
telescope.enable = true;
autocomplete.nvim-cmp.enable = true;
languages = {
enableLSP = true;
enableTreesitter = true;
nix.enable = true;
ts.enable = true;
rust.enable = true;
};
};
# This value determines the home Manager release that your
# configuration is compatible with. This helps avoid breakage
# when a new home Manager release introduces backwards
# incompatible changes.
#
# You can update home Manager without changing this value. See
# the home Manager release notes for a list of state version
# changes in each release.
home.stateVersion = "24.05";
# Let home Manager install and manage itself.
programs.home-manager.enable = true;
}

15
mods/intel-gpu.nix Normal file
View file

@ -0,0 +1,15 @@
{ config, pkgs, lib, ... }:
# for Accelerated Video Playback
# https://wiki.nixos.org/wiki/Accelerated_Video_Playback
{
hardware.graphics = {
enable = true;
extraPackages = with pkgs; [
intel-media-driver # For Broadwell (2014) or newer processors. LIBVA_DRIVER_NAME=iHD
intel-vaapi-driver # For older processors. LIBVA_DRIVER_NAME=i965, works better for firefox/chromium?
vpl-gpu-rt # For Quick Sync Video
];
};
environment.sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; }; # Optionally, set the environment variable
}

30
mods/neovim-config.nix Normal file
View file

@ -0,0 +1,30 @@
{ pkgs, lib, ... }:
{
# neovim setup with NVF
# https://github.com/NotAShelf/nvf
programs.nvf = {
enable = true;
settings.vim = {
theme = {
enable = true;
name = "gruvbox";
style = "dark";
};
statusLine.lualine.enable = true;
telescope.enable = true;
autocomplete.nvim-cmp.enable = true;
languages = {
enableLSP = true;
enableTreesitter = true;
nix.enable = true;
ts.enable = true;
rust.enable = true;
};
};
};
}

26
mods/systemd.nix Normal file
View file

@ -0,0 +1,26 @@
{ config, pkgs, lib, ... }:
{
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
};
}