2024-12-01 18:28:35 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
2024-10-29 19:35:34 +00:00
|
|
|
let
|
|
|
|
# Add nixpkgs-unstable channel with the following command:
|
|
|
|
# nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable && nix-channel --update
|
2024-12-01 18:28:35 +00:00
|
|
|
# 09/15/24: Use nixpkgs-unstable for logseq, see https://github.com/NixOS/nixpkgs/pull/340427
|
2024-10-29 19:35:34 +00:00
|
|
|
unstable = import <nixpkgs-unstable> { config = config.nixpkgs.config; };
|
|
|
|
host_name = "litten";
|
|
|
|
host_fqdn = "${host_name}.brenise.dev";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./hardware-configuration.nix
|
|
|
|
];
|
2024-12-01 18:28:35 +00:00
|
|
|
|
|
|
|
nixpkgs.config = {
|
|
|
|
allowUnfreePredicate = pkg:
|
2024-10-29 19:35:34 +00:00
|
|
|
builtins.elem (lib.getName pkg) [
|
2024-12-01 18:28:35 +00:00
|
|
|
"obsidian"
|
2024-10-29 19:35:34 +00:00
|
|
|
"packer"
|
|
|
|
"vscode"
|
|
|
|
"terraform"
|
|
|
|
"zoom"
|
|
|
|
];
|
|
|
|
};
|
2024-12-05 17:15:42 +00:00
|
|
|
nixpkgs.overlays = [
|
|
|
|
(self: super: {
|
|
|
|
ansible = super.ansible.overrideAttrs (oldAttrs: {
|
|
|
|
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [ super.python312Packages.jmespath ];
|
|
|
|
}); # Add jmespath to ansible build inputs
|
|
|
|
})
|
|
|
|
];
|
2024-10-29 19:35:34 +00:00
|
|
|
|
|
|
|
boot = {
|
|
|
|
loader = {
|
|
|
|
systemd-boot.enable = true;
|
|
|
|
efi.canTouchEfiVariables = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
hardware = {
|
|
|
|
bluetooth.enable = true;
|
|
|
|
keyboard.qmk.enable = true;
|
|
|
|
|
2024-12-05 17:15:42 +00:00
|
|
|
graphics = { # https://wiki.nixos.org/wiki/Accelerated_Video_Playback
|
2024-10-29 19:35:34 +00:00
|
|
|
enable = true;
|
|
|
|
extraPackages = with pkgs; [
|
|
|
|
intel-media-driver
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
hostName = "${host_name}";
|
|
|
|
# networkmanager.enable = true;
|
|
|
|
firewall.enable = false;
|
|
|
|
interfaces = {
|
|
|
|
enp100s0.ipv4.addresses = [{
|
|
|
|
address = "192.168.1.35";
|
|
|
|
prefixLength = 24;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
defaultGateway = {
|
|
|
|
address = "192.168.1.1";
|
|
|
|
interface = "enp100s0";
|
|
|
|
};
|
|
|
|
# TODO https://nixos.wiki/wiki/Encrypted_DNS
|
|
|
|
nameservers = [ "1.1.1.1" "8.8.8.8" ];
|
|
|
|
extraHosts = ''
|
2024-12-01 18:28:35 +00:00
|
|
|
192.168.1.1 shinx.${host_fqdn}
|
2024-10-29 19:35:34 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
time.timeZone = "America/Los_Angeles";
|
|
|
|
|
|
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
console = {
|
|
|
|
font = "Lat2-Terminus16";
|
|
|
|
# keyMap = "us";
|
|
|
|
useXkbConfig = true; # use xkbOptions in tty.
|
|
|
|
};
|
|
|
|
|
|
|
|
users = {
|
|
|
|
groups.glance = {};
|
|
|
|
users = {
|
|
|
|
|
|
|
|
root = {
|
|
|
|
openssh.authorizedKeys.keyFiles = [
|
|
|
|
/etc/nixos/ssh/authorized_keys
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
blee = {
|
|
|
|
openssh.authorizedKeys.keyFiles = [
|
|
|
|
/etc/nixos/ssh/authorized_keys
|
|
|
|
];
|
|
|
|
isNormalUser = true;
|
|
|
|
extraGroups = [
|
|
|
|
"wheel"
|
2024-12-05 17:15:42 +00:00
|
|
|
"docker"
|
2024-10-29 19:35:34 +00:00
|
|
|
"glance"
|
|
|
|
];
|
|
|
|
packages = with pkgs; [
|
|
|
|
chromium
|
|
|
|
coreutils # base64
|
|
|
|
element-desktop
|
|
|
|
firefox
|
|
|
|
gimp
|
|
|
|
jellyfin-media-player
|
|
|
|
kate # kwrite
|
|
|
|
kdenlive
|
|
|
|
libsForQt5.kcalc
|
2024-12-01 18:28:35 +00:00
|
|
|
# unstable.logseq # warning: https://github.com/logseq/logseq/issues/10851#issuecomment-2402925912
|
2024-10-29 19:35:34 +00:00
|
|
|
moonlight-qt
|
|
|
|
obs-studio
|
|
|
|
obsidian
|
2024-12-01 18:28:35 +00:00
|
|
|
pavucontrol
|
|
|
|
# qbittorrent
|
2024-10-29 19:35:34 +00:00
|
|
|
rtorrent
|
|
|
|
spek # beat saber mapping
|
2024-12-01 18:28:35 +00:00
|
|
|
sq
|
2024-10-29 19:35:34 +00:00
|
|
|
synergy
|
|
|
|
tenacity
|
|
|
|
thunderbird
|
|
|
|
tor-browser
|
|
|
|
via
|
|
|
|
vlc
|
|
|
|
vscode
|
2024-12-01 18:28:35 +00:00
|
|
|
xcaddy # warning: awfuly hacky
|
2024-10-29 19:35:34 +00:00
|
|
|
yt-dlp
|
|
|
|
zoom-us
|
|
|
|
|
|
|
|
# Build vim huge with clipboard support
|
|
|
|
(vim_configurable.overrideAttrs (oldAttrs: {
|
|
|
|
features = "huge";
|
|
|
|
}))
|
|
|
|
|
|
|
|
awscli2
|
|
|
|
#aws-sam-cli # broken, fails to init. use pip install aws-sam-cli
|
|
|
|
packer
|
|
|
|
terraform
|
|
|
|
ansible
|
2024-12-05 17:15:42 +00:00
|
|
|
python311
|
2024-10-29 19:35:34 +00:00
|
|
|
python311Packages.pip
|
|
|
|
python311Packages.ipython
|
2024-12-05 17:15:42 +00:00
|
|
|
# python311Packages.jmespath # for Ansible playbooks with json_query (grafana, caddy)
|
2024-10-29 19:35:34 +00:00
|
|
|
libreoffice-qt
|
|
|
|
hunspell
|
|
|
|
hunspellDicts.uk_UA
|
|
|
|
hunspellDicts.th_TH
|
2024-12-01 18:28:35 +00:00
|
|
|
# postman # nope, auth is broken
|
2024-10-29 19:35:34 +00:00
|
|
|
nodejs_20
|
|
|
|
yarn
|
|
|
|
deno
|
2024-12-01 18:28:35 +00:00
|
|
|
nix-init
|
|
|
|
nix-tree
|
|
|
|
nurl
|
2024-10-29 19:35:34 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
glance = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = "glance";
|
|
|
|
home = "/var/lib/glance";
|
|
|
|
createHome = true;
|
|
|
|
description = "Glance service user";
|
|
|
|
# shell = pkgs.bash;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
systemPackages = with pkgs; [
|
|
|
|
# GPU tools
|
|
|
|
android-tools
|
|
|
|
arp-scan
|
|
|
|
cryptsetup
|
|
|
|
curl
|
|
|
|
difftastic
|
|
|
|
dig
|
|
|
|
dnscontrol
|
|
|
|
dnsutils
|
|
|
|
doas
|
|
|
|
exiftool
|
|
|
|
ffmpeg
|
|
|
|
file
|
|
|
|
fzf
|
|
|
|
git
|
|
|
|
go
|
|
|
|
htop
|
|
|
|
iftop
|
|
|
|
imagemagick
|
|
|
|
iperf
|
|
|
|
jq
|
|
|
|
lego
|
|
|
|
libressl
|
|
|
|
mediainfo
|
|
|
|
net-snmp # snmpwalk
|
|
|
|
netcat
|
|
|
|
nettools
|
|
|
|
parted
|
|
|
|
pass
|
|
|
|
pciutils # lspci
|
|
|
|
psmisc
|
|
|
|
qrencode
|
|
|
|
rsync
|
|
|
|
screen
|
|
|
|
tcpdump
|
|
|
|
tmux
|
|
|
|
tree
|
|
|
|
unzip
|
|
|
|
vim
|
|
|
|
vulkan-tools
|
|
|
|
wget
|
|
|
|
whois
|
|
|
|
wireguard-tools
|
|
|
|
zbar
|
|
|
|
zip
|
|
|
|
];
|
|
|
|
|
|
|
|
shellInit = ''
|
|
|
|
pheonix() {
|
|
|
|
systemctl restart "$1"
|
|
|
|
journalctl -fu "$1"
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
|
|
|
plasma5.excludePackages = with pkgs.libsForQt5; [
|
|
|
|
plasma-browser-integration
|
|
|
|
];
|
2024-12-01 18:28:35 +00:00
|
|
|
etc."gitconfig".text = ''
|
|
|
|
[init]
|
|
|
|
defaultBranch = main
|
|
|
|
'';
|
|
|
|
# vscode on Wayland
|
|
|
|
#sessionVariables.NIXOS_OZONE_WL = "1";
|
2024-10-29 19:35:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
programs = {
|
|
|
|
appimage = {
|
|
|
|
enable = true;
|
|
|
|
binfmt = true;
|
|
|
|
package = pkgs.appimage-run.override {
|
|
|
|
extraPkgs = pkgs: [
|
|
|
|
pkgs.libthai # lume
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-12-01 18:28:35 +00:00
|
|
|
# hyprland = {
|
|
|
|
# enable = true;
|
|
|
|
# xwayland.enable = true;
|
|
|
|
# };
|
|
|
|
|
2024-10-29 19:35:34 +00:00
|
|
|
fish.enable = true;
|
2024-12-05 17:15:42 +00:00
|
|
|
vim = {
|
|
|
|
enable = true;
|
|
|
|
defaultEditor = true;
|
|
|
|
};
|
2024-10-29 19:35:34 +00:00
|
|
|
bash = {
|
|
|
|
shellAliases = {
|
|
|
|
ll = "ls -lAF --classify --group-directories-first";
|
|
|
|
l = "ls -lF --classify --group-directories-first";
|
|
|
|
};
|
|
|
|
# https://nixos.wiki/wiki/Fish
|
|
|
|
interactiveShellInit = ''
|
|
|
|
if [[ $(${pkgs.procps}/bin/ps --no-header --pid=$PPID --format=comm) != "fish" && -z ''${BASH_EXECUTION_STRING} ]]
|
|
|
|
then
|
|
|
|
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=""
|
|
|
|
exec ${pkgs.fish}/bin/fish $LOGIN_OPTION
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
mtr.enable = true;
|
|
|
|
gnupg.agent = {
|
|
|
|
enable = true;
|
|
|
|
enableSSHSupport = true;
|
|
|
|
};
|
|
|
|
kdeconnect.enable = true;
|
|
|
|
chromium = {
|
|
|
|
enable = true;
|
|
|
|
extraOpts = {
|
|
|
|
"SpellcheckEnabled" = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
security = {
|
|
|
|
sudo.enable = false;
|
|
|
|
doas = {
|
|
|
|
enable = true;
|
|
|
|
extraRules = [
|
|
|
|
{
|
|
|
|
users = [ "blee" ];
|
|
|
|
persist = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2024-12-01 18:28:35 +00:00
|
|
|
pki.certificateFiles = [
|
|
|
|
"${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
|
|
|
|
# "/etc/ssl/certs/dotted-turbans.pem"
|
|
|
|
];
|
2024-10-29 19:35:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
|
|
|
|
|
|
|
openssh.enable = true;
|
|
|
|
udev.packages = [ pkgs.via ];
|
|
|
|
|
|
|
|
# https://discourse.nixos.org/t/bluetooth-a2dp-sink-not-showing-up-in-pulseaudio-on-nixos/32447/4?u=bleetube
|
|
|
|
pipewire = {
|
|
|
|
enable = true;
|
|
|
|
pulse.enable = true;
|
2024-12-01 18:28:35 +00:00
|
|
|
alsa.enable = true; # for tenacity
|
|
|
|
};
|
|
|
|
avahi = { # for resolving start9 hostname
|
|
|
|
enable = true;
|
|
|
|
nssmdns4 = true; # Enable NSS support for mDNS
|
2024-10-29 19:35:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
syncthing = {
|
|
|
|
enable = true;
|
|
|
|
user = "blee";
|
|
|
|
dataDir = "/home/blee/Documents";
|
|
|
|
};
|
|
|
|
journald.extraConfig = "MaxRetentionSec=30day";
|
|
|
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/blob/nixos-23.05/nixos/modules/services/monitoring/prometheus/exporters.nix
|
|
|
|
prometheus.exporters.node = {
|
|
|
|
enable = true;
|
|
|
|
port = 8030;
|
2024-12-01 18:28:35 +00:00
|
|
|
# openFirewall = true;
|
2024-10-29 19:35:34 +00:00
|
|
|
enabledCollectors = [
|
|
|
|
"cpu.info"
|
|
|
|
"interrupts"
|
|
|
|
"netstat"
|
|
|
|
"vmstat"
|
|
|
|
"systemd"
|
|
|
|
"tcpstat"
|
|
|
|
"processes"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
caddy = {
|
|
|
|
enable = true;
|
|
|
|
logFormat = "output discard";
|
|
|
|
extraConfig = let
|
|
|
|
tlsConfig = ''
|
|
|
|
tls {
|
|
|
|
dns namecheap {
|
|
|
|
api_key {env.NAMECHEAP_API_KEY}
|
|
|
|
user {env.NAMECHEAP_API_USER}
|
|
|
|
api_endpoint https://api.namecheap.com/xml.response
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
in ''
|
|
|
|
${host_fqdn} { # open-webui
|
|
|
|
${tlsConfig}
|
|
|
|
reverse_proxy http://127.0.0.1:8080
|
|
|
|
|
|
|
|
# handle /files/* {
|
|
|
|
# root /mnt/usb/
|
|
|
|
# file_server browse
|
|
|
|
# }
|
2024-12-01 18:28:35 +00:00
|
|
|
|
2024-10-29 19:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
${host_fqdn}:4430 { # node_exporter
|
|
|
|
${tlsConfig}
|
|
|
|
reverse_proxy http://127.0.0.1:8030
|
|
|
|
}
|
|
|
|
|
|
|
|
${host_fqdn}:4431 { # litellm
|
|
|
|
${tlsConfig}
|
|
|
|
reverse_proxy http://127.0.0.1:8031
|
|
|
|
}
|
|
|
|
|
|
|
|
${host_fqdn}:4432 { # glance
|
|
|
|
${tlsConfig}
|
|
|
|
reverse_proxy http://127.0.0.1:8032
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
displayManager = {
|
|
|
|
sddm.enable = true;
|
|
|
|
#defaultSession = "plasmawayland";
|
|
|
|
};
|
|
|
|
xserver = {
|
|
|
|
enable = true;
|
|
|
|
desktopManager.plasma5.enable = true;
|
|
|
|
};
|
2024-12-01 18:28:35 +00:00
|
|
|
|
2024-10-29 19:35:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd = {
|
2024-12-01 18:28:35 +00:00
|
|
|
services.caddy = {
|
|
|
|
serviceConfig = {
|
|
|
|
EnvironmentFile = "/var/src/secrets/namecheap";
|
|
|
|
ExecStart = [
|
|
|
|
"" # This empty string clears the existing ExecStart commands
|
|
|
|
"/opt/bin/caddy run --config /etc/caddy/caddy_config --adapter caddyfile"
|
|
|
|
];
|
|
|
|
ExecReload = [
|
|
|
|
"" # This empty string clears the existing ExecReload commands
|
|
|
|
"/opt/bin/caddy reload --config /etc/caddy/caddy_config --adapter caddyfile --force"
|
|
|
|
];
|
2024-10-29 19:35:34 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
2024-12-01 18:28:35 +00:00
|
|
|
services.glance = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
User = "glance";
|
|
|
|
Group = "glance";
|
|
|
|
WorkingDirectory = "/var/lib/glance";
|
|
|
|
# Environment = "LOG_LEVEL=debug"; # https://github.com/glanceapp/glance/issues/196
|
|
|
|
ExecStart = "${pkgs.glance}/bin/glance --config config.yaml";
|
|
|
|
};
|
|
|
|
};
|
2024-10-29 19:35:34 +00:00
|
|
|
# TODO: fix errors
|
2024-12-01 18:28:35 +00:00
|
|
|
# services.nightly-backups = {
|
2024-10-29 19:35:34 +00:00
|
|
|
# description = "Nightly Backup Service";
|
|
|
|
# wantedBy = [ "multi-user.target" ];
|
|
|
|
# after = [ "network.target" ];
|
|
|
|
# # enable = false; # testing
|
|
|
|
# serviceConfig = {
|
|
|
|
# User = "blee";
|
|
|
|
# Type = "oneshot";
|
|
|
|
# Environment = "NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels";
|
|
|
|
# WorkingDirectory = "/home/blee/ops/brenise.dev/scripts/backups";
|
|
|
|
# # batch.sh calls other shell scripts which leads to nix environment hell.
|
|
|
|
# # As a workaround, I think we could add multiple ExecStart lines for other backup scripts.
|
|
|
|
# # ExecStart = "${pkgs.bash}/bin/bash /home/blee/ops/brenise.dev/scripts/backups/batch.sh";
|
|
|
|
# ExecStart = "${pkgs.bash}/bin/bash /home/blee/ops/brenise.dev/scripts/backups/hosts/litten.brenise.dev.sh";
|
|
|
|
# # Path = [
|
|
|
|
# # "${pkgs.openssh}/bin"
|
|
|
|
# # "${pkgs.coreutils}/bin"
|
|
|
|
# # "${pkgs.gnugrep}/bin"
|
|
|
|
# # "${pkgs.gnused}/bin"
|
|
|
|
# # ];
|
|
|
|
# };
|
|
|
|
# };
|
|
|
|
|
2024-12-01 18:28:35 +00:00
|
|
|
# timers.nightly-backups = {
|
2024-10-29 19:35:34 +00:00
|
|
|
# wantedBy = [ "timers.target" ];
|
|
|
|
# partOf = [ "nightly-backups.service" ];
|
|
|
|
# timerConfig = {
|
|
|
|
# OnCalendar = "daily";
|
|
|
|
# nCalendar = "*-*-* 03:00:00";
|
|
|
|
# # Persistent = true;
|
|
|
|
# Unit = "nightly-backups.service";
|
|
|
|
# };
|
|
|
|
# };
|
|
|
|
|
2024-12-01 18:28:35 +00:00
|
|
|
services.ollama-webui = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
|
|
|
User = "blee";
|
|
|
|
WorkingDirectory = "/opt/open-webui";
|
|
|
|
Environment = "NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels";
|
|
|
|
# ExecStart = "${pkgs.nix}/bin/nix-shell";
|
|
|
|
};
|
|
|
|
script = "${pkgs.nix}/bin/nix-shell";
|
|
|
|
};
|
|
|
|
|
2024-10-29 19:35:34 +00:00
|
|
|
};
|
|
|
|
|
2024-12-05 17:15:42 +00:00
|
|
|
virtualisation.docker = {
|
|
|
|
enable = true;
|
|
|
|
rootless = {
|
|
|
|
enable = true;
|
|
|
|
setSocketVariable = true;
|
|
|
|
};
|
|
|
|
autoPrune = {
|
|
|
|
enable = true;
|
|
|
|
dates = "monthly";
|
|
|
|
};
|
|
|
|
};
|
2024-10-29 19:35:34 +00:00
|
|
|
|
|
|
|
system.stateVersion = "23.05";
|
|
|
|
}
|