feat(modules): core option system and shared lib helpers

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-06-28 06:48:07 +02:00
commit 3b21d570e0
3 changed files with 887 additions and 0 deletions

390
modules/core.nix Normal file
View file

@ -0,0 +1,390 @@
{
config,
pkgs,
lib,
...
}:
let
inherit (lib)
mkEnableOption
mkOption
mkIf
mkMerge
mkDefault
types
;
cfg = config.omni;
in
{
options.omni = {
enable = mkEnableOption "Omnixient system configuration";
# User Configuration
user = mkOption {
type = types.str;
default = "user";
description = "Primary user for the system";
example = "john";
};
# Theme Configuration
theme = mkOption {
type = types.enum [
"tokyo-night"
"catppuccin"
"gruvbox"
"nord"
"everforest"
"rose-pine"
"kanagawa"
];
default = "tokyo-night";
description = "System theme - changes colors, wallpaper, and overall look";
example = "catppuccin";
};
# User-friendly theme aliases
darkMode = mkOption {
type = types.bool;
default = true;
description = "Use dark theme variant when available";
};
displayManager = mkOption {
type = types.enum [
"gdm"
"tuigreet"
];
default = "tuigreet";
description = "Display manager to use for login";
};
colorScheme = mkOption {
type = types.nullOr types.attrs;
default = null;
description = "Color scheme from nix-colors. If null, uses theme-specific colors.";
example = "inputs.nix-colors.colorSchemes.tokyo-night-dark";
};
wallpaper = mkOption {
type = types.nullOr types.path;
default = null;
description = "Path to wallpaper for automatic color generation";
};
# Feature Categories - Simple on/off switches for major functionality
features = {
# Development
coding = mkEnableOption "Development tools, editors, and programming languages";
containers = mkEnableOption "Docker and container support";
# Entertainment
gaming = mkEnableOption "Gaming support with Steam, Wine, and performance tools";
media = mkEnableOption "Video players, image viewers, and media editing tools";
# Productivity
office = mkEnableOption "Office suite, PDF viewers, and productivity apps";
communication = mkEnableOption "Chat apps, email clients, and video conferencing";
# System
virtualization = mkEnableOption "VM support (VirtualBox, QEMU, etc.)";
backup = mkEnableOption "Backup tools and cloud sync applications";
# Appearance
customThemes = mkEnableOption "Advanced theming with nix-colors integration";
wallpaperEffects = mkEnableOption "Dynamic wallpapers and color generation";
};
# Simple Presets - Predefined feature combinations
preset = mkOption {
type = types.nullOr (
types.enum [
"minimal"
"developer"
"creator"
"gamer"
"office"
"everything"
]
);
default = null;
description = ''
Quick setup preset that automatically enables related features:
- minimal: Just the basics (browser, terminal, file manager)
- developer: Coding tools, containers, git, IDEs
- creator: Media editing, design tools, content creation
- gamer: Gaming support, performance tools, Discord
- office: Productivity apps, office suite, communication
- everything: All features enabled
'';
example = "developer";
};
};
config = mkIf cfg.enable {
# Apply preset configurations automatically
omni.features = mkMerge [
# Default features based on preset
(mkIf (cfg.preset == "minimal") {
# Only basic features
})
(mkIf (cfg.preset == "developer") {
coding = mkDefault true;
containers = mkDefault true;
customThemes = mkDefault true;
media = mkDefault true;
communication = mkDefault true;
})
(mkIf (cfg.preset == "creator") {
media = mkDefault true;
office = mkDefault true;
customThemes = mkDefault true;
wallpaperEffects = mkDefault true;
})
(mkIf (cfg.preset == "gamer") {
gaming = mkDefault true;
media = mkDefault true;
communication = mkDefault true;
})
(mkIf (cfg.preset == "office") {
office = mkDefault true;
communication = mkDefault true;
backup = mkDefault true;
})
(mkIf (cfg.preset == "everything") {
coding = mkDefault true;
containers = mkDefault true;
gaming = mkDefault true;
media = mkDefault true;
office = mkDefault true;
communication = mkDefault true;
virtualization = mkDefault true;
backup = mkDefault true;
customThemes = mkDefault true;
wallpaperEffects = mkDefault true;
})
];
# Basic system configuration
system.autoUpgrade = {
enable = true;
flake = "/etc/nixos#omni";
flags = [
"--update-input"
"nixpkgs"
"--commit-lock-file"
];
dates = "weekly";
};
# Enable documentation
documentation = {
enable = true;
man.enable = true;
};
# Security settings
security.sudo = {
enable = true;
wheelNeedsPassword = true;
extraRules = [
{
groups = [ "wheel" ];
commands = [
{
command = "/run/current-system/sw/bin/nixos-rebuild";
options = [ "NOPASSWD" ];
}
];
}
];
};
# Services, hardware, bluetooth, graphics, polkit, openssh, fstrim,
# thermald, power-profiles, avahi, smartd are all in:
# modules/services.nix and modules/hardware/
# Programs configuration
programs = {
# nh — Rust frontend for nixos-rebuild used by omni-rebuild.
# Sets $NH_FLAKE / $FLAKE so `nh os switch` (and `nh home switch`)
# resolve the right flake without an explicit path.
nh = {
enable = true;
flake = "/etc/nixos";
};
};
# Environment variables
environment.variables = {
EDITOR = "nvim";
VISUAL = "nvim";
BROWSER = "chromium";
TERM = "xterm-256color";
# Development
CARGO_HOME = "$HOME/.cargo";
GOPATH = "$HOME/go";
NPM_CONFIG_PREFIX = "$HOME/.npm";
# Omnixient specific
OMNI_ROOT = "/etc/nixos";
OMNI_VERSION = "1.0.0";
};
# Shell configuration
programs.bash = {
interactiveShellInit = ''
# Omnixient bash initialization
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$HOME/go/bin:$HOME/.npm/bin:$PATH"
# Aliases
alias ll='eza -la'
alias ls='eza'
alias cat='bat'
alias grep='rg'
alias find='fd'
alias vim='nvim'
alias vi='nvim'
alias n='nvim'
# Omnixient specific aliases (omni-rebuild is a script, not an alias)
alias omni-update='nix flake update --flake /etc/nixos'
alias omni-clean='sudo nix-collect-garbage -d'
alias omni-search='nix search nixpkgs'
# Functions
omni-theme() {
local theme=$1
if [ -z "$theme" ]; then
echo "Available themes: tokyo-night, catppuccin, catppuccin-latte, gruvbox, nord, everforest, rose-pine, kanagawa, matte-black, osaka-jade, ristretto"
return 1
fi
echo "Switching to theme: $theme"
# This would need to update the configuration and rebuild
sudo sed -i "s/currentTheme = \".*\"/currentTheme = \"$theme\"/" /etc/nixos/configuration.nix
omni-rebuild
}
omni-help() {
cat << EOF
Omnixient Commands:
===============
omni-rebuild - Rebuild system configuration
omni-update - Update flake inputs
omni-clean - Garbage collect nix store
omni-search - Search for packages
omni-theme - Change system theme
omni-help - Show this help message
Key Bindings (Hyprland):
=======================
Super + Return - Open terminal
Super + B - Open browser
Super + E - Open file manager
Super + D - Application launcher
Super + Q - Close window
Super + F - Fullscreen
Super + Space - Toggle floating
For more information, visit: https://github.com/TheArctesian/omnixy
EOF
}
# Welcome message
if [ -z "$IN_NIX_SHELL" ]; then
echo "Welcome to Omnixient! Type 'omni-help' for available commands."
fi
'';
promptInit = ''
# Starship prompt
if command -v starship &> /dev/null; then
eval "$(starship init bash)"
fi
# try — experiment directory manager
if command -v try &> /dev/null; then
eval "$(try init ~/Work/tries)"
fi
'';
};
# System-wide packages
environment.systemPackages =
with pkgs;
[
# Core utilities
coreutils
findutils
gnugrep
gnused
gawk
# System tools
htop
fastfetch
tree
wget
curl
# Text editors
vim
nano
# Version control (always needed, even on minimal/ISO)
git
# Experiment directory manager (tobi/try)
ruby
(pkgs.callPackage ../packages/try-cli.nix { })
# Nix tools
nix-prefetch-git
nixfmt
nil
# Custom Omnixient scripts
(writeShellScriptBin "omni-info" ''
#!/usr/bin/env bash
echo "🌟 Omnixient NixOS Configuration"
echo "============================="
echo ""
echo "📋 Basic Settings:"
echo " User: ${cfg.user}"
echo " Theme: ${cfg.theme}"
echo " Preset: ${if cfg.preset != null then cfg.preset else "custom"}"
echo " Display Manager: ${cfg.displayManager}"
echo ""
echo "🎯 Active Features:"
echo " Development: ${if cfg.features.coding or false then "" else ""}"
echo " Containers: ${if cfg.features.containers or false then "" else ""}"
echo " Gaming: ${if cfg.features.gaming or false then "" else ""}"
echo " Media: ${if cfg.features.media or false then "" else ""}"
echo " Office: ${if cfg.features.office or false then "" else ""}"
echo " Communication: ${if cfg.features.communication or false then "" else ""}"
echo " Virtualization: ${if cfg.features.virtualization or false then "" else ""}"
echo " Backup: ${if cfg.features.backup or false then "" else ""}"
echo ""
echo "🎨 Theming:"
echo " Custom Themes: ${if cfg.features.customThemes or false then "" else ""}"
echo " Wallpaper Effects: ${if cfg.features.wallpaperEffects or false then "" else ""}"
echo " Color Scheme: ${if cfg.colorScheme != null then "Custom" else "Theme-based"}"
echo " Wallpaper: ${if cfg.wallpaper != null then toString cfg.wallpaper else "Not set"}"
echo ""
echo "💡 Quick Commands:"
echo " omni-setup-colors - Configure colors and themes"
echo " omni-rebuild - Rebuild system configuration"
echo " omni-help - Show keyboard shortcuts and help"
echo ""
echo "📊 System Information:"
nixos-version --json | ${pkgs.jq}/bin/jq -r '" NixOS: " + .nixosVersion'
echo " Kernel: $(uname -r)"
echo " Uptime: $(uptime -p)"
'')
];
};
}