+/config
my dotfiles and nix configuration
git clone https://git.julia.blue/+/config
8dbea4b
main
1{ pkgs , config , lib , ...} :let 2= "juliaryan3.14@gmail.com" ; 3in { 4networking . firewall = { 5allowedTCPPorts = [ 622 28 # ssh 780 443 # http(s) 82283 # immich 922000 # syncthing 108080 8443 # testing 118123 21063 # home-assistant 125580 # matter server 13] ++ lib . lists . range 9000 9020 # testing 14++ lib . lists . range 1714 1764 ; # kde connect 15allowedUDPPorts = [ 165353 # mdns 1722000 21027 # syncthing + discovery 18]; 19}; 20 21age . secrets = { 22porkbun-api . file = ../../secrets/porkbun-api.age ; 23porkbun-secret . file = ../../secrets/porkbun-secret.age ; 24password = { 25file = ../../secrets/cortana-service-password.age ; 26group = "grafana" ; mode = "660" ; 27}; 28caddy-env . file = ../../secrets/caddy.age ; 29}; 30 31environment . systemPackages = with pkgs ; [ 32caddy 33prometheus . cli 34]; 35 36services = let home-config = config . home-manager . users . julia ; in { 37caddy = { enable = true ; 38configFile = home-config . lib . file . mkOutOfStoreSymlink 39( home-config . home . sessionVariables . CONF_DIR + "/machines/cortana/Caddyfile" ); 40environmentFile = config . age . secrets . caddy-env . path ; 41# TODO: ipban or ratelimit? 42package = pkgs . caddy . withPlugins { plugins = [ 43"github.com/mholt/caddy-l4@v0.1.2" 44]; hash = "sha256-orq1LkXp8KeBLsp1eoRQ+dHGeM9t+R47Be58s0/irWI=" ; }; 45}; 46 47openssh = { enable = true ; 48ports = [ 28 ]; 49settings . PasswordAuthentication = false ; 50# TODO: watch /run/utmp and export to prometheus, or just read ssh log? 51}; 52 53endlessh-go = { enable = true ; 54port = 22 ; 55prometheus = { enable = true ; port = 9100 ; }; 56extraOptions = [ "-alsologtostderr" "-geoip_supplier" "ip-api" ]; 57# TODO: use maxmind csv for offline geoip (just download it manually) 58}; 59 60grafana = { enable = true ; 61settings = { 62server = { 63http_addr = "127.0.0.1" ; 64http_port = 9001 ; 65domain = "stats.pineapple.computer" ; 66}; 67security = { 68admin_email = "julia" ; 69admin_password = "$__file{ ${ config . age . secrets . password . path } }" ; 70secret_key = "SW2YcwTIb9zpOOhoPsMm" ; 71}; 72}; 73}; 74 75prometheus = { enable = true ; 76exporters . node = { 77enable = true ; 78enabledCollectors = [ "systemd" ]; 79port = 9101 ; 80}; 81scrapeConfigs = [{ 82job_name = "prometheus" ; 83static_configs = [{ targets = [ 84"localhost:2019" # caddy 85"localhost:9100" # endlessh 86"localhost:9101" # node 87"localhost:9003" # syncthing 88"localhost:9006" # harmonia 89# TODO: atuin 90# TODO: btrfs if it's not in node 91# TODO: home assistant 92]; }]; 93}]; 94}; 95 96atuin = { enable = true ; 97port = 9002 ; 98openRegistration = true ; # TODO: how to add my user statically? 99}; 100 101syncthing = { enable = true ; 102guiAddress = "127.0.0.1:9003" ; 103dataDir = "/syncthing" ; 104overrideDevices = true ; overrideFolders = true ; 105settings . options . localAnnounceEnabled = true ; 106settings = { 107devices = { 108HAL . id = "ON6QDIA-Q76YZPP-2QDT5KI-DOJVPXS-6757LVB-P2FKJAS-LOMDKIW-JT36XQ6" ; 109WOPR . id = "R6XKQSK-3XE7J2H-LSELK56-HVO6PTF-5PX2HZP-775JTZO-ETP2BR3-5QZ6YAF" ; 110dragon . id = "6TN3KGX-JU2KQEA-B6VKVCK-AJFAWQG-W2CLE5Q-2WYDPEN-YV3YKXU-HJV6UQL" ; 111}; 112folders = ( builtins . mapAttrs ( n :d :{ path = "/syncthing/ ${ n } " ; devices = d ; }) { 113notes = [ "HAL" "WOPR" "dragon" ]; 114music = [ "HAL" "WOPR" "dragon" ]; 115recipes = [ "HAL" "WOPR" "dragon" ]; 116torrents = [ "HAL" "WOPR" ]; 117screenshots = [ "HAL" "WOPR" ]; 118}); 119gui . insecureSkipHostcheck = true ; # expose web dashboard 120}; 121}; 122 123pgadmin = { # enable = true; 124port = 9004 ; 125initialEmail = ; 126initialPasswordFile = config . age . secrets . password . path ; 127# TODO: disable admin password once http auth works 128}; 129 130chhoto-url = { # enable = true; 131settings = { 132site_url = "https://l.julia.blue" ; 133port = 9005 ; 134try_longer_slugs = true ; 135public_mode = true ; 136}; 137}; 138 139# TODO: hook up grafana dashboard from the repo 140harmonia . cache = { enable = true ; settings . bind = "[::]:9006" ; }; 141 142immich = { enable = true ; 143# TODO: figure out how i'm gonna setup uploads, do initial immich-go takeout batch, 144# and configure public-proxy 145port = 9007 ; 146mediaLocation = "/photos" ; 147accelerationDevices = [ "/dev/dri/renderD128" ]; 148}; 149 150home-assistant = { enable = true ; 151extraPackages = python3packages :with python3packages ; [ gtts zlib-ng isal ]; 152config . default_config = {}; 153}; 154matterjs-server . enable = true ; 155matterjs-server . listenAddress = "::" ; 156 157sorcery = { enable = true ; 158name = "git.julia.blue" ; 159url_base = "https://git.julia.blue" ; 160repositories = "/git" ; 161keys = let c = config . users . users ; in 162c . julia . openssh . authorizedKeys . keys ++ c . rahul . openssh . authorizedKeys . keys ; 163}; 164 165# TODO: vaultwarden 166 167qbittorrent = { enable = true ; webuiPort = 9008 ; }; 168 169ntfy-sh = { enable = true ; 170settings = { listen-http = ":9009" ; base-url = "https://notif.julia.blue" ; }; 171}; 172 173porkbun-ddns = { enable = true ; 174secret-key = config . age . secrets . porkbun-secret . path ; 175api-key = config . age . secrets . porkbun-api . path ; 176ipv6 = true ; 177domains = [ "pineapple.computer" "julia.blue" ]; 178}; 179}; 180 181systemd . services = { 182chhoto-url . environment = { 183slug_style = lib . mkForce "UNICODE" ; 184slug_length = lib . mkForce "2" ; 185CHHOTO_SQLITE_USE_WAL_MODE = "True" ; 186}; 187 188rahul-gists = { 189description = "Grab rahuls gists (until he makes a blog)" ; 190startAt = "0 0 */2 * *" ; # every 2 days 191path = with pkgs ; [ bash gh jq sd ]; 192script = '' 193~/.local/bin/gist-rss \ 194rrbutani rahul https://rahul.red > /website/feeds/rahul; 195'' ; 196serviceConfig = { User = "julia" ; Group = "users" ; }; 197}; 198 199rsspls = { 200description = "Extract rss feeds from web pages" ; 201startAt = "00,12:00" ; # twice a day 202serviceConfig = { 203ExecStart = " ${ lib . getExe pkgs . rsspls } -o /website/feeds" ; 204User = "julia" ; Group = "users" ; 205}; 206}; 207 208rssfetch = let 209blogs = builtins . toFile "blogs.json" ( builtins . toJSON ( import ./blogs.nix )); 210in { 211description = "Update https://julia.blue/read" ; 212startAt = "01,13:00" ; # twice a day 213path = with pkgs ; [ rssfetch jq zstd gzip ]; 214script = let 215out = "/website/posts.json" ; 216blogs_out = "/website/blogs.json" ; 217in '' 218cp ${ blogs } ${ blogs_out } 219rssfetch <(jq '.[]' ${ blogs } -c) | 220jq -sc '. |= sort_by(.date) | reverse' > ${ out } 221zstd ${ blogs } -f -10 -o ${ blogs_out } .zst 222zstd ${ out } -f -10 223gzip -c ${ blogs } > ${ blogs_out } .gz 224gzip -c ${ out } > ${ out } .gz 225'' ; 226}; 227}; 228 229# caddy needs to read files in /home, /syncthing, and /git 230systemd . services = { 231caddy . serviceConfig . ProtectHome = lib . mkForce false ; 232immich-server . serviceConfig . UMask = lib . mkForce "0027" ; 233}; 234users . users = { 235caddy . extraGroups = [ "users" "syncthing" "git" ]; 236syncthing . homeMode = "750" ; 237qbittorrent . extraGroups = [ "users" "syncthing" ]; 238julia = { 239homeMode = "750" ; 240extraGroups = [ "syncthing" "caddy" "immich" "git" "postgres" "minecraft" ]; 241}; 242}; 243}