refactor: make hosts declarative and consolidate shared config
- add my.username / my.gaming.enable / my.ai.local.enable options and gate optional app modules on them instead of per-host import lists - move vendor-neutral hardware.graphics into modules/graphical, leaving only NVIDIA-specific drivers and env vars in modules/hardware/nvidia - derive the primary user everywhere from my.username (users, getty, home-manager, tmpfiles) - de-duplicate Hyprland autostart down to a single system loginShellInit using the start-hyprland wrapper - consolidate all nixpkgs overlays into modules/core/nix.nix and use final.stdenv.hostPlatform.system - make the zsh rebuild helper target $(hostname) instead of hardcoded hades - add nixpkgs follows for nixos-hardware, pi and comfy-ui (single nixpkgs) - add .gitignore and a nixfmt flake formatter; format all nix files - remove empty browser.nix/display-configuration.nix and rename local_ai.nix -> local-ai.nix - document the my.* toggles in the README
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
# Browser is configured and managed via Home Manager (home/brave.nix)
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
vesktop
|
||||
signal-desktop
|
||||
];
|
||||
environment.systemPackages = with pkgs; [
|
||||
vesktop
|
||||
signal-desktop
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
{
|
||||
imports = [
|
||||
./terminal.nix
|
||||
./browser.nix
|
||||
./communication.nix
|
||||
./dev.nix
|
||||
./virt.nix
|
||||
./gaming.nix
|
||||
./local-ai.nix
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
config = lib.mkIf config.my.gaming.enable {
|
||||
programs.steam = {
|
||||
enable = true;
|
||||
remotePlay.openFirewall = false;
|
||||
dedicatedServer.openFirewall = false;
|
||||
gamescopeSession.enable = false;
|
||||
enable = true;
|
||||
remotePlay.openFirewall = false;
|
||||
dedicatedServer.openFirewall = false;
|
||||
gamescopeSession.enable = false;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
mangohud
|
||||
gamemode
|
||||
mangohud
|
||||
gamemode
|
||||
];
|
||||
};
|
||||
}
|
||||
|
||||
45
modules/apps/local-ai.nix
Normal file
45
modules/apps/local-ai.nix
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.comfy-ui.nixosModules.default
|
||||
];
|
||||
|
||||
config = lib.mkIf config.my.ai.local.enable {
|
||||
services = {
|
||||
comfyui = {
|
||||
enable = true;
|
||||
gpuSupport = "cuda";
|
||||
enableManager = true;
|
||||
port = 8188;
|
||||
listenAddress = "0.0.0.0";
|
||||
dataDir = "/var/lib/comfyui";
|
||||
user = "comfyui";
|
||||
group = "comfyui";
|
||||
createUser = true;
|
||||
};
|
||||
|
||||
ollama = {
|
||||
enable = true;
|
||||
package = pkgs.unstable.ollama-cuda;
|
||||
host = "0.0.0.0";
|
||||
port = 11434;
|
||||
user = "ollama";
|
||||
group = "ollama";
|
||||
home = "/var/lib/ollama";
|
||||
};
|
||||
|
||||
open-webui.enable = true;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
unstable.ollama-cuda
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
{ pkgs, inputs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
inputs.comfy-ui.nixosModules.default
|
||||
];
|
||||
|
||||
services = {
|
||||
comfyui = {
|
||||
enable = true;
|
||||
gpuSupport = "cuda";
|
||||
enableManager = true;
|
||||
port = 8188;
|
||||
listenAddress = "0.0.0.0";
|
||||
dataDir = "/var/lib/comfyui";
|
||||
user = "comfyui";
|
||||
group = "comfyui";
|
||||
createUser = true;
|
||||
};
|
||||
|
||||
ollama = {
|
||||
enable = true;
|
||||
package = pkgs.unstable.ollama-cuda;
|
||||
host = "0.0.0.0";
|
||||
port = 11434;
|
||||
user = "ollama";
|
||||
group = "ollama";
|
||||
home = "/var/lib/ollama";
|
||||
};
|
||||
|
||||
open-webui.enable = true;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
unstable.ollama-cuda
|
||||
];
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
# Terminal is managed elsewhere; system-level CLI helpers live here.
|
||||
environment.systemPackages = with pkgs; [
|
||||
zoxide
|
||||
fzf
|
||||
];
|
||||
# Terminal is managed elsewhere; system-level CLI helpers live here.
|
||||
environment.systemPackages = with pkgs; [
|
||||
zoxide
|
||||
fzf
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ pkgs, ... }:
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
virtualisation = {
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
programs.virt-manager.enable = true;
|
||||
|
||||
users.users.anish.extraGroups = [
|
||||
users.users.${config.my.username}.extraGroups = [
|
||||
"libvirtd"
|
||||
"kvm"
|
||||
"incus-admin"
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./system.nix
|
||||
./users.nix
|
||||
./nix.nix
|
||||
];
|
||||
imports = [
|
||||
../options.nix
|
||||
./system.nix
|
||||
./users.nix
|
||||
./nix.nix
|
||||
];
|
||||
}
|
||||
|
||||
@@ -36,12 +36,16 @@
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
# Single source of truth for overlays; the flake module imports only the
|
||||
# modules and does not declare overlays itself.
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
unstable = import inputs.nixpkgs-unstable {
|
||||
inherit (prev) system;
|
||||
inherit (prev) config;
|
||||
system = final.stdenv.hostPlatform.system;
|
||||
config = final.config;
|
||||
};
|
||||
})
|
||||
inputs.antigravity.overlays.default
|
||||
inputs.comfy-ui.overlays.default
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
{ pkgs, ... }:
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
users.defaultUserShell = pkgs.zsh;
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
loginShellInit = ''
|
||||
if [ -z "$DISPLAY" ] && [ "$TTY" = "/dev/tty1" ]; then
|
||||
exec start-hyprland
|
||||
fi
|
||||
'';
|
||||
};
|
||||
users.defaultUserShell = pkgs.zsh;
|
||||
programs.zsh.enable = true;
|
||||
|
||||
users.users.anish = {
|
||||
isNormalUser = true;
|
||||
description = "Main Account";
|
||||
extraGroups = [ "wheel" "networkmanager" "video" "audio" "gaming" "llm" ];
|
||||
openssh.authorizedKeys.keys = [
|
||||
# ssh-ed25519 AAAAA.... add my key here to enable ssh from another computer
|
||||
];
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
users.users.${config.my.username} = {
|
||||
isNormalUser = true;
|
||||
description = "Main Account";
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
"networkmanager"
|
||||
"video"
|
||||
"audio"
|
||||
"gaming"
|
||||
"llm"
|
||||
];
|
||||
openssh.authorizedKeys.keys = [
|
||||
# ssh-ed25519 AAAAA.... add my key here to enable ssh from another computer
|
||||
];
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,41 +1,58 @@
|
||||
{ pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
programs.hyprland = {
|
||||
enable = true;
|
||||
xwayland.enable = true;
|
||||
};
|
||||
programs.hyprland = {
|
||||
enable = true;
|
||||
xwayland.enable = true;
|
||||
};
|
||||
|
||||
services.getty.autologinUser = "anish";
|
||||
services.getty.autologinUser = config.my.username;
|
||||
|
||||
# Boot straight into Hyprland from the first virtual console on any machine.
|
||||
# No display manager required; tty2-6 remain available as plain shells.
|
||||
environment.loginShellInit = ''
|
||||
if [ "$(tty)" = "/dev/tty1" ]; then
|
||||
exec ${pkgs.hyprland}/bin/Hyprland
|
||||
fi
|
||||
'';
|
||||
# Boot straight into Hyprland from the first virtual console on any machine.
|
||||
# No display manager required; tty2-6 remain available as plain shells.
|
||||
# The start-hyprland wrapper ships with programs.hyprland and sets up the
|
||||
# session environment correctly.
|
||||
environment.loginShellInit = ''
|
||||
if [ "$(tty)" = "/dev/tty1" ]; then
|
||||
exec start-hyprland
|
||||
fi
|
||||
'';
|
||||
|
||||
# Machine-agnostic Wayland session variables.
|
||||
# GPU/vendor specific variables live with their hardware module (e.g. modules/hardware/nvidia.nix).
|
||||
environment.sessionVariables = {
|
||||
NIXOS_OZONE_WL = "1";
|
||||
HYPRCURSOR_ENABLED = "1";
|
||||
MOZ_ENABLE_WAYLAND = "1";
|
||||
QT_QPA_PLATFORM = "wayland;xcb";
|
||||
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
|
||||
CLUTTER_BACKEND = "wayland";
|
||||
GDK_BACKEND = "wayland,x11,*";
|
||||
};
|
||||
# Vendor-neutral graphics stack. Vendor modules (e.g. modules/hardware/nvidia.nix)
|
||||
# only add drivers and vendor-specific environment variables.
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
enable32Bit = true;
|
||||
};
|
||||
|
||||
# Fonts used across the desktop shell (Silicon Volt theme):
|
||||
# JetBrains Mono for terminal/UI mono, IBM Plex Sans for UI sans,
|
||||
# Instrument Serif for display italics, Nanum Gothic Coding as mono fallback.
|
||||
fonts.packages = with pkgs; [
|
||||
nerd-fonts.jetbrains-mono
|
||||
nerd-fonts.fira-code
|
||||
font-awesome
|
||||
ibm-plex
|
||||
nanum-gothic-coding
|
||||
] ++ lib.optional (lib.hasAttr "instrument-serif" pkgs) pkgs.instrument-serif;
|
||||
# Machine-agnostic Wayland session variables.
|
||||
# GPU/vendor specific variables live with their hardware module (e.g. modules/hardware/nvidia.nix).
|
||||
environment.sessionVariables = {
|
||||
NIXOS_OZONE_WL = "1";
|
||||
HYPRCURSOR_ENABLED = "1";
|
||||
MOZ_ENABLE_WAYLAND = "1";
|
||||
QT_QPA_PLATFORM = "wayland;xcb";
|
||||
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
|
||||
CLUTTER_BACKEND = "wayland";
|
||||
GDK_BACKEND = "wayland,x11,*";
|
||||
};
|
||||
|
||||
# Fonts used across the desktop shell (Silicon Volt theme):
|
||||
# JetBrains Mono for terminal/UI mono, IBM Plex Sans for UI sans,
|
||||
# Instrument Serif for display italics, Nanum Gothic Coding as mono fallback.
|
||||
fonts.packages =
|
||||
with pkgs;
|
||||
[
|
||||
nerd-fonts.jetbrains-mono
|
||||
nerd-fonts.fira-code
|
||||
font-awesome
|
||||
ibm-plex
|
||||
nanum-gothic-coding
|
||||
]
|
||||
++ lib.optional (lib.hasAttr "instrument-serif" pkgs) pkgs.instrument-serif;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,39 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
enable32Bit = true;
|
||||
};
|
||||
services.xserver.videoDrivers = [ "nvidia" ];
|
||||
|
||||
services.xserver.videoDrivers = [ "nvidia" ];
|
||||
boot.initrd.kernelModules = [
|
||||
"nvidia"
|
||||
"nvidia_modeset"
|
||||
"nvidia_uvm"
|
||||
"nvidia_drm"
|
||||
];
|
||||
boot.kernelParams = [
|
||||
"nvidia-drm.modeset=1"
|
||||
"nvidia-drm.fbdev=1"
|
||||
];
|
||||
|
||||
boot.initrd.kernelModules = [ "nvidia" "nvidia_modeset" "nvidia_uvm" "nvidia_drm" ];
|
||||
boot.kernelParams = [
|
||||
"nvidia-drm.modeset=1"
|
||||
"nvidia-drm.fbdev=1"
|
||||
];
|
||||
|
||||
hardware.nvidia = {
|
||||
modesetting.enable = true;
|
||||
powerManagement.enable = true;
|
||||
powerManagement.finegrained = lib.mkDefault false;
|
||||
open = lib.mkDefault true;
|
||||
nvidiaSettings = true;
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
};
|
||||
hardware.nvidia = {
|
||||
modesetting.enable = true;
|
||||
powerManagement.enable = true;
|
||||
powerManagement.finegrained = lib.mkDefault false;
|
||||
open = lib.mkDefault true;
|
||||
nvidiaSettings = true;
|
||||
package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
};
|
||||
|
||||
# NVIDIA-specific session variables live here so machines without
|
||||
# NVIDIA GPUs (which do not import this module) stay vendor-clean.
|
||||
environment.sessionVariables = {
|
||||
LIBVA_DRIVER_NAME = "nvidia";
|
||||
GBM_BACKEND = "nvidia-drm";
|
||||
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
|
||||
NVD_BACKEND = "direct";
|
||||
};
|
||||
# NVIDIA-specific session variables live here so machines without
|
||||
# NVIDIA GPUs (which do not import this module) stay vendor-clean.
|
||||
environment.sessionVariables = {
|
||||
LIBVA_DRIVER_NAME = "nvidia";
|
||||
GBM_BACKEND = "nvidia-drm";
|
||||
__GLX_VENDOR_LIBRARY_NAME = "nvidia";
|
||||
NVD_BACKEND = "direct";
|
||||
};
|
||||
}
|
||||
|
||||
20
modules/options.nix
Normal file
20
modules/options.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
# Shared, machine-agnostic configuration surface. Hosts enable optional
|
||||
# feature modules by setting these booleans instead of editing import lists.
|
||||
options.my = {
|
||||
username = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "anish";
|
||||
description = "Primary interactive user account.";
|
||||
};
|
||||
|
||||
gaming.enable = lib.mkEnableOption "Steam, Gamemode and gaming tooling";
|
||||
|
||||
ai.local.enable = lib.mkEnableOption "local AI services (Ollama, ComfyUI, Open WebUI)";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user