NixOS-Configs/hosts/server/default.nix
2026-01-06 23:27:49 -06:00

251 lines
5.3 KiB
Nix

{
inputs,
outputs,
lib,
config,
pkgs,
...
}: let
my-python-packages = python-packages:
with python-packages; [
# pipx
distutils
docx2txt
numpy
pip
python-dateutil
requests
setuptools
];
python-with-my-packages = pkgs.python313.withPackages my-python-packages;
in {
nix = {
settings = {
experimental-features = ["nix-command" "flakes"];
warn-dirty = false;
auto-optimise-store = true;
trusted-users = ["root" "don"];
};
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 4d";
};
};
imports = [
../../home
../vars.nix
./systemd.nix
../systemd-primary.nix
# ./tailscale.nix
./upgrade-diff.nix
../../modules/beszel-agent.nix
];
# Enable networking
networking.networkmanager.enable = true;
networking.enableIPv6 = true;
networking.useDHCP = false;
# Set your time zone.
time = {
timeZone = "America/Chicago";
hardwareClockInLocalTime = false;
};
# Select internationalisation properties.
i18n = {
defaultLocale = "en_US.UTF-8";
inputMethod = {
enable = true;
type = "fcitx5";
fcitx5.addons = with pkgs; [fcitx5-mozc fcitx5-gtk];
};
};
# Bootloader.
boot = {
binfmt.emulatedSystems = ["aarch64-linux"];
kernelPackages = pkgs.linuxPackages_latest;
kernelParams = ["consoleblank=60"];
#loader = {
#systemd-boot = {
#enable = true;
#};
#efi = {
#canTouchEfiVariables = true;
#efiSysMountPoint = "/boot";
#};
#};
plymouth = {enable = true;};
kernel = {sysctl = {"vm.swappiness" = 10;};};
};
security = {
polkit = {enable = true;};
sudo.enable = false;
doas = {
enable = true;
extraRules = [
{
users = ["don"];
keepEnv = true;
noPass = true;
}
];
};
};
services = {
pcscd = {enable = true;};
beszel-agent = {enable = true;};
avahi = {
enable = true;
nssmdns4 = true;
};
printing = {enable = true;};
udisks2 = {enable = true;};
nscd = {enableNsncd = true;};
tailscale = {enable = true;};
locate = {
enable = true;
package = pkgs.mlocate;
};
openssh = {
enable = true;
settings = {
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
PermitRootLogin = "yes";
};
};
};
security.rtkit.enable = true;
users.users = {
root = {
initialPassword = "changeme";
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINd8AdVbQQ/Fmw+b9mI8EMYqIoRkwmSwAOtmlte3incL don@loki"
];
};
don = {
isNormalUser = true;
initialPassword = "changeme";
description = "Don Harper";
extraGroups = [
"disk"
"docker"
"lp"
"cdrom"
"mlocate"
"networkmanager"
"scanner"
"video"
"wheel"
];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINd8AdVbQQ/Fmw+b9mI8EMYqIoRkwmSwAOtmlte3incL don@loki"
];
};
};
# nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
python-with-my-packages
age
aspell
aspellDicts.en
base16-schemes
bash-completion
btop
colmena
dmidecode
docker-compose
git-crypt
gitFull
has
home-manager
hunspell
hunspellDicts.en_US
id3v2
isync
just
lazydocker
lsb-release
lsof
lsscsi
nix-bash-completions
nixfmt-classic
pkg-config
podman
poppler-utils
ruby
sshfs
sops
udiskie
];
programs = {
dconf = {enable = true;};
mtr = {enable = true;};
gnupg = {
agent = {
enable = true;
pinentryPackage = pkgs.pinentry-curses;
enableSSHSupport = true;
};
};
};
nixpkgs.overlays = [
(final: super: {
khal = super.khal.overridePythonAttrs (_: {doCheck = false;});
})
];
# Open ports in the firewall.
networking.firewall = {
enable = true;
trustedInterfaces = ["tailscale0"];
checkReversePath = "loose";
allowedUDPPorts = [config.services.tailscale.port];
allowedTCPPortRanges = [
{
from = 1714;
to = 1764;
}
];
allowedUDPPortRanges = [
{
from = 1714;
to = 1764;
}
];
allowedTCPPorts = [22];
};
# 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. It's perfectly fine and recommended to leavecatenate(variables, "bootdev", bootdev)
# 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.11"; # Did you read the comment?
programs.msmtp = {
enable = true;
accounts = {
default = {
auth = true;
tls = true;
port = 587;
from = "don@donharper.org";
host = "smtp.smtp2go.com";
user = "donharper.org";
passwordeval = "cat /home/don/.smtp_password.txt";
};
};
};
}