diff options
| author | Martin Fischer <martin@push-f.com> | 2026-09-30 10:59:24 +0200 |
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2026-09-30 11:00:58 +0200 |
| commit | 748d3282d351107723e79060a9471b08e66c4670 (patch) | |
| tree | e1d52d7ae8a4095683a70e1dd2079de17ddc5c60 /nixos | |
| parent | d1f67c929ae7397b7ae241bb59932113b5f9e4c1 (diff) | |
refactor: move absolute path imports to private.nix
Diffstat (limited to 'nixos')
| -rw-r--r-- | nixos/hosts/ev/default.nix | 27 | ||||
| -rw-r--r-- | nixos/hosts/ev/hosehawk.nix | 32 | ||||
| -rw-r--r-- | nixos/hosts/ev/private.nix | 50 | ||||
| -rwxr-xr-x | nixos/rebuild | 22 |
4 files changed, 69 insertions, 62 deletions
diff --git a/nixos/hosts/ev/default.nix b/nixos/hosts/ev/default.nix index 5c9d64e..3e30678 100644 --- a/nixos/hosts/ev/default.nix +++ b/nixos/hosts/ev/default.nix @@ -20,8 +20,6 @@ in <top/shared/postgresql.nix> <top/shared/tailscale.nix> <top/shared/basics-physical.nix> - # Not yet released; will be eventually. - /home/martin/repos/exercise-log/service.nix <top/shared/vpn.nix> <top/shared/restic-database-backups.nix> ./exporters.nix @@ -29,7 +27,6 @@ in ./kodi.nix ./miniflux.nix ./navidrome.nix - ./hosehawk.nix ./qbittorrent.nix ]; @@ -166,21 +163,11 @@ in ]; }; - exerciseLog = { - enable = true; - port = ports.exerciseLog; - }; - home-automation = { zigbee2mqttPort = ports.zigbee2mqtt; zigbeeSerialPort = "/dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_e2fed465c59ded11962fd7a5a7669f5d-if00-port0"; }; - hosehawk = { - nestPort = ports.hosehawk; - hawkMetricsPort = ports.prometheusHoseHawk; - }; - kodi = { user = "kodi"; }; @@ -239,19 +226,6 @@ in targets = ["localhost:${toString ports.prometheusSqlExporter}"]; }]; } - { - job_name = "exercise-log"; - scrape_interval = "10m"; - static_configs = [{ - targets = ["localhost:${toString ports.exerciseLog}"]; - }]; - } - { - job_name = "hosehawk"; - static_configs = [{ - targets = ["localhost:${toString ports.prometheusHoseHawk}"]; - }]; - } ]; }; @@ -267,7 +241,6 @@ in ]; sqliteDatabases = { anki-martin = "/var/lib/anki-sync-server/martin/collection.anki2"; - exercise-log = "/var/lib/exercise-log/database.sqlite"; navidrome = "/var/lib/navidrome/navidrome.db"; }; timerConfig = { OnCalendar = "00:20"; }; diff --git a/nixos/hosts/ev/hosehawk.nix b/nixos/hosts/ev/hosehawk.nix deleted file mode 100644 index 3a9c71d..0000000 --- a/nixos/hosts/ev/hosehawk.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - cfg = config.hosehawk; -in -{ - imports = [ - /home/martin/repos/hosehawk/services/hosenest.nix - /home/martin/repos/hosehawk/services/hosehawk.nix - ]; - - options.hosehawk = { - nestPort = lib.mkOption { - type = lib.types.int; - }; - hawkMetricsPort = lib.mkOption { - type = lib.types.int; - }; - }; - - config = { - services.hosenest = { - enable = true; - port = cfg.nestPort; - }; - services.hosehawk = { - enable = true; - hosenestUrl = "http://localhost:${toString cfg.nestPort}/"; - prometheusPort = cfg.hawkMetricsPort; - }; - }; -} diff --git a/nixos/hosts/ev/private.nix b/nixos/hosts/ev/private.nix new file mode 100644 index 0000000..a5404fc --- /dev/null +++ b/nixos/hosts/ev/private.nix @@ -0,0 +1,50 @@ +{ config, lib, pkgs, ... }: + +let + ports = import ./ports.nix; +in +{ + imports = [ + ./default.nix + # Not yet published; will be eventually. + /home/martin/repos/exercise-log/service.nix + /home/martin/repos/hosehawk/services/hosenest.nix + /home/martin/repos/hosehawk/services/hosehawk.nix + ]; + + exerciseLog = { + enable = true; + port = ports.exerciseLog; + }; + + services.hosenest = { + enable = true; + port = ports.hosehawk; + }; + + services.hosehawk = { + enable = true; + hosenestUrl = "http://localhost:${toString ports.hosehawk}/"; + prometheusPort = ports.prometheusHoseHawk; + }; + + monitoring.prometheusScrapeConfigs = [ + { + job_name = "exercise-log"; + scrape_interval = "10m"; + static_configs = [{ + targets = ["localhost:${toString ports.exerciseLog}"]; + }]; + } + { + job_name = "hosehawk"; + static_configs = [{ + targets = ["localhost:${toString ports.prometheusHoseHawk}"]; + }]; + } + ]; + + restic-database-backups.sqliteDatabases = { + exercise-log = "/var/lib/exercise-log/database.sqlite"; + }; +} diff --git a/nixos/rebuild b/nixos/rebuild index 9e62b33..d6a06a8 100755 --- a/nixos/rebuild +++ b/nixos/rebuild @@ -2,9 +2,25 @@ set -euo pipefail top=$(dirname "$(realpath "$0")") -configPath="$top/hosts/$HOSTNAME/default.nix" +hostDir="$top/hosts/$HOSTNAME" +defaultConfigPath="$hostDir/default.nix" +privateConfigPath="$hostDir/private.nix" -if [ ! -f $configPath ]; then +case "${1:-}" in + --default) + configPath="$defaultConfigPath" + shift + ;; + *) + if [ -f "$privateConfigPath" ]; then + configPath="$privateConfigPath" + else + configPath="$defaultConfigPath" + fi + ;; +esac + +if [ ! -f "$configPath" ]; then echo "aborting: $configPath doesn't exist" exit 1 fi @@ -27,7 +43,7 @@ nixpkgsPath=$( # The result symlink created in the current directory is registered as a root of the Nix # garbage collector, so it's important that we call nixos-rebuild from the host directory. # (nix-build has an --out-link option but that option cannot be set via nixos-rebuild). - cd $top/hosts/$HOSTNAME && + cd "$hostDir" && # nixos-rebuild always reads Nixpkgs from the NIX_PATH, # so we need to set it explicitly to our pinned version |
