diff options
| author | Kleidi Bujari <mail@4kb.net> | 2026-10-24 22:52:35 -0700 |
|---|---|---|
| committer | Kleidi Bujari <mail@4kb.net> | 2026-10-24 22:59:09 -0700 |
| commit | 48c8a4145c5a73874797a6de3f05ce584b1d1798 (patch) | |
| tree | bd4c627e8c8944fb7082b7a9982e8d3677c2a2c4 /modules/xnet | |
| parent | 1a181be93f37a94b347b2f5f97a1fef57e11cf89 (diff) | |
| parent | 27db59cac4f3c3e7a1e4187a5f56d4ec61895c5a (diff) | |
| download | depot-48c8a4145c5a73874797a6de3f05ce584b1d1798.tar.gz depot-48c8a4145c5a73874797a6de3f05ce584b1d1798.tar.bz2 depot-48c8a4145c5a73874797a6de3f05ce584b1d1798.zip | |
Diffstat (limited to 'modules/xnet')
| -rw-r--r-- | modules/xnet/default.nix | 18 | ||||
| -rw-r--r-- | modules/xnet/disk.nix | 34 | ||||
| -rw-r--r-- | modules/xnet/gitserver/default.nix | 7 | ||||
| -rw-r--r-- | modules/xnet/gitserver/gitweb.nix | 29 | ||||
| -rw-r--r-- | modules/xnet/monitoring/default.nix | 37 | ||||
| -rw-r--r-- | modules/xnet/monitoring/grafana.nix | 33 | ||||
| -rw-r--r-- | modules/xnet/nginx.nix | 5 | ||||
| -rw-r--r-- | modules/xnet/persist.nix | 59 |
8 files changed, 141 insertions, 81 deletions
diff --git a/modules/xnet/default.nix b/modules/xnet/default.nix index 28edf60..020accb 100644 --- a/modules/xnet/default.nix +++ b/modules/xnet/default.nix @@ -2,8 +2,6 @@ pkgs, lib, config, - flake, - inputs, ... }: let @@ -47,14 +45,15 @@ in time.timeZone = mkDefault "US/Pacific"; nix = { - nixPath = mkForce [ "nixpkgs=${inputs.nixpkgs}" ]; settings = { auto-optimise-store = true; + nix-path = mkForce [ "nixpkgs=${pkgs.path}" ]; experimental-features = [ "nix-command" "flakes" "pipe-operators" ]; + warn-dirty = false; # timeout fast from binary cache @@ -64,10 +63,7 @@ in automatic = true; options = mkDefault "--delete-older-than 30d"; }; - registry = { - nixpkgs.flake = inputs.nixpkgs; - depot.flake = flake; - }; + registry.nixpkgs.flake.outPath = pkgs.path; }; documentation = { @@ -104,6 +100,9 @@ in "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFmWInQNT6EoU1NtUYzTs5jtpfbO/m6yvCckOiEGjvDc"; }; extraConfig = '' + Host * + SetEnv TERM=xterm-256color + Host github HostName github.com User git @@ -122,6 +121,11 @@ in Host ee HostName pascal.ee.ryerson.ca User kbujari + + Host src + HostName src.web.4kb.net + User git + PreferredAuthentications publickey ''; }; diff --git a/modules/xnet/disk.nix b/modules/xnet/disk.nix index 82e9c87..e6835f4 100644 --- a/modules/xnet/disk.nix +++ b/modules/xnet/disk.nix @@ -1,4 +1,9 @@ -{ config, lib, modulesPath, inputs, ... }: +{ + config, + lib, + modulesPath, + ... +}: let cfg = config.xnet.disk; commonOpts = { @@ -11,12 +16,16 @@ let "com.sun:auto-snapshot" = "false"; }; - inherit (lib) mkOption mkDefault mkIf types; + inherit (lib) + mkOption + mkDefault + mkIf + types + ; in { imports = [ (modulesPath + "/installer/scan/not-detected.nix") - inputs.disko.nixosModules.default ]; options.xnet.disk = { @@ -33,8 +42,7 @@ in }; config = mkIf cfg.enable { - networking.hostId = builtins.substring 0 8 - (builtins.hashString "md5" config.networking.hostName); + networking.hostId = builtins.substring 0 8 (builtins.hashString "md5" config.networking.hostName); services.zfs = { autoScrub.enable = true; @@ -46,8 +54,14 @@ in zramSwap.enable = mkDefault true; boot = { - kernelParams = [ "nohibernate" "elevator=none" ]; - supportedFilesystems = [ "vfat" "zfs" ]; + kernelParams = [ + "nohibernate" + "elevator=none" + ]; + supportedFilesystems = [ + "vfat" + "zfs" + ]; zfs.devNodes = mkDefault "/dev/disk/by-partuuid"; loader = { systemd-boot.enable = true; @@ -94,7 +108,11 @@ in disko.devices = { nodev."/" = { fsType = "tmpfs"; - mountOptions = [ "defaults" "size=2G" "mode=755" ]; + mountOptions = [ + "defaults" + "size=2G" + "mode=755" + ]; }; zpool.zroot = { diff --git a/modules/xnet/gitserver/default.nix b/modules/xnet/gitserver/default.nix index 2152ebd..2bd471a 100644 --- a/modules/xnet/gitserver/default.nix +++ b/modules/xnet/gitserver/default.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.xnet.gitServer; inherit (lib) mkOption mkIf types; diff --git a/modules/xnet/gitserver/gitweb.nix b/modules/xnet/gitserver/gitweb.nix index a9ed7d9..6473183 100644 --- a/modules/xnet/gitserver/gitweb.nix +++ b/modules/xnet/gitserver/gitweb.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.xnet.gitServer.gitweb; inherit (lib) mkOption mkIf types; @@ -38,16 +43,11 @@ in mimetype.pdf=application/pdf mimetype.png=image/png mimetype.svg=image/svg+xml - readme=:readme - readme=:readme.md - readme=:readme.txt - readme=:README - readme=:README.md - readme=:README.txt + readme=master:README ''; settings = { - # about-filter = "${pkgs.cgit-pink}/lib/cgit/filters/about-formatting.sh"; - # source-filter = "${pkgs.cgit-pink}/lib/cgit/filters/syntax-highlighting.py"; + about-filter = "${pkgs.cgit}/lib/cgit/filters/about-formatting.sh"; + source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py"; clone-url = "https://${cfg.hostName}/$CGIT_REPO_URL git@${cfg.hostName}:$CGIT_REPO_URL"; enable-commit-graph = true; enable-http-clone = false; @@ -58,13 +58,16 @@ in root-desc = "What I cannot create, I do not understand"; root-title = cfg.hostName; section-from-path = true; + scan-hidden-path = true; snapshots = "tar.gz tar.bz2 zip"; }; }; - # services.nginx.virtualHosts."${cfg.gitweb.hostName}" = { - # useACMEHost = "4kb.net"; - # addSSL = true; - # }; + services.nginx.virtualHosts."${cfg.hostName}" = { + useACMEHost = "4kb.net"; + forceSSL = true; + + locations."/robots.txt".return = "200 \"User-agent: *\nDisallow: /\n\""; + }; }; } diff --git a/modules/xnet/monitoring/default.nix b/modules/xnet/monitoring/default.nix index eed4963..20566d3 100644 --- a/modules/xnet/monitoring/default.nix +++ b/modules/xnet/monitoring/default.nix @@ -9,7 +9,6 @@ in { imports = [ ./grafana.nix ]; - config = { services.prometheus = { enable = config.xnet.monitoring.hostGrafana; @@ -19,7 +18,10 @@ in node = { enable = true; openFirewall = true; - enabledCollectors = [ "processes" "systemd" ]; + enabledCollectors = [ + "processes" + "systemd" + ]; }; # systemd = { @@ -39,20 +41,29 @@ in scrapeConfigs = let - hosts = [ "iridium" "radon" ]; + hosts = [ + "iridium" + "radon" + ]; in - [{ - job_name = "node"; - static_configs = [{ - targets = map (h: "${h}:${toString exporters.node.port}") hosts; - }]; - } + [ + { + job_name = "node"; + static_configs = [ + { + targets = map (h: "${h}:${toString exporters.node.port}") hosts; + } + ]; + } { job_name = "smartctl"; - static_configs = [{ - targets = map (h: "${h}:${toString exporters.smartctl.port}") hosts; - }]; - }]; + static_configs = [ + { + targets = map (h: "${h}:${toString exporters.smartctl.port}") hosts; + } + ]; + } + ]; }; }; } diff --git a/modules/xnet/monitoring/grafana.nix b/modules/xnet/monitoring/grafana.nix index e95318d..a8712f0 100644 --- a/modules/xnet/monitoring/grafana.nix +++ b/modules/xnet/monitoring/grafana.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let inherit (lib) mkOption mkIf types; @@ -18,18 +23,22 @@ in config = mkIf hostGrafana { services.grafana.provision = { enable = true; - datasources.settings.datasources = [{ - name = "Prometheus"; - type = "prometheus"; - url = "http://localhost:9090"; - access = "proxy"; - editable = false; - }]; + datasources.settings.datasources = [ + { + name = "Prometheus"; + type = "prometheus"; + url = "http://localhost:9090"; + access = "proxy"; + editable = false; + } + ]; - dashboards.settings.providers = [{ - name = "Fetched Dashboards"; - options.path = "/etc/grafana/dashboards"; - }]; + dashboards.settings.providers = [ + { + name = "Fetched Dashboards"; + options.path = "/etc/grafana/dashboards"; + } + ]; }; environment.etc = { diff --git a/modules/xnet/nginx.nix b/modules/xnet/nginx.nix index eadd794..3e6ca7c 100644 --- a/modules/xnet/nginx.nix +++ b/modules/xnet/nginx.nix @@ -14,7 +14,10 @@ in }; config = mkIf cfg.enable { - networking.firewall.allowedTCPPorts = [ 80 443 ]; + networking.firewall.allowedTCPPorts = [ + 80 + 443 + ]; services.nginx = { enable = true; diff --git a/modules/xnet/persist.nix b/modules/xnet/persist.nix index 10eb883..5e69bae 100644 --- a/modules/xnet/persist.nix +++ b/modules/xnet/persist.nix @@ -10,39 +10,42 @@ let in { options.xnet.persist = mkOption { - type = types.listOf (types.either - types.str - (types.submodule { - options = { - path = mkOption { - type = types.str; - description = "Path to persist"; - }; - user = mkOption { - type = types.nullOr types.str; - default = null; - description = "User ID to set on the persisted directory"; - }; - group = mkOption { - type = types.nullOr types.str; - default = null; - description = "Group ID to set on the persisted directory"; - }; + type = types.listOf ( + types.either types.str ( + types.submodule { + options = { + path = mkOption { + type = types.str; + description = "Path to persist"; + }; + user = mkOption { + type = types.nullOr types.str; + default = null; + description = "User ID to set on the persisted directory"; + }; + group = mkOption { + type = types.nullOr types.str; + default = null; + description = "Group ID to set on the persisted directory"; + }; - mode = mkOption { - type = types.nullOr types.str; - default = null; - description = "Permissions to set"; + mode = mkOption { + type = types.nullOr types.str; + default = null; + description = "Permissions to set"; + }; }; - }; - })); + } + ) + ); default = [ ]; description = "Automatically persisted state."; }; config.systemd.tmpfiles.rules = let - mkEntry = entry: + mkEntry = + entry: let path = if isString entry then entry else entry.path; user = if isString entry then "-" else entry.user; @@ -53,7 +56,11 @@ in link = "L+ ${path} - - - - /persist${path}"; perm = "Z ${mode} ${user} ${group} - -"; in - [ dent link perm ]; + [ + dent + link + perm + ]; entries = map mkEntry config.xnet.persist; in |
