initial commit

This commit is contained in:
2026-08-05 18:57:23 +01:00
commit dda5d14d63
51 changed files with 1123 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
{...}: {
# PipeWire-based audio. wpctl (used by the Hyprland media keybinds) is provided
# by wireplumber, which PipeWire enables by default.
flake.nixosModules.audio = {pkgs, ...}: {
environment.systemPackages = with pkgs; [
playerctl # media keys (hypr keybinds)
pavucontrol # GUI mixer (waybar pulseaudio on-click)
];
# PipeWire replaces the PulseAudio server; don't run the standalone daemon.
services.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
};
}
+31
View File
@@ -0,0 +1,31 @@
{...}: {
flake.nixosModules.bootloader = {
pkgs,
lib,
...
}: {
boot = {
loader = {
timeout = 2;
efi = {
canTouchEfiVariables = true;
};
grub = {
efiSupport = true;
device = "nodev";
theme = pkgs.catppuccin-grub;
};
};
plymouth = {
enable = true;
theme = "catppuccin-mocha";
themePackages = with pkgs; [
(catppuccin-plymouth.override {
variant = "mocha";
})
];
};
kernelPackages = pkgs.linuxPackages_latest;
};
};
}
+43
View File
@@ -0,0 +1,43 @@
{
self,
inputs,
...
}: {
flake.nixosModules.core = {
pkgs,
lib,
...
}: let
modules = with self.nixosModules; [
user
bootloader
nix
hardware
locale
nix-ld
];
in {
imports =
[
/etc/nixos/hardware-configuration.nix
]
++ modules;
services = {
openssh.enable = true;
avahi.enable = true;
};
environment.systemPackages = with pkgs; [
# neovim is provided by the nvim feature module (programs.neovim.enable).
unzip
p7zip-rar
usbutils
lsof
gvfs
libnotify
python313
curlWithGnuTls
wget
];
system.stateVersion = "26.05";
};
}
+11
View File
@@ -0,0 +1,11 @@
{...}: {
flake.nixosModules.hardware = {...}: {
hardware = {
bluetooth = {
enable = true;
powerOnBoot = true;
};
xpadneo.enable = true;
};
};
}
+32
View File
@@ -0,0 +1,32 @@
{
self,
inputs,
...
}: {
flake.nixosModules.locale = {
pkgs,
lib,
...
}: {
time.timeZone = "Europe/London";
i18n = {
defaultLocale = "en_GB.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "en_GB.UTF-8";
LC_IDENTIFICATION = "en_GB.UTF-8";
LC_MEASUREMENT = "en_GB.UTF-8";
LC_MONETARY = "en_GB.UTF-8";
LC_NAME = "en_GB.UTF-8";
LC_NUMERIC = "en_GB.UTF-8";
LC_PAPER = "en_GB.UTF-8";
LC_TELEPHONE = "en_GB.UTF-8";
LC_TIME = "en_GB.UTF-8";
};
};
services.xserver.xkb = {
layout = "gb";
variant = "";
};
console.keyMap = "uk";
};
}
+23
View File
@@ -0,0 +1,23 @@
{inputs, ...}: {
flake.nixosModules.nix = {...}: {
nix = {
settings = {
cores = 6;
trusted-users = ["root" "ahmza"];
download-buffer-size = 524288000;
experimental-features = [
"nix-command"
"flakes"
];
};
nixPath = ["nixpkgs=${inputs.nixpkgs}"];
optimise.automatic = true;
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 5d";
};
};
nixpkgs.config.allowUnfree = true;
};
}
+30
View File
@@ -0,0 +1,30 @@
{self, ...}: {
flake.nixosModules.user = {
pkgs,
...
}: let
modules = with self.nixosModules; [
zsh
stow
];
in {
imports = modules;
ahmza.stow = {
enable = true;
user = "ahmza";
# repoPath defaults to /home/ahmza/dot
};
users.users.ahmza = {
isNormalUser = true;
initialPassword = "qwer";
shell = pkgs.zsh;
description = "ahmza";
extraGroups = [
"networkmanager"
"wheel"
];
};
};
}
+20
View File
@@ -0,0 +1,20 @@
{
self,
moduleWithSystem,
...
}: {
flake.nixosModules.desktop = moduleWithSystem ({pkgs, ...}: let
modules = with self.nixosModules; [
core
hyprland
sddm
network
];
in {
imports = modules;
environment.systemPackages = with pkgs; [
mpv
];
});
}
+7
View File
@@ -0,0 +1,7 @@
{...}: {
# AMD CPU: microcode updates (applied via initrd at boot).
flake.nixosModules.cpuAmd = {...}: {
hardware.cpu.amd.updateMicrocode = true;
hardware.enableRedistributableFirmware = true;
};
}
+7
View File
@@ -0,0 +1,7 @@
{...}: {
# Intel CPU: microcode updates (applied via initrd at boot).
flake.nixosModules.cpuIntel = {...}: {
hardware.cpu.intel.updateMicrocode = true;
hardware.enableRedistributableFirmware = true;
};
}
+20
View File
@@ -0,0 +1,20 @@
{...}: {
# AMD GPU (mesa + RADV/ROCm).
flake.nixosModules.gpuAmd = {pkgs, ...}: {
environment.systemPackages = with pkgs; [
mesa
vulkan-tools
rocmPackages.rocm-smi
rocmPackages.rocminfo
];
hardware.graphics = {
enable = true;
enable32Bit = true;
extraPackages = with pkgs; [
libva-vdpau-driver
libvdpau-va-gl
rocmPackages.clr.icd
];
};
};
}
+18
View File
@@ -0,0 +1,18 @@
{...}: {
# Intel integrated GPU (mesa + VA-API hardware video acceleration).
flake.nixosModules.gpuIntel = {pkgs, ...}: {
environment.systemPackages = with pkgs; [
mesa
vulkan-tools
];
hardware.graphics = {
enable = true;
enable32Bit = true;
extraPackages = with pkgs; [
intel-media-driver # modern iHD driver (Broadwell+)
intel-vaapi-driver # legacy i965 driver
libva-vdpau-driver
];
};
};
}
@@ -0,0 +1,41 @@
{self, ...}: {
# Hybrid Intel + NVIDIA (PRIME) for laptops like the T480 (Intel UHD 620 +
# NVIDIA MX150). Uses "offload" mode: the dGPU stays powered down by default
# (minimal extra battery drain) and is only used for apps launched with
# `nvidia-offload <cmd>`. It also pulls in the Intel GPU stack (gpuIntel).
#
# Bus IDs below are specific to the T480 (from `lspci`):
# Intel 00:02.0 -> PCI:0:2:0
# NVIDIA 01:00.0 -> PCI:1:0:0
# Adjust for other machines.
flake.nixosModules.gpuNvidiaPrime = {
config,
pkgs,
...
}: {
imports = [self.nixosModules.gpuIntel];
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
modesetting.enable = true;
# MX150 is Pascal (pre-Turing); the proprietary modules are the safe choice.
open = false;
nvidiaSettings = true;
powerManagement.enable = true;
prime = {
# Offload keeps the NVIDIA GPU asleep until explicitly used. This gives
# the `nvidia-offload` helper wrapper. Swap to sync mode if you want the
# dGPU always driving the display (higher power draw).
offload = {
enable = true;
enableOffloadCmd = true; # provides `nvidia-offload` wrapper
};
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
};
};
};
}
+31
View File
@@ -0,0 +1,31 @@
{...}: {
# Dedicated NVIDIA GPU (single discrete card, no hybrid/PRIME).
# For Intel+NVIDIA laptops (e.g. the T480), use gpuNvidiaPrime instead.
flake.nixosModules.gpuNvidia = {
config,
pkgs,
...
}: {
services.xserver.videoDrivers = ["nvidia"];
hardware.graphics = {
enable = true;
enable32Bit = true;
};
hardware.nvidia = {
modesetting.enable = true;
# Proprietary kernel modules. Set to true only for Turing+ (RTX 20xx and
# newer) where the open modules are well supported.
open = false;
nvidiaSettings = true;
# Fixes suspend/resume corruption on many setups.
powerManagement.enable = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
environment.systemPackages = with pkgs; [
vulkan-tools
];
};
}
+13
View File
@@ -0,0 +1,13 @@
{...}: {
flake.nixosModules.network = {...}: {
networking = {
networkmanager.enable = true;
# Firewall intentionally disabled (trusted LAN; local services like
# weylus / remote play need open ports).
firewall.enable = false;
};
# Don't block boot waiting for a network connection.
systemd.services.NetworkManager-wait-online.enable = false;
};
}
+16
View File
@@ -0,0 +1,16 @@
{moduleWithSystem, ...}: {
flake.nixosModules.nix-ld = moduleWithSystem ({pkgs, ...}: {
programs = {
nix-ld = {
enable = true;
libraries = with pkgs; [
util-linux
stdenv.cc.cc
zlib
libusb1
];
};
};
});
}
+115
View File
@@ -0,0 +1,115 @@
{...}: {
flake.nixosModules.stow = {
config,
pkgs,
lib,
...
}: let
cfg = config.ahmza.stow;
stowScript = pkgs.writeShellApplication {
name = "ahmza-stow";
runtimeInputs = [pkgs.stow pkgs.coreutils pkgs.findutils pkgs.gnused];
text = ''
set -euo pipefail
REPO="${cfg.repoPath}"
TARGET="$HOME"
if [ ! -d "$REPO" ]; then
echo "ahmza-stow: dotfiles repo not found at $REPO; skipping." >&2
echo " (clone it with: git clone ${cfg.repoUrl} $REPO)" >&2
exit 0
fi
packages=(${lib.escapeShellArgs cfg.packages})
if [ ''${#packages[@]} -eq 0 ]; then
echo "ahmza-stow: no packages configured; nothing to do."
exit 0
fi
cd "$REPO"
# Back up any existing non-symlink targets that would block stowing $pkg.
# Mirrors the dotfiles repo's own install script: list the files/links the
# package provides (relative to the package dir) and back up only real
# (non-symlink) targets. Skipping symlinks means we never write through an
# already-stowed folded directory symlink into the repo itself.
# Backups go to <file>.pre-stow.bak.
backup_conflicts() {
local pkg="$1" rel target
while IFS= read -r rel; do
target="$HOME/$rel"
if [ -e "$target" ] && [ ! -L "$target" ]; then
echo "ahmza-stow: backing up existing $target -> $target.pre-stow.bak"
mv "$target" "$target.pre-stow.bak"
fi
done < <(cd "$REPO/$pkg" && find . \( -type f -o -type l \) | sed 's|^\./||')
}
for pkg in "''${packages[@]}"; do
if [ ! -d "$pkg" ]; then
echo "ahmza-stow: package '$pkg' not present in repo; skipping." >&2
continue
fi
echo "ahmza-stow: stow -R $pkg"
# Try to stow first; only back up (and retry) if there's a real conflict.
if ! stow -R --target="$TARGET" "$pkg" 2>/dev/null; then
echo "ahmza-stow: conflicts detected for '$pkg'; backing up and retrying."
backup_conflicts "$pkg"
if ! stow -R --target="$TARGET" "$pkg"; then
echo "ahmza-stow: failed to stow '$pkg' — resolve manually." >&2
fi
fi
done
echo "ahmza-stow: done."
'';
};
in {
options.ahmza.stow = {
enable = lib.mkEnableOption "automatic GNU Stow of dotfiles on login";
user = lib.mkOption {
type = lib.types.str;
description = "User whose dotfiles should be stowed.";
};
repoPath = lib.mkOption {
type = lib.types.str;
default = "/home/${cfg.user}/dot";
defaultText = "/home/\${config.ahmza.stow.user}/dot";
description = "Absolute path to the stow dotfiles repository.";
};
repoUrl = lib.mkOption {
type = lib.types.str;
default = "https://github.com/ahmzaa/dot.git";
description = "URL of the dotfiles repo (used only in help messages).";
};
packages = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [];
description = ''
Stow package names (top-level dirs in the dotfiles repo) to link.
Feature modules append to this via lib.mkAfter / list concatenation.
'';
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [pkgs.stow stowScript];
systemd.user.services.ahmza-stow = {
description = "Stow dotfiles for ${cfg.user}";
wantedBy = ["default.target"];
serviceConfig = {
Type = "oneshot";
ExecStart = lib.getExe stowScript;
};
};
};
};
}
+25
View File
@@ -0,0 +1,25 @@
{...}: {
flake.nixosModules.bibataCursors = {pkgs, ...}: {
environment.systemPackages = with pkgs; [
bibata-cursors
];
environment.variables = {
XCURSOR_THEME = "Bibata-Modern-Ice";
XCURSOR_SIZE = "20";
};
programs.dconf.profiles.user.databases = [
{
lockAll = false;
settings = {
"org/gnome/desktop/interface" = {
cursor-theme = "Bibata-Modern-Ice";
font-name = "JetBrainsMono Nerd Font 11";
};
};
}
];
};
}
+21
View File
@@ -0,0 +1,21 @@
{
self,
inputs,
...
}: {
flake.nixosModules.systemTheme = {
config,
pkgs,
lib,
...
}: let
modules = with self.nixosModules; [
bibataCursors
catppuccinGtk
fonts
];
in {
imports = modules;
};
}
+23
View File
@@ -0,0 +1,23 @@
{...}: {
# System-wide fonts. Standardized on JetBrainsMono Nerd Font everywhere
# (terminal, sddm, gtk/dconf, waybar, etc.).
flake.nixosModules.fonts = {pkgs, ...}: {
fonts = {
packages = with pkgs; [
nerd-fonts.jetbrains-mono
# Fallbacks for emoji / CJK / general coverage.
noto-fonts
noto-fonts-color-emoji
];
enableDefaultPackages = true;
fontconfig.defaultFonts = {
monospace = ["JetBrainsMono Nerd Font"];
sansSerif = ["JetBrainsMono Nerd Font"];
serif = ["JetBrainsMono Nerd Font"];
emoji = ["Noto Color Emoji"];
};
};
};
}
+44
View File
@@ -0,0 +1,44 @@
{
self,
inputs,
...
}: {
flake.nixosModules.catppuccinGtk = {
pkgs,
lib,
...
}: let
in {
environment.systemPackages = with pkgs; [
(catppuccin-gtk.override {
variant = "mocha";
accents = ["mauve"];
tweaks = ["rimless"];
size = "compact";
})
(catppuccin-papirus-folders.override {
flavor = "mocha";
accent = "mauve";
})
];
programs = {
xfconf.enable = true;
dconf = {
enable = true;
profiles.user.databases = [
{
lockAll = false;
settings = {
"org/gnome/desktop/interface" = {
gtk-theme = "catppuccin-mocha-mauve-compact+rimless";
icon-theme = "Papirus";
color-scheme = "prefer-dark";
};
};
}
];
};
};
};
}