refactor: move system modules into proper directories

This commit is contained in:
Mohammad Rafiq 2025-03-27 03:04:21 +08:00
parent 16f28bf227
commit 1989535535
No known key found for this signature in database
10 changed files with 80 additions and 105 deletions

View file

@ -1,13 +1,8 @@
{
lib,
hostname,
pkgs,
type,
modulesPath,
inputs,
config,
specialArgs,
username,
...
}:
{
@ -15,13 +10,14 @@
# Common options for all machines.
[
(modulesPath + "/installer/scan/not-detected.nix")
./modules/bootloaders/systemd-boot.nix
./modules/boot.nix
./modules/networking.nix
./modules/nix.nix
./modules/programs/zsh.nix
./modules/hardware/networking.nix
./modules/security.nix
./modules/users.nix
]
# Options for desktops.
# Options for graphical systems.
(lib.optionals (type == "desktop") [
./modules/hardware/audio.nix
./modules/hardware/bluetooth.nix
@ -33,66 +29,9 @@
# Options for specific hostnames.
(lib.optionals (hostname == "nemesis") [
./hw-nemesis.nix
./modules/hardware/nvidia.nix
./modules/bootloaders/systemd-boot.nix
./modules/hardware/cpu_amd.nix
./modules/hardware/nvidia.nix
])
];
boot = {
loader = {
timeout = 5;
efi.canTouchEfiVariables = true;
};
kernelPackages = pkgs.linuxPackages_latest;
initrd.availableKernelModules = [
"nvme"
"xhci_pci"
"ahci"
"usbhid"
"usb_storage"
"sd_mod"
];
};
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = specialArgs;
};
system.stateVersion = "24.11";
users.mutableUsers = false; # Always reset users on system activation
nixpkgs.config.allowUnfree = true;
nix = {
settings.experimental-features = [
"nix-command"
"flakes"
"pipe-operators"
];
# Add binary caches to avoid having to compile them
settings = {
substituters = [
"https://hyprland.cachix.org"
"https://cuda-maintainers.cachix.org"
"https://nix-community.cachix.org"
"https://nvf.cachix.org"
"https://yazi.cachix.org"
];
trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nvf.cachix.org-1:GMQWiUhZ6ux9D5CvFFMwnc2nFrUHTeGaXRlVBXo+naI="
"yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k="
];
};
};
time.timeZone = "Asia/Singapore";
i18n.defaultLocale = "en_SG.UTF-8";
}

18
systems/modules/boot.nix Normal file
View file

@ -0,0 +1,18 @@
{ pkgs, ... }:
{
boot = {
loader = {
timeout = 5;
efi.canTouchEfiVariables = true;
};
kernelPackages = pkgs.linuxPackages_latest;
initrd.availableKernelModules = [
"nvme"
"xhci_pci"
"ahci"
"usbhid"
"usb_storage"
"sd_mod"
];
};
}

View file

@ -1,6 +0,0 @@
{
# Use the extlinux boot loader. (NixOS wants to enable GRUB by default)
boot.loader.grub.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf
boot.loader.generic-extlinux-compatible.enable = true;
}

View file

@ -3,10 +3,17 @@
pkgs,
config,
...
}: {
}:
{
# Accept the license by default; needed for some packages.
nixpkgs.config.nvidia.acceptLicense = true;
services.xserver.videoDrivers = ["nvidia"];
nix.settings = {
substituters = [ "https://cuda-maintainers.cachix.org" ];
trusted-public-keys = [
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
];
};
services.xserver.videoDrivers = [ "nvidia" ];
environment.variables = {
GBM_BACKEND = "nvidia-drm";
LIBVA_DRIVER_NAME = "nvidia";
@ -17,19 +24,23 @@
nvidia-container-toolkit.enable = true;
graphics = {
enable = true;
package = inputs.hyprland.inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}.mesa.drivers;
package = inputs.hyprland.inputs.nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}.mesa;
extraPackages = with pkgs; [
nvidia-vaapi-driver # hardware acceleration
];
};
nvidia = {
modesetting.enable = true;
# powerManagement.enable = true;
open = false;
nvidiaSettings = true;
nvidiaPersistenced = true;
package = config.boot.kernelPackages.nvidiaPackages.latest;
};
};
boot.initrd.availableKernelModules = ["nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm"];
boot.initrd.availableKernelModules = [
"nvidia"
"nvidia_modeset"
"nvidia_uvm"
"nvidia_drm"
];
}

28
systems/modules/nix.nix Normal file
View file

@ -0,0 +1,28 @@
{
system.stateVersion = "24.11";
nixpkgs.config.allowUnfree = true;
nix = {
settings = {
experimental-features = [
"nix-command"
"flakes"
"pipe-operators"
];
# Add binary caches to avoid having to compile them
substituters = [
"https://hyprland.cachix.org"
"https://nix-community.cachix.org"
"https://nvf.cachix.org"
"https://yazi.cachix.org"
];
trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"nvf.cachix.org-1:GMQWiUhZ6ux9D5CvFFMwnc2nFrUHTeGaXRlVBXo+naI="
"yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k="
];
};
};
}

View file

@ -1,2 +0,0 @@
{
}

View file

@ -1,8 +0,0 @@
{ inputs, ... }:
{
sops = {
defaultSopsFile = ../../../secrets/secrets.yaml;
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
secrets.password.neededForUsers = true;
};
}

View file

@ -1,5 +1,16 @@
{ config, ... }:
{ config, specialArgs, ... }:
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = specialArgs;
};
users.mutableUsers = false; # Always reset users on system activation
time.timeZone = "Asia/Singapore";
i18n.defaultLocale = "en_SG.UTF-8";
home-manager.users.rafiq.imports = [ ../../users/rafiq.nix ];
users.users.rafiq = {
isNormalUser = true;

View file

@ -1,16 +0,0 @@
{ inputs, config, ... }:
{
home-manager.users.rafiq.imports = [ ../../../users/rafiq.nix ];
users.users.rafiq = {
isNormalUser = true;
description = "rafiq";
hashedPasswordFile = config.sops.secrets.password.path;
extraGroups = [
"networkmanager"
"wheel"
];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILdsZyY3gu8IGB8MzMnLdh+ClDxQQ2RYG9rkeetIKq8n"
];
};
}