feat: add new host and start modularizing system configuration

This commit is contained in:
Jay Looney 2025-06-16 13:54:38 -05:00
parent ebe58addaa
commit 4a8c953223
22 changed files with 1050 additions and 288 deletions

View file

@ -2,10 +2,22 @@
This is my primary homelab host/NAS, previously powered by TrueNAS Scale/k3s.
## Manual Actions
Even with fully declarative Nix/Nixpkgs/NixOS at the end of the day there are
still some actions that need to be taken manually.
- secrets configuration (both for SOPS and git-agecrypt semi-secrets)
- kanidm user management
- tailscale auth key
- jellyfin configuration via web-ui
## Semi-Secrets
`semi-secret-vars.nix` is following a pattern I discovered here:
https://github.com/nyawox/arcanum/blob/4629dfba1bc6d4dd2f4cf45724df81289230b61a/var/README.md
`semi-secret-vars.nix` is using [git-agecrypt](https://github.com/vlaci/git-agecrypt)
and following a pattern I discovered here:
- https://github.com/nyawox/arcanum/blob/4629dfba1bc6d4dd2f4cf45724df81289230b61a/var/README.md
- https://github.com/vlaci/git-agecrypt
Essentially there are some details I won't want exposed in the repository, but
I do want them available to all my nix modules. The main one being the domain.

View file

@ -1,130 +1,13 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
{ config, pkgs, ... }:
{
# Setup sops default secrets.
sops.defaultSopsFile = ./secrets/common.yaml;
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# TODO: Request 192.168.50.3 over DHCP
# Currently this is enforced at the router layer on a single interface.
# I'd dramatically prefer it to be a bond0 interface but w/e it is what it is.
networking.hostName = "lithium"; # Define your hostname.
networking.hostName = "lithium";
networking.domain = config.vars.domain;
# Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
# Set your time zone.
time.timeZone = "America/Chicago";
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Select internationalisation properties.
# i18n.defaultLocale = "en_US.UTF-8";
# console = {
# font = "Lat2-Terminus16";
# keyMap = "us";
# useXkbConfig = true; # use xkb.options in tty.
# };
# Enable the X11 windowing system.
#services.xserver.enable = true;
# Enable the GNOME Desktop Environment.
#services.xserver.displayManager.gdm.enable = true;
#services.xserver.desktopManager.gnome.enable = true;
# Configure keymap in X11
# services.xserver.xkb.layout = "us";
# services.xserver.xkb.options = "eurosign:e,caps:escape";
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound.
# services.pulseaudio.enable = true;
# OR
# services.pipewire = {
# enable = true;
# pulse.enable = true;
# };
# Enable touchpad support (enabled default in most desktopManager).
# services.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.jay = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user.
packages = with pkgs; [
tree
];
};
nixpkgs.config.allowUnfree = true;
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
};
# List packages installed in system profile.
# You can use https://search.nixos.org/ to find more packages (and options).
environment.systemPackages = with pkgs; [
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
git
zfs
# wget
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# system.copySystemConfiguration = true;
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "25.05"; # Did you read the comment?
programs.mosh.enable = true;
system.stateVersion = "25.05";
}

View file

@ -1,12 +1,16 @@
{ ... }:
{ inputs, ... }:
{
imports = [
../../modules/nixos/base.nix
inputs.sops-nix.nixosModules.sops
./hardware.nix
./configuration.nix
./semi-secret-vars.nix
./services/caddy.nix
./services/tailscale.nix
./services/kanidm.nix
./services/jellyfin.nix
./services/uptime-kuma.nix
./services/file-shares.nix
];
}

View file

@ -0,0 +1,78 @@
{ ... }:
{
# NOTE: We do need to guarantee this group exists.
# and manually provision users with `sudo smbpasswd -a $username`
users.groups.samba = {};
services.samba = {
enable = true;
openFirewall = true;
nmbd.enable = false; # NOTE: Disable NetBIOS responses.
# usershares.enable = true; # NOTE: Members of group "samba" can create usershares.
# NOTE: Refer to https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html
# to configure this service.
settings = {
global = {
workgroup = "WORKGROUP";
"hosts allow" = "192.168.50.";
"hosts deny" = "ALL";
"guest account" = "nobody";
"map to guest" = "bad user";
"log file" = "/var/log/samba/%m.log";
"max log size" = 1000;
"create mask" = "0660";
"directory mask" = "2770";
};
# NOTE: usershares enables users to create their own shares. This creates
# a share per-user.
homes = {
browseable = "no";
writable = "yes";
"read only" = "no";
"guest ok" = "no";
"valid users" = "%S";
path = "/tank/shares/personal/%S";
};
staging = {
comment = "Temp Upload Area";
path = "/tank/shares/staging";
browseable = "yes";
writable = "yes";
"guest ok" = "yes";
"force user" = "nobody";
"force group" = "nogroup";
"create mask" = "0666";
"directory mask" = "0777";
};
backups = {
comment = "Device Backups";
path = "/tank/shares/backups";
browseable = "no";
writable = "yes";
"valid users" = "@samba";
"guest ok" = "no";
};
## TODO: Time Machine Configuration
# http://wiki.nixos.org/wiki/Samba#Apple_Time_Machine
};
};
# NOTE: This is used to advertise shares to Windows hosts.
services.samba-wsdd = {
enable = true;
openFirewall = true;
};
#services.avahi = {
#enable = true;
#openFirewall = true;
#publish.enable = true;
#publish.userServices = true;
#};
}

View file

@ -0,0 +1,22 @@
{ config, pkgs, ... }:
#let
#hostName = config.networking.hostName;
#tailnetName = "tail79151.ts.net";
#svcDomain = "${hostName}.${tailnetName}";
#in
{
# NOTE: This does require a manual step of creating a tailscale account if
# you don't already have one, and generating an Auth Key:
# https://login.tailscale.com/admin/machines/new-linux
# After enabling this and generating an install script copy the authkey and
# run: `sudo tailscale up --auth-key=KEY`
# NOTE: Use Caddy to create and manage SSL Certs for Tailscale
#services.caddy.virtualHosts."${svcDomain}".extraConfig = ''
#reverse_proxy :<port>
#'';
services.tailscale = {
enable = true;
#permitCertUid = "caddy"; # Allow caddy to edit certs
};
}

View file

@ -1,147 +1,7 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{ ... }:
{
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "neon"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Enable networking
networking.hostName = "neon";
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "America/Chicago";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome.enable = true;
# Configure keymap in X11
services.xserver.xkb.layout = "us";
# Enable CUPS to print documents.
# services.printing.enable = true;
# Enable sound with pipewire.
# sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default,
# no need to redefine it in your config for now)
#media-session.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd.
users.users.jml = {
isNormalUser = true;
description = "Jay Looney";
extraGroups = [ "networkmanager" "wheel" ];
packages = with pkgs; [
firefox
];
};
# Enable automatic login for the user.
services.displayManager.autoLogin.enable = true;
services.displayManager.autoLogin.user = "jml";
# Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229
systemd.services."getty@tty1".enable = false;
systemd.services."autovt@tty1".enable = false;
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
# substituters = ["https://hyprland.cachix.org"];
# trusted-public-keys = ["hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="];
};
# Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
environment.systemPackages = with pkgs; [
home-manager
neovim
git
yubikey-personalization
kitty # hyprland default term
swww # wallpaper
xdg-desktop-portal-gtk
xdg-desktop-portal-hyprland
xwayland
];
programs.neovim.enable = true;
programs.neovim.defaultEditor = true;
environment.variables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
programs.hyprland = {
enable = true;
# following along with stackademic installing nixos with hyprland
xwayland.enable = true;
#xwayland.hidpi = true;
};
# Hint electron apps to use wayland
environment.sessionVariables = {
NIXOS_OZONE_WL = "1";
};
# screen sharing /w hyp
services.dbus.enable = true;
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment?
system.stateVersion = "23.05";
}

View file

@ -1,6 +1,13 @@
{ ... }:
{ inputs, ... }:
{
imports = [
../../modules/nixos/base.nix
../../modules/nixos/audio.nix
../../modules/nixos/desktop.nix
# https://github.com/NixOS/nixos-hardware/blob/master/README.md#using-nix-flakes-support
inputs.nixos-hardware.nixosModules.gpd-pocket-3
# override from nixos-hardware
({config, lib, ...}: { services.xserver.videoDrivers = lib.mkForce [ "modesetting" ]; })
./hardware-configuration.nix
./configuration.nix
];

View file

@ -0,0 +1,19 @@
{ config, lib, pkgs, ... }:
{
networking.hostName = "titanium";
networking.networkmanager.enable = true;
environment.systemPackages = with pkgs; [
sbctl # Secure-Boot
helix nil # nice for editing '.nix'
discord
signal-desktop
obs-studio
];
# Hardware Specific programs...
#programs.ryzen-monitor-ng.enable = true;
#programs.rog-control-center.enable = true;
services.openssh.enable = true;
services.tailscale.enable = true;
networking.firewall.trustedInterfaces = [ "tailscale0" ];
system.stateVersion = "25.05";
}

View file

@ -0,0 +1,12 @@
{ inputs, ... }:
{
imports = [
../../modules/nixos/base.nix
../../modules/nixos/audio.nix
../../modules/nixos/desktop.nix
../../modules/nixos/gaming.nix
inputs.nixos-hardware.nixosModules.asus-rog-strix-x570e
./hardware.nix
./configuration.nix
];
}

76
hosts/titanium/disko.nix Normal file
View file

@ -0,0 +1,76 @@
{ ... }:
{
# Based on:
# https://github.com/nix-community/disko/blob/master/example/luks-btrfs-subvolumes.nix
#
# Run with:
# `sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode destroy,format,mount /tmp/disk-config.nix`
disko.devices = {
disk = {
main-disk = {
type = "disk";
device = "/dev/disk/by-path/pci-0000:08:00.0-ata-2";
content = {
type = "gpt";
partitions = {
ESP = {
size = "512M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
mountOptions = [ "umask=0077" ];
};
};
luks = {
size = "100%"; # Full Disk Encryption
content = {
type = "luks";
name = "crypted";
# disable settings.keyFile if you want to use interactive password entry
# passwordFile = "/tmp/secret.key"; # Interactive
settings = {
allowDiscards = true;
#keyFile = "/tmp/secret.key";
};
#additionalKeyFiles = [ "/tmp/additionalSecret.key" ];
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # What?
subvolumes = {
"/root" = {
mountpoint = "/";
mountOptions = [
"compress=zstd"
"noatime"
];
};
"/home" = {
mountpoint = "/home";
mountOptions = [
"compress=zstd"
"noatime"
];
};
"/nix" = {
mountpoint = "/nix";
mountOptions = [
"compress=zstd"
"noatime"
];
};
"/swap" = {
mountpoint = "/.swapvol";
swap.swapfile.size = "16G";
};
};
};
};
};
};
};
};
};
};
}

View file

@ -0,0 +1,72 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/0b3de117-c34f-4cc6-81db-5b84ea46cd51";
fsType = "btrfs";
options = [ "subvol=root" ];
};
boot.initrd.luks.devices."crypted".device = "/dev/disk/by-uuid/0ccc4028-c27e-4259-ade9-a2b2081722cb";
fileSystems."/.swapvol" =
{ device = "/dev/disk/by-uuid/0b3de117-c34f-4cc6-81db-5b84ea46cd51";
fsType = "btrfs";
options = [ "subvol=swap" ];
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/219D-4579";
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};
fileSystems."/home" =
{ device = "/dev/disk/by-uuid/0b3de117-c34f-4cc6-81db-5b84ea46cd51";
fsType = "btrfs";
options = [ "subvol=home" ];
};
fileSystems."/nix" =
{ device = "/dev/disk/by-uuid/0b3de117-c34f-4cc6-81db-5b84ea46cd51";
fsType = "btrfs";
options = [ "subvol=nix" ];
};
swapDevices = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp4s0.useDHCP = lib.mkDefault true;
# networking.interfaces.enp5s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
# GPU Things
hardware.graphics.enable = true;
hardware.nvidia = {
# package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
open = true;
nvidiaSettings = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
};
}