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
};
}