This commit is contained in:
William 2026-02-12 18:50:38 -03:00
parent 7309074f25
commit 8f98f7d420
45 changed files with 932 additions and 723 deletions

View file

@ -1,9 +1,11 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.ai = { inputs, pkgs, ... }: { flake.modules.nixos.ai =
{ inputs, pkgs, ... }:
{
environment.systemPackages = environment.systemPackages =
(with pkgs; [claude-desktop]) ++ (with pkgs; [ claude-desktop ])
(with inputs.nix-ai-tools.packages.${pkgs.system}; [ ++ (with inputs.nix-ai-tools.packages.${pkgs.system}; [
claude-code claude-code
claudebox claudebox
opencode opencode

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.bluetooth = { config, lib, pkgs, ... }: { flake.modules.nixos.bluetooth =
{
config,
lib,
pkgs,
...
}:
{
hardware.bluetooth.enable = true; hardware.bluetooth.enable = true;
}; };
} }

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.cli-btop = { config, lib, pkgs, ... }: { flake.modules.homeManager.cli-btop =
{
config,
lib,
pkgs,
...
}:
{
programs.btop = { programs.btop = {
enable = true; enable = true;
settings = { settings = {

View file

@ -1,6 +1,14 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.cli-comma = { config, lib, pkgs, inputs, ... }: { flake.modules.homeManager.cli-comma =
{
config,
lib,
pkgs,
inputs,
...
}:
{
imports = [ inputs.nix-index-database.homeModules.nix-index ]; imports = [ inputs.nix-index-database.homeModules.nix-index ];
programs.nix-index-database.comma.enable = true; programs.nix-index-database.comma.enable = true;

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.cli-direnv = { config, lib, pkgs, ... }: { flake.modules.homeManager.cli-direnv =
{
config,
lib,
pkgs,
...
}:
{
programs.direnv = { programs.direnv = {
enable = true; enable = true;
nix-direnv.enable = true; nix-direnv.enable = true;

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.cli-helix = { config, lib, pkgs, ... }: { flake.modules.homeManager.cli-helix =
{
config,
lib,
pkgs,
...
}:
{
home.sessionVariables = { home.sessionVariables = {
EDITOR = "hx"; EDITOR = "hx";
}; };

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.cli-base = { config, lib, pkgs, ... }: { flake.modules.homeManager.cli-base =
{
config,
lib,
pkgs,
...
}:
{
home = { home = {
packages = with pkgs; [ hm-cli ]; packages = with pkgs; [ hm-cli ];
sessionVariables = { sessionVariables = {

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.cli-starship = { config, lib, pkgs, ... }: { flake.modules.homeManager.cli-starship =
{
config,
lib,
pkgs,
...
}:
{
programs.starship = { programs.starship = {
enable = true; enable = true;
enableBashIntegration = true; enableBashIntegration = true;

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.cli-tmux = { config, lib, pkgs, ... }: { flake.modules.homeManager.cli-tmux =
{
config,
lib,
pkgs,
...
}:
{
programs.tmux = { programs.tmux = {
enable = true; enable = true;
clock24 = true; clock24 = true;

View file

@ -1,6 +1,8 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.common-boot = { pkgs, ... }: { flake.modules.nixos.common-boot =
{ pkgs, ... }:
{
boot = { boot = {
loader = { loader = {
timeout = 1; timeout = 1;

View file

@ -1,6 +1,8 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.common-console = { ... }: { flake.modules.nixos.common-console =
{ ... }:
{
console = { console = {
useXkbConfig = true; useXkbConfig = true;
earlySetup = true; earlySetup = true;

View file

@ -1,6 +1,8 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.common-firewall = { ... }: { flake.modules.nixos.common-firewall =
{ ... }:
{
networking = { networking = {
firewall.enable = true; firewall.enable = true;
nftables.enable = true; nftables.enable = true;

View file

@ -1,6 +1,8 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.common-locale = { ... }: { flake.modules.nixos.common-locale =
{ ... }:
{
time.timeZone = "America/Bahia"; time.timeZone = "America/Bahia";
i18n = { i18n = {

View file

@ -1,6 +1,8 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.common-nix = { inputs, ... }: { flake.modules.nixos.common-nix =
{ inputs, ... }:
{
imports = [ inputs.nixos-cli.nixosModules.nixos-cli ]; imports = [ inputs.nixos-cli.nixosModules.nixos-cli ];
nix = { nix = {

View file

@ -1,6 +1,8 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.common-openssh = { ... }: { flake.modules.nixos.common-openssh =
{ ... }:
{
services.openssh = { services.openssh = {
enable = true; enable = true;
settings.PermitRootLogin = "no"; settings.PermitRootLogin = "no";

View file

@ -1,6 +1,8 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.common-services = { ... }: { flake.modules.nixos.common-services =
{ ... }:
{
services = { services = {
dbus.implementation = "broker"; dbus.implementation = "broker";
irqbalance.enable = true; irqbalance.enable = true;

View file

@ -1,6 +1,8 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.common-tailscale = { ... }: { flake.modules.nixos.common-tailscale =
{ ... }:
{
services.tailscale = { services.tailscale = {
enable = true; enable = true;
extraUpFlags = [ "--operator=user" ]; extraUpFlags = [ "--operator=user" ];

View file

@ -54,12 +54,15 @@ let
sharedData = import ../data/services.nix; sharedData = import ../data/services.nix;
# Enrich services with host IP information # Enrich services with host IP information
enrichServices = hosts: services: enrichServices =
map (svc: hosts: services:
map (
svc:
let let
hostInfo = hosts.${svc.host} or {}; hostInfo = hosts.${svc.host} or { };
in in
svc // { svc
// {
lanIP = hostInfo.lanIP or null; lanIP = hostInfo.lanIP or null;
tailscaleIP = hostInfo.tailscaleIP or null; tailscaleIP = hostInfo.tailscaleIP or null;
} }
@ -70,19 +73,19 @@ in
options.flake = { options.flake = {
hosts = lib.mkOption { hosts = lib.mkOption {
type = lib.types.attrsOf hostType; type = lib.types.attrsOf hostType;
default = {}; default = { };
description = "Host definitions with IP addresses"; description = "Host definitions with IP addresses";
}; };
services = lib.mkOption { services = lib.mkOption {
type = lib.types.listOf serviceType; type = lib.types.listOf serviceType;
default = []; default = [ ];
description = "Service definitions with enriched host information"; description = "Service definitions with enriched host information";
}; };
lib = lib.mkOption { lib = lib.mkOption {
type = lib.types.attrsOf lib.types.raw; type = lib.types.attrsOf lib.types.raw;
default = {}; default = { };
description = "Utility functions for flake configuration"; description = "Utility functions for flake configuration";
}; };
}; };
@ -94,9 +97,11 @@ in
lib = { lib = {
# Nginx virtual host utilities # Nginx virtual host utilities
mkNginxVHosts = { domains }: mkNginxVHosts =
{ domains }:
let let
mkVHostConfig = domain: vhostConfig: mkVHostConfig =
domain: vhostConfig:
lib.recursiveUpdate { lib.recursiveUpdate {
useACMEHost = domain; useACMEHost = domain;
forceSSL = true; forceSSL = true;
@ -107,7 +112,8 @@ in
# Split DNS utilities for unbound # Split DNS utilities for unbound
# Generates unbound view config from a list of DNS entries # Generates unbound view config from a list of DNS entries
mkSplitDNS = entries: mkSplitDNS =
entries:
let let
tailscaleData = map (e: ''"${e.domain}. IN A ${e.tailscaleIP}"'') entries; tailscaleData = map (e: ''"${e.domain}. IN A ${e.tailscaleIP}"'') entries;
lanData = map (e: ''"${e.domain}. IN A ${e.lanIP}"'') entries; lanData = map (e: ''"${e.domain}. IN A ${e.lanIP}"'') entries;

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.desktop-boot = { config, lib, pkgs, ... }: { flake.modules.nixos.desktop-boot =
{
config,
lib,
pkgs,
...
}:
{
boot = { boot = {
plymouth.enable = true; plymouth.enable = true;
initrd.systemd.enable = true; initrd.systemd.enable = true;

View file

@ -4,7 +4,14 @@
}: }:
{ {
flake.modules = { flake.modules = {
nixos.desktop-desktop = { config, lib, pkgs, ... }: { nixos.desktop-desktop =
{
config,
lib,
pkgs,
...
}:
{
imports = [ imports = [
inputs.niri-flake.nixosModules.niri inputs.niri-flake.nixosModules.niri
inputs.nix-flatpak.nixosModules.nix-flatpak inputs.nix-flatpak.nixosModules.nix-flatpak
@ -160,7 +167,15 @@
}; };
}; };
homeManager.desktop-desktop = { config, lib, pkgs, inputs, ... }: { homeManager.desktop-desktop =
{
config,
lib,
pkgs,
inputs,
...
}:
{
imports = [ inputs.vicinae.homeManagerModules.default ]; imports = [ inputs.vicinae.homeManagerModules.default ];
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;

View file

@ -1,6 +1,14 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.desktop-niri = { config, lib, pkgs, inputs, hostname ? null, ... }: flake.modules.homeManager.desktop-niri =
{
config,
lib,
pkgs,
inputs,
hostname ? null,
...
}:
let let
isRotterdam = hostname == "rotterdam"; isRotterdam = hostname == "rotterdam";
in in

View file

@ -1,6 +1,13 @@
{ inputs, ... }: { inputs, ... }:
{ {
flake.modules.nixos.desktop-nix = { config, lib, pkgs, ... }: { flake.modules.nixos.desktop-nix =
{
config,
lib,
pkgs,
...
}:
{
environment.etc."channels/nixpkgs".source = inputs.nixpkgs.outPath; environment.etc."channels/nixpkgs".source = inputs.nixpkgs.outPath;
nix = { nix = {

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.desktop-services = { config, lib, pkgs, ... }: { flake.modules.nixos.desktop-services =
{
config,
lib,
pkgs,
...
}:
{
services = { services = {
printing.enable = true; printing.enable = true;
udev.packages = with pkgs; [ yubikey-personalization ]; udev.packages = with pkgs; [ yubikey-personalization ];

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.dev = { config, lib, pkgs, ... }: { flake.modules.nixos.dev =
{
config,
lib,
pkgs,
...
}:
{
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
android-tools android-tools
bat bat

View file

@ -3,7 +3,8 @@
{ inputs, ... }: { inputs, ... }:
{ {
# Base module with options (for external flakes or direct use) # Base module with options (for external flakes or direct use)
flake.modules.nixos.ephemeral = { lib, config, ... }: flake.modules.nixos.ephemeral =
{ lib, config, ... }:
let let
cfg = config.ephemeral; cfg = config.ephemeral;
in in
@ -89,18 +90,19 @@
# Factory function that generates configured modules # Factory function that generates configured modules
flake.factory.ephemeral = flake.factory.ephemeral =
{ rootDevice {
, rootSubvolume ? "@root" rootDevice,
, retentionDays ? 30 rootSubvolume ? "@root",
, persistentStoragePath ? "/persistent" retentionDays ? 30,
, persistentFiles ? [ persistentStoragePath ? "/persistent",
persistentFiles ? [
"/etc/machine-id" "/etc/machine-id"
"/etc/ssh/ssh_host_ed25519_key" "/etc/ssh/ssh_host_ed25519_key"
"/etc/ssh/ssh_host_ed25519_key.pub" "/etc/ssh/ssh_host_ed25519_key.pub"
"/etc/ssh/ssh_host_rsa_key" "/etc/ssh/ssh_host_rsa_key"
"/etc/ssh/ssh_host_rsa_key.pub" "/etc/ssh/ssh_host_rsa_key.pub"
] ],
, persistentDirectories ? [ persistentDirectories ? [
"/etc/NetworkManager/system-connections" "/etc/NetworkManager/system-connections"
"/etc/nixos" "/etc/nixos"
"/var/lib/bluetooth" "/var/lib/bluetooth"
@ -111,9 +113,10 @@
"/var/lib/systemd/timers" "/var/lib/systemd/timers"
"/var/lib/tailscale" "/var/lib/tailscale"
"/var/log" "/var/log"
] ],
}: }:
{ ... }: { { ... }:
{
imports = [ imports = [
inputs.impermanence.nixosModules.impermanence inputs.impermanence.nixosModules.impermanence
inputs.self.modules.nixos.ephemeral inputs.self.modules.nixos.ephemeral

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.fwupd = { config, lib, pkgs, ... }: { flake.modules.nixos.fwupd =
{
config,
lib,
pkgs,
...
}:
{
services.fwupd.enable = true; services.fwupd.enable = true;
}; };
} }

View file

@ -1,7 +1,9 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.gaming-flatpak = { pkgs, ... }: { flake.modules.nixos.gaming-flatpak =
{ pkgs, ... }:
{
services.flatpak.packages = [ services.flatpak.packages = [
"com.github.k4zmu2a.spacecadetpinball" "com.github.k4zmu2a.spacecadetpinball"
"com.steamgriddb.SGDBoop" "com.steamgriddb.SGDBoop"

View file

@ -1,7 +1,9 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.gaming-hardware = { ... }: { flake.modules.nixos.gaming-hardware =
{ ... }:
{
hardware = { hardware = {
xpadneo.enable = true; xpadneo.enable = true;
steam-hardware.enable = true; # Allow steam client to manage controllers steam-hardware.enable = true; # Allow steam client to manage controllers

View file

@ -1,7 +1,9 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.gaming-launchers = { pkgs, ... }: { flake.modules.nixos.gaming-launchers =
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
clonehero clonehero
heroic heroic

View file

@ -2,13 +2,17 @@
{ {
flake.modules = { flake.modules = {
nixos.gaming-mangohud = { pkgs, ... }: { nixos.gaming-mangohud =
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
mangohud mangohud
]; ];
}; };
homeManager.gaming-mangohud = { config, ... }: { homeManager.gaming-mangohud =
{ config, ... }:
{
programs.mangohud = { programs.mangohud = {
enable = true; enable = true;
enableSessionWide = true; enableSessionWide = true;

View file

@ -1,7 +1,9 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.gaming-steam = { pkgs, ... }: { flake.modules.nixos.gaming-steam =
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
steam-run steam-run
]; ];

View file

@ -34,8 +34,7 @@ in
# LAN-only DNS records # LAN-only DNS records
local-zone = ''"baduhai.dev." transparent''; local-zone = ''"baduhai.dev." transparent'';
local-data = map (e: ''"${e.domain}. IN A ${e.lanIP}"'') local-data = map (e: ''"${e.domain}. IN A ${e.lanIP}"'') (lib.filter (e: e.lanIP != null) services);
(lib.filter (e: e.lanIP != null) services);
}; };
forward-zone = [ forward-zone = [

View file

@ -9,9 +9,7 @@ let
services = inputs.self.services; services = inputs.self.services;
# Get all unique domains from shared services on trantor (host = "trantor") # Get all unique domains from shared services on trantor (host = "trantor")
localDomains = lib.unique ( localDomains = lib.unique (map (s: s.domain) (lib.filter (s: s.host == "trantor") services));
map (s: s.domain) (lib.filter (s: s.host == "trantor") services)
);
# Generate ACME cert configs for all local domains # Generate ACME cert configs for all local domains
acmeCerts = lib.genAttrs localDomains (domain: { acmeCerts = lib.genAttrs localDomains (domain: {

View file

@ -1,4 +1,5 @@
{ inputs, self, ... }: { inputs, self, ... }:
{ {
flake.nixosConfigurations.alexandria = inputs.nixpkgs-stable.lib.nixosSystem { flake.nixosConfigurations.alexandria = inputs.nixpkgs-stable.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.libvirtd = { config, lib, pkgs, ... }: { flake.modules.nixos.libvirtd =
{
config,
lib,
pkgs,
...
}:
{
virtualisation = { virtualisation = {
libvirtd.enable = true; libvirtd.enable = true;
spiceUSBRedirection.enable = true; spiceUSBRedirection.enable = true;

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.nixos.networkmanager = { config, lib, pkgs, ... }: { flake.modules.nixos.networkmanager =
{
config,
lib,
pkgs,
...
}:
{
networking.networkmanager = { networking.networkmanager = {
enable = true; enable = true;
wifi.backend = "iwd"; wifi.backend = "iwd";

View file

@ -1,7 +1,14 @@
# aspects/server/boot.nix # aspects/server/boot.nix
{ ... }: { ... }:
{ {
flake.modules.nixos.server-boot = { config, lib, pkgs, ... }: { flake.modules.nixos.server-boot =
{
config,
lib,
pkgs,
...
}:
{
boot.kernelPackages = pkgs.linuxPackages_hardened; boot.kernelPackages = pkgs.linuxPackages_hardened;
}; };
} }

View file

@ -1,7 +1,14 @@
# aspects/server/nix.nix # aspects/server/nix.nix
{ inputs, ... }: { inputs, ... }:
{ {
flake.modules.nixos.server-nix = { config, lib, pkgs, ... }: { flake.modules.nixos.server-nix =
{
config,
lib,
pkgs,
...
}:
{
environment.etc."channels/nixpkgs".source = inputs.nixpkgs-stable.outPath; environment.etc."channels/nixpkgs".source = inputs.nixpkgs-stable.outPath;
nix = { nix = {

View file

@ -1,7 +1,14 @@
# aspects/server/tailscale.nix # aspects/server/tailscale.nix
{ ... }: { ... }:
{ {
flake.modules.nixos.server-tailscale = { config, lib, pkgs, ... }: { flake.modules.nixos.server-tailscale =
{
config,
lib,
pkgs,
...
}:
{
services.tailscale = { services.tailscale = {
extraSetFlags = [ "--advertise-exit-node" ]; extraSetFlags = [ "--advertise-exit-node" ];
useRoutingFeatures = "server"; useRoutingFeatures = "server";

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.shell-bash = { config, lib, pkgs, ... }: { flake.modules.homeManager.shell-bash =
{
config,
lib,
pkgs,
...
}:
{
programs.bash = { programs.bash = {
enable = true; enable = true;
historyFile = "~/.cache/bash_history"; historyFile = "~/.cache/bash_history";

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
flake.modules.homeManager.shell-fish = { config, lib, pkgs, ... }: { flake.modules.homeManager.shell-fish =
{
config,
lib,
pkgs,
...
}:
{
programs.fish = { programs.fish = {
enable = true; enable = true;
interactiveShellInit = '' interactiveShellInit = ''

View file

@ -18,7 +18,8 @@
}; };
src = src =
srcs.${pkgs.stdenv.hostPlatform.system} or (throw "Unsupported system: ${pkgs.stdenv.hostPlatform.system}"); srcs.${pkgs.stdenv.hostPlatform.system}
or (throw "Unsupported system: ${pkgs.stdenv.hostPlatform.system}");
claudeNativeStub = '' claudeNativeStub = ''
// Stub implementation of claude-native using KeyboardKey enum values // Stub implementation of claude-native using KeyboardKey enum values

View file

@ -4,19 +4,20 @@ let
packageDir = builtins.readDir ./.; packageDir = builtins.readDir ./.;
# Filter to .nix files, excluding overlays.nix # Filter to .nix files, excluding overlays.nix
isPackageFile = name: isPackageFile = name: name != "overlays.nix" && builtins.match ".*\\.nix$" name != null;
name != "overlays.nix" && builtins.match ".*\\.nix$" name != null;
# Extract package name from filename (e.g., "foo-bar.nix" -> "foo-bar") # Extract package name from filename (e.g., "foo-bar.nix" -> "foo-bar")
toPackageName = filename: toPackageName = filename: builtins.head (builtins.match "(.+)\\.nix$" filename);
builtins.head (builtins.match "(.+)\\.nix$" filename);
packageNames = map toPackageName (builtins.filter isPackageFile (builtins.attrNames packageDir)); packageNames = map toPackageName (builtins.filter isPackageFile (builtins.attrNames packageDir));
in in
{ {
flake.overlays.default = final: prev: flake.overlays.default =
builtins.listToAttrs (map (name: { final: prev:
builtins.listToAttrs (
map (name: {
inherit name; inherit name;
value = inputs.self.packages.${final.system}.${name}; value = inputs.self.packages.${final.system}.${name};
}) packageNames); }) packageNames
);
} }

View file

@ -8,9 +8,12 @@
terranix.terranixConfigurations.cloudflare-kernelpanicspace = { terranix.terranixConfigurations.cloudflare-kernelpanicspace = {
terraformWrapper.package = pkgs.opentofu; terraformWrapper.package = pkgs.opentofu;
modules = [ modules = [
({ config, ... }: { (
{ config, ... }:
{
# Terraform config goes here # Terraform config goes here
}) }
)
]; ];
}; };
}; };

View file

@ -8,9 +8,12 @@
terranix.terranixConfigurations.oci-terminus = { terranix.terranixConfigurations.oci-terminus = {
terraformWrapper.package = pkgs.opentofu; terraformWrapper.package = pkgs.opentofu;
modules = [ modules = [
({ config, ... }: { (
{ config, ... }:
{
# Terraform config goes here # Terraform config goes here
}) }
)
]; ];
}; };
}; };