No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-08 00:04:13 -03:00
.agents pequenas melhorias 2026-10-24 18:27:14 -03:00
modules Update forgejo.nix 2026-11-08 00:02:33 -03:00
secrets feat(omega): migrar searxng, forgejo e traefik para nativos e habilitar podman 2026-11-07 20:29:29 -03:00
skills/system/run-workflow mudanças 2026-11-01 15:46:19 -03:00
.gitignore mexendo no sistema 2026-09-15 18:38:39 -03:00
.sops.yaml feat(omega): configurar sops-nix e migrar vaultwarden para servico nativo com backup dropbox 2026-11-07 19:02:24 -03:00
flake.lock Update flake.lock 2026-11-08 00:04:13 -03:00
flake.nix feat(omega): configurar sops-nix e migrar vaultwarden para servico nativo com backup dropbox 2026-11-07 19:02:24 -03:00
README.md feat(omega): migrar searxng, forgejo e traefik para nativos e habilitar podman 2026-11-07 20:29:29 -03:00

❄️ NixConfig

Configuração NixOS — Desktop Alfa + VPS omega

Desde 22/07/2025

nixpkgs segue nixpkgs-unstable (via chaotic/nyx) e o system.stateVersion está em 25.11 — o badge indica o canal, não a versão do SO.

NixOS Flakes License


🖥️ 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_cachyos em modules/alfa/hardware/boot.nix. Para a variante LTO basta trocar para linuxPackages_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 em modules/alfa/ ou modules/omega/ com mkDefault/mkForce explícito.

O nix.optimise só liga no omega (modules/omega/default.nix) porque o store dele é ext4 (noatime); no Alfa o store é CoW (ZFS com autoScrub e trim).


🎯 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 desktop em modules/alfa/desktop/default.nix (fonte única de verdade para system e home-manager; cada DE lê via config.desktop). Apenas a selecionada é ativada (sem dependências cruzadas no closure). Ativo atualmente: umbriel.

🛠️ Otimizações

  • Kernel & Storage: CachyOS + zfs_cachyos (autoScrub, trim, Sanoid em zpool/home, ZFS ARC limitado entre 1 GiB e 12 GiB liberando ~20 GiB para jogos/VMs/IA) + /boot restrito (0077)
  • CPU & Memória: amd_pstate=active, scx_lavd --autopilot (sem conflito com ananicy-cpp), NTSync (ntsync + Proton), ZRAM zstd 40%, THP defer+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-git 64-bit e 32-bit, VA-API iHD zero-copy no MPV, VPL, Intel Compute Runtime, xe.enable_dsb=0
  • IA Local: llama.cpp Vulkan multi-modelo (presets.ini sob demanda do HuggingFace) em 127.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 (/boot vfat umask=0077 + / ext4 noatime) + ZRAM zstd 50%
  • Docker com IPv6 (fd00:db8:1::/64) e storage overlay2
  • 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 53 e netbird-server)
  • Firewall nftables: 22/80/443 públicos + portas de gerência e DNS restritas à interface wt0

📦 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 lado hosts.Alfa.nixos e hosts.Alfa.home daquela feature — sem espalhar pacotes da mesma área em múltiplos arquivos.
  • CPU: scx_lavd --autopilot cuida do agendamento interativo, enquanto o gamemode eleva o governor para performance durante o jogo (ananicy-cpp fica desligado para não conflitar com scx_lavd).
  • Noctalia Shell: sobe automaticamente via programs.noctalia.systemd.enable = true (noctalia.service), sem precisar de autostart duplicado nos compositores.
  • Acesso remoto: no omega, gerência interna fica restrita à interface wt0 (NetBird), protegida no ignoreIP do Fail2ban.

📋 Inputs do Flake

flake.nix é gerado (nix run .#write-flake, via flake-file). Os inputs são declarados em modules/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