- Nix 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .agents | ||
| modules | ||
| secrets | ||
| skills/system/run-workflow | ||
| .gitignore | ||
| .sops.yaml | ||
| flake.lock | ||
| flake.nix | ||
| README.md | ||
❄️ NixConfig
Configuração NixOS — Desktop Alfa + VPS omega
Desde 22/07/2025
nixpkgsseguenixpkgs-unstable(via chaotic/nyx) e osystem.stateVersionestá em25.11— o badge indica o canal, não a versão do SO.
🖥️ Hosts
| Host | Arquitetura | Função | Kernel |
|---|---|---|---|
| Alfa | x86_64-linux |
Desktop / Workstation / Gaming / IA | CachyOS (genérico, patches BORE) |
| omega | aarch64-linux |
VPS Headless (serviços via Docker + NetBird) | nixpkgs padrão |
💡 O kernel do Alfa é o
linuxPackages_cachyosemmodules/alfa/hardware/boot.nix. Para a variante LTO basta trocar paralinuxPackages_cachyos-lto.
🧩 Módulos compartilhados — modules/common/
Base importada pelos 2 hosts (cada host mantém só o delta):
| Módulo | O que centraliza |
|---|---|
nix.nix |
Lix, experimental-features, accept-flake-config, trusted-users=root,@wheel, paralelismo (cores=0, max-jobs="auto"), nh (clean 8d/7), nix-ld, allowUnfree |
caches.nix |
Substituters e chaves públicas por host (cache.nixos.org, nix-community, chaotic nos 2; compositores/apps desktop só no Alfa) |
shell.nix |
Fish (auto-switch seguro em Bash interativo sem quebrar scp/rsync), Starship no omega (no Alfa fica no HM + Stylix), aliases upd e flakeadd |
security.nix |
OpenSSH hardenado (PermitRootLogin="no", só chave, MaxAuthTries=3, keepalive), Fail2ban com ignoreIP do NetBird + bantime-increment, sudo-rs (execWheelOnly, com senha) |
services.nix |
NetBird (+UI no Alfa), nftables + firewall ligado, Docker (enable, autoPrune e rotação de logs JSON) |
base.nix |
Timezone America/Bahia + locale en_US (defaults), curl/wget/htop/vim/git/speedtest, journald 500M, cleanOnBoot, timesyncd, systemd-oomd, EDITOR=vim |
Regra: o que é igual nos 2 vai pro
common; o que difere fica emmodules/alfa/oumodules/omega/commkDefault/mkForceexplícito.O
nix.optimisesó liga no omega (modules/omega/default.nix) porque o store dele éext4(noatime); no Alfa o store é CoW (ZFS comautoScrubetrim).
🎯 Desktop — Alfa
Interfaces
| Interface | Status |
|---|---|
| Umbriel (WM) | ✅ Ativo (DM: Noctalia Greeter) |
| KDE Plasma 6 | ⏸️ Disponível (DM: plasma-login-manager) |
| Hyprland (WM) | ⏸️ Disponível (DM: Noctalia Greeter + UWSM) |
| Niri (WM) | ⏸️ Disponível (DM: Noctalia Greeter) |
| Mango (WM) | ⏸️ Disponível (DM: Noctalia Greeter) |
| GNOME | ⏸️ Disponível (DM: GDM) |
| Cosmic | ⏸️ Disponível (DM: cosmic-greeter) |
| Noctalia (Shell) | ✅ Shell via noctalia.service nos 4 WMs Wayland |
Seletor unificado de interfaces: altere
desktopemmodules/alfa/desktop/default.nix(fonte única de verdade para system e home-manager; cada DE lê viaconfig.desktop). Apenas a selecionada é ativada (sem dependências cruzadas no closure). Ativo atualmente:umbriel.
🛠️ Otimizações
- Kernel & Storage: CachyOS +
zfs_cachyos(autoScrub,trim, Sanoid emzpool/home, ZFS ARC limitado entre 1 GiB e 12 GiB liberando ~20 GiB para jogos/VMs/IA) +/bootrestrito (0077) - CPU & Memória:
amd_pstate=active,scx_lavd --autopilot(sem conflito comananicy-cpp), NTSync (ntsync+ Proton), ZRAMzstd40%, THPdefer+madvise+ shrinker, BBR TCP - Áudio: PipeWire low-latency (
quantum = 512,32..1024), WirePlumber BlueZ codecs, RTKit, limites PAM@audio,snd_hda_intel power_save=0 - GPU Intel Arc B570 (Battlemage G21, driver
xe):chaotic.mesa-git64-bit e 32-bit, VA-APIiHDzero-copy no MPV, VPL, Intel Compute Runtime,xe.enable_dsb=0 - IA Local:
llama.cppVulkan multi-modelo (presets.inisob demanda do HuggingFace) em127.0.0.1:8080, com acesso DRM (char-drm) e ICD Intel ANV isolado - Gaming & Streaming: Steam (Proton-GE + Proton-CachyOS), Gamescope, Gamemode, LatencyDevil, MangoHUD, AAGL, Sunshine (VA-API AV1/HEVC) e GPU Screen Recorder
☁️ VPS — omega
Serviços
- Disco declarativo via Disko (
/bootvfatumask=0077+/ext4noatime) + ZRAMzstd50% - Docker com IPv6 (
fd00:db8:1::/64) e storageoverlay2 - NetBird (overlay
100.104.0.0/16) - Serviços nativos & OCI: Traefik nativo (80/443 com ACME Let's Encrypt, gRPC h2c e TCP passthrough), Vaultwarden nativo (:8080), SearXNG nativo (:8888 + Valkey/Redis), Forgejo nativo (:3000 + MariaDB e Runner CI), Podman + OCI declarativo, e containers de apoio (Technitium DNS em
53enetbird-server) - Firewall nftables:
22/80/443públicos + portas de gerência e DNS restritas à interfacewt0
📦 Estrutura
/etc/nixos/
├── .sops.yaml # Regras de criação e chaves age do SOPS
├── flake.lock
├── flake.nix # GERADO — não edite; `nix run .#write-flake` regenera
├── secrets/ # Segredos criptografados (sops-nix)
│ └── omega.yaml # Segredos do omega (tokens, senhas)
└── modules/ # Padrão dendritic: todo .nix é módulo flake-parts auto-importado
│ # via import-tree (arquivos com prefixo `_` são ignorados).
├── flake/ # ⚙️ Infraestrutura do Flake
│ ├── inputs.nix # flake-file, inputs, systems, treefmt (nixfmt+deadnix) e devShell
│ └── hosts.nix # options.hosts + montagem de nixosConfigurations e Home Manager
├── common/ # 🧩 Base compartilhada (Alfa + omega)
│ ├── base.nix # Timezone, locale, pacotes base, journald, oomd
│ ├── caches.nix # Substituters e chaves Cachix por host
│ ├── nix.nix # Lix, nh, nix-ld, allowUnfree, paralelismo e rede do Nix
│ ├── security.nix # OpenSSH hardenado, Fail2ban (ignoreIP NetBird), sudo-rs
│ ├── services.nix # NetBird, nftables e Docker base
│ └── shell.nix # Fish, integração Bash->Fish, Starship (omega) e aliases
├── alfa/ # 🖥️ Workstation / Gaming / IA (NixOS + HM juntos por domínio)
│ ├── default.nix # Identidade do host Alfa, usuário `gui`, grupos e chaves SSH
│ ├── hardware/ # Kernel, Boot, Storage, GPU, Áudio, Periféricos e Tuning
│ │ ├── _hardware-configuration.nix
│ │ ├── boot.nix # Kernel CachyOS, Limine, Secure Boot e Memtest86+
│ │ ├── storage.nix # ZFS (ARC 1–12 GiB, autoScrub, trim), Sanoid e ZRAM 40%
│ │ ├── gpu.nix # Intel Arc B570 (xe, Mesa-git 64/32-bit, VA-API, VPL, Vulkan)
│ │ ├── audio.nix # PipeWire low-latency, Bluetooth, RTKit, PAM @audio, HDA
│ │ ├── peripherals.nix # OpenRGB, i2c, fwupd, Wake-on-LAN e udev (Attack Shark/Akko)
│ │ └── tuning.nix # AMD P-State, NTSync, Sysctl, THP, I/O udev e scx_lavd
│ ├── services/ # Serviços locais, Containers, Rede, Streaming e VMs
│ │ ├── ai.nix # llama.cpp server Vulkan multi-modelo (:8080)
│ │ ├── containers.nix # Docker em ZFS (zpool/docker), Distrobox, Flatpak, AppImage, ccache
│ │ ├── network.nix # NetworkManager, firewall (wt0), formatos regionais PT-BR, XKB e ProtonVPN
│ │ ├── streaming.nix # Sunshine (VA-API) e GPU Screen Recorder
│ │ └── virtualization.nix # Libvirtd / QEMU-KVM, Virt-Manager, Wine Staging e Winboat
│ ├── desktop/ # Seletor de Interface, Temas e Compositores
│ │ ├── default.nix # options.desktop + base Wayland (greeter, polkit, keyring, xwayland)
│ │ ├── theme.nix + theme/ # Stylix (system + HM), fontes Nerd/Noto, paletas e wallpaper
│ │ ├── noctalia.nix # Noctalia Shell (barra, dock, widgets, lockscreen, plugins)
│ │ ├── umbriel.nix # Compositor Umbriel (ativo)
│ │ ├── niri.nix # Compositor Niri
│ │ ├── hyprland.nix # Compositor Hyprland (Lua + UWSM)
│ │ ├── mango.nix # Compositor Mango
│ │ ├── kde.nix # KDE Plasma 6 + Karousel
│ │ ├── gnome.nix # Desktop GNOME
│ │ └── cosmic.nix # Desktop COSMIC
│ └── apps/ # Aplicativos e Ferramentas por Domínio (System + HM)
│ ├── cli.nix + btop/ + starship/ # Base HM, Git+Delta, Starship, Btop, Fzf, Eza, Zoxide, Bat, Lazygit
│ ├── dev.nix # Zed, Antigravity, OpenCode, LM Studio, Godot, Node/Bun/Python/GCC, LSPs
│ ├── dolphin.nix # Dolphin, KIO/GDrive/Fuse, Ark e Partition Manager
│ ├── gaming.nix # Steam, Gamescope, Gamemode, LatencyDevil, AAGL e Launchers
│ ├── kitty.nix + kitty/ # Terminal Kitty e atalhos
│ ├── mangohud.nix # MangoHud ordenado com cores Stylix + MangoJuice
│ ├── media.nix # MPV (VA-API zero-copy), VLC, Kdenlive, Loupe, OnlyOffice, Cava, Torrent
│ ├── nixcord.nix # Equibop / Nixcord + Telegram, Thunderbird e ProtonMail
│ └── zen.nix # Zen Browser + CSS Stylix
└── omega/ # ☁️ VPS ARM64 Headless
├── default.nix # Identidade do host omega, systemd-boot, ZRAM 50%, nix.optimise
├── _hardware-configuration.nix # Gerado pelo nixos-generate-config
├── _disk-config.nix # Disko (/boot vfat 0077 + / ext4 noatime)
├── firewall.nix # Portas públicas (22/80/443) + malha NetBird (wt0)
├── packages.nix # Utilitários CLI do servidor
├── self-host.nix # Docker IPv6 + Sysctl BBR/rede
├── sops.nix # sops-nix no omega (defaultSopsFile + chaves SSH)
└── services/ # Serviços do omega (nativos / podman)
├── forgejo.nix # Forgejo nativo (:3000) + MariaDB (:3306 socket), LFS, dump diário e Runner CI
├── podman.nix # Podman + virtualisation.oci-containers
├── searxng.nix # SearXNG nativo (:8888) + Valkey/Redis local
├── traefik.nix # Traefik nativo (80/443, ACME Let's Encrypt, gRPC h2c e TCP passthrough NetBird)
└── vaultwarden.nix # Vaultwarden nativo (:8080) com secrets SOPS + backup automatizado (SQLite + Dropbox)
🚀 Comandos Rápidos
# Validar antes de todo switch (padrão do repo)
nix flake check --no-build --all-systems
# Formatar (nixfmt + deadnix) — rode antes de commitar
nix fmt
# Lint sob demanda (deve retornar 0 avisos)
nix develop -c statix check .
# Após mexer em flake-file.inputs (modules/flake/inputs.nix), regenerar o flake:
nix run .#write-flake
# Atalho fish (faz o acima + atualiza o lock):
flakeadd
# Rebuild (Alfa) — nh gerencia sudo automaticamente
nh os switch
# Atalho fish:
upd
# Rebuild (omega) — a partir do Alfa via NetBird/SSH, ou local na VPS
nh os switch . -H omega
# Atualizar inputs
nix flake update
# Limpar gerações antigas (manter últimos 7 gens + 8 dias — padrão do nh)
nh clean --keep-since 8d --keep 7
# Diagnóstico rápido do kernel, CPU e schedulers (Alfa)
kerver
topmem
# Validar configs declarativos de sessão Wayland
noctalia config validate ~/.config/noctalia/config.toml
umbriel config validate -c ~/.config/umbriel/config.toml
Regras que valem lembrar
- Um dono por domínio (System + HM juntos): cada arquivo em
modules/alfa/{hardware,services,desktop,apps}/declara lado a ladohosts.Alfa.nixosehosts.Alfa.homedaquela feature — sem espalhar pacotes da mesma área em múltiplos arquivos. - CPU:
scx_lavd --autopilotcuida do agendamento interativo, enquanto ogamemodeeleva o governor paraperformancedurante o jogo (ananicy-cppfica desligado para não conflitar comscx_lavd). - Noctalia Shell: sobe automaticamente via
programs.noctalia.systemd.enable = true(noctalia.service), sem precisar deautostartduplicado nos compositores. - Acesso remoto: no
omega, gerência interna fica restrita à interfacewt0(NetBird), protegida noignoreIPdo Fail2ban.
📋 Inputs do Flake
flake.nixé gerado (nix run .#write-flake, viaflake-file). Os inputs são declarados emmodules/flake/inputs.nix.
| Input | Consumido em | Uso |
|---|---|---|
nixpkgs (unstable) |
modules/flake/hosts.nix |
Canal principal (segue chaotic) |
chaotic (nyx) |
modules/{alfa,omega}/default.nix |
Kernel CachyOS, ZFS CachyOS, Mesa-git, Proton-CachyOS |
home-manager |
modules/flake/hosts.nix |
Gestão declarativa do usuário (gui) |
disko |
modules/omega/default.nix |
Particionamento declarativo do omega |
flake-parts |
modules/flake/inputs.nix |
Orquestração modular do flake |
flake-file |
modules/flake/inputs.nix |
Geração declarativa do flake.nix |
import-tree |
modules/flake/inputs.nix |
Auto-import recursivo de modules/ |
treefmt-nix |
modules/flake/inputs.nix |
Formatação (nixfmt + deadnix) + devShell |
stylix |
modules/alfa/desktop/theme.nix |
Temas Base16, fontes, ícones e cursores |
noctalia (cachix) |
modules/alfa/desktop/noctalia.nix |
Shell/bar/dock/lockscreen Wayland |
noctalia-greeter |
modules/alfa/desktop/default.nix |
Display manager (greetd) |
umbriel (cachix) |
modules/alfa/desktop/umbriel.nix |
Compositor Wayland Umbriel |
niri |
modules/alfa/desktop/niri.nix |
Compositor Wayland Niri |
mangowm |
modules/alfa/desktop/mango.nix |
Compositor Wayland Mango |
aagl |
modules/alfa/apps/gaming.nix |
Anime Game Launchers |
latencydevil |
modules/alfa/apps/gaming.nix |
Wrapper de baixa latência para jogos |
optiscaler-client |
modules/alfa/apps/gaming.nix |
OptiScaler Client |
nixcord |
modules/alfa/apps/nixcord.nix |
Equibop / Discord com plugins declarativos |
zen-browser |
modules/alfa/apps/zen.nix |
Navegador Zen Browser |
antigravity-nix |
modules/alfa/apps/dev.nix |
Google Antigravity App, IDE e CLI (agy) |
Feito com 💜 e ❄️ NixOS