From b671c05db950140a3fb24af664b71fbad7205d65 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 31 Jul 2024 11:11:14 +0800 Subject: [PATCH 1/8] feat: migrate services to aqua --- .../{12kingdoms-rakushun => idols-aquamarine}/caddy.nix | 0 .../exporters/default.nix | 0 .../{12kingdoms-rakushun => idols-aquamarine}/gitea.nix | 0 .../grafana/dashboards.yml | 0 .../grafana/dashboards/README.md | 0 .../dashboards/homelab/alertmanager-9578_rev4.json | 0 .../homelab/node-exporter-full-1860_rev33.json | 0 .../dashboards/kubernetes/k8s-addons-prometheus.json | 0 .../dashboards/kubernetes/k8s-addons-trivy-operator.json | 0 .../dashboards/kubernetes/k8s-system-api-server.json | 0 .../dashboards/kubernetes/k8s-system-coredns.json | 0 .../grafana/dashboards/kubernetes/k8s-views-global.json | 0 .../dashboards/kubernetes/k8s-views-namespaces.json | 0 .../grafana/dashboards/kubernetes/k8s-views-nodes.json | 0 .../grafana/dashboards/kubernetes/k8s-views-pods.json | 0 .../grafana/datasources.yml | 0 .../grafana/default.nix | 0 .../homepage/README.md | 0 .../homepage/config/bookmarks.yaml | 0 .../homepage/config/docker.yaml | 0 .../homepage/config/kubernetes.yaml | 0 .../homepage/config/services.yaml | 0 .../homepage/config/settings.yaml | 0 .../homepage/config/widgets.yaml | 0 .../homepage/default.nix | 0 .../prometheus/README.md | 0 .../prometheus/alert_rules/coredns_embedded-exporter.yml | 0 .../prometheus/alert_rules/etcd_embedded-exporter.yml | 0 .../prometheus/alert_rules/istio_embedded-exporter.yml | 0 .../prometheus/alert_rules/kubestate-exporter.yml | 0 .../prometheus/alert_rules/node-exporter.yml | 0 .../prometheus/default.nix | 4 ++-- .../{12kingdoms-rakushun => idols-aquamarine}/restic.nix | 0 .../{12kingdoms-rakushun => idols-aquamarine}/sftpgo.nix | 0 .../transmission.nix | 0 .../uptime-kuma.nix | 0 outputs/aarch64-linux/src/12kingdoms-rakushun.nix | 9 +++------ outputs/x86_64-linux/src/idols-aquamarine.nix | 6 ++++++ 38 files changed, 11 insertions(+), 8 deletions(-) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/caddy.nix (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/exporters/default.nix (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/gitea.nix (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards.yml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/README.md (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/homelab/alertmanager-9578_rev4.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/homelab/node-exporter-full-1860_rev33.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/kubernetes/k8s-addons-prometheus.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/kubernetes/k8s-addons-trivy-operator.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/kubernetes/k8s-system-api-server.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/kubernetes/k8s-system-coredns.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/kubernetes/k8s-views-global.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/kubernetes/k8s-views-namespaces.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/kubernetes/k8s-views-nodes.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/dashboards/kubernetes/k8s-views-pods.json (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/datasources.yml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/grafana/default.nix (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/homepage/README.md (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/homepage/config/bookmarks.yaml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/homepage/config/docker.yaml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/homepage/config/kubernetes.yaml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/homepage/config/services.yaml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/homepage/config/settings.yaml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/homepage/config/widgets.yaml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/homepage/default.nix (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/prometheus/README.md (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/prometheus/alert_rules/coredns_embedded-exporter.yml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/prometheus/alert_rules/etcd_embedded-exporter.yml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/prometheus/alert_rules/istio_embedded-exporter.yml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/prometheus/alert_rules/kubestate-exporter.yml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/prometheus/alert_rules/node-exporter.yml (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/prometheus/default.nix (96%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/restic.nix (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/sftpgo.nix (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/transmission.nix (100%) rename hosts/{12kingdoms-rakushun => idols-aquamarine}/uptime-kuma.nix (100%) diff --git a/hosts/12kingdoms-rakushun/caddy.nix b/hosts/idols-aquamarine/caddy.nix similarity index 100% rename from hosts/12kingdoms-rakushun/caddy.nix rename to hosts/idols-aquamarine/caddy.nix diff --git a/hosts/12kingdoms-rakushun/exporters/default.nix b/hosts/idols-aquamarine/exporters/default.nix similarity index 100% rename from hosts/12kingdoms-rakushun/exporters/default.nix rename to hosts/idols-aquamarine/exporters/default.nix diff --git a/hosts/12kingdoms-rakushun/gitea.nix b/hosts/idols-aquamarine/gitea.nix similarity index 100% rename from hosts/12kingdoms-rakushun/gitea.nix rename to hosts/idols-aquamarine/gitea.nix diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards.yml b/hosts/idols-aquamarine/grafana/dashboards.yml similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards.yml rename to hosts/idols-aquamarine/grafana/dashboards.yml diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/README.md b/hosts/idols-aquamarine/grafana/dashboards/README.md similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/README.md rename to hosts/idols-aquamarine/grafana/dashboards/README.md diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/homelab/alertmanager-9578_rev4.json b/hosts/idols-aquamarine/grafana/dashboards/homelab/alertmanager-9578_rev4.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/homelab/alertmanager-9578_rev4.json rename to hosts/idols-aquamarine/grafana/dashboards/homelab/alertmanager-9578_rev4.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/homelab/node-exporter-full-1860_rev33.json b/hosts/idols-aquamarine/grafana/dashboards/homelab/node-exporter-full-1860_rev33.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/homelab/node-exporter-full-1860_rev33.json rename to hosts/idols-aquamarine/grafana/dashboards/homelab/node-exporter-full-1860_rev33.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-addons-prometheus.json b/hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-addons-prometheus.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-addons-prometheus.json rename to hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-addons-prometheus.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-addons-trivy-operator.json b/hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-addons-trivy-operator.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-addons-trivy-operator.json rename to hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-addons-trivy-operator.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-system-api-server.json b/hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-system-api-server.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-system-api-server.json rename to hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-system-api-server.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-system-coredns.json b/hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-system-coredns.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-system-coredns.json rename to hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-system-coredns.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-views-global.json b/hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-views-global.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-views-global.json rename to hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-views-global.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-views-namespaces.json b/hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-views-namespaces.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-views-namespaces.json rename to hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-views-namespaces.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-views-nodes.json b/hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-views-nodes.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-views-nodes.json rename to hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-views-nodes.json diff --git a/hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-views-pods.json b/hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-views-pods.json similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/dashboards/kubernetes/k8s-views-pods.json rename to hosts/idols-aquamarine/grafana/dashboards/kubernetes/k8s-views-pods.json diff --git a/hosts/12kingdoms-rakushun/grafana/datasources.yml b/hosts/idols-aquamarine/grafana/datasources.yml similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/datasources.yml rename to hosts/idols-aquamarine/grafana/datasources.yml diff --git a/hosts/12kingdoms-rakushun/grafana/default.nix b/hosts/idols-aquamarine/grafana/default.nix similarity index 100% rename from hosts/12kingdoms-rakushun/grafana/default.nix rename to hosts/idols-aquamarine/grafana/default.nix diff --git a/hosts/12kingdoms-rakushun/homepage/README.md b/hosts/idols-aquamarine/homepage/README.md similarity index 100% rename from hosts/12kingdoms-rakushun/homepage/README.md rename to hosts/idols-aquamarine/homepage/README.md diff --git a/hosts/12kingdoms-rakushun/homepage/config/bookmarks.yaml b/hosts/idols-aquamarine/homepage/config/bookmarks.yaml similarity index 100% rename from hosts/12kingdoms-rakushun/homepage/config/bookmarks.yaml rename to hosts/idols-aquamarine/homepage/config/bookmarks.yaml diff --git a/hosts/12kingdoms-rakushun/homepage/config/docker.yaml b/hosts/idols-aquamarine/homepage/config/docker.yaml similarity index 100% rename from hosts/12kingdoms-rakushun/homepage/config/docker.yaml rename to hosts/idols-aquamarine/homepage/config/docker.yaml diff --git a/hosts/12kingdoms-rakushun/homepage/config/kubernetes.yaml b/hosts/idols-aquamarine/homepage/config/kubernetes.yaml similarity index 100% rename from hosts/12kingdoms-rakushun/homepage/config/kubernetes.yaml rename to hosts/idols-aquamarine/homepage/config/kubernetes.yaml diff --git a/hosts/12kingdoms-rakushun/homepage/config/services.yaml b/hosts/idols-aquamarine/homepage/config/services.yaml similarity index 100% rename from hosts/12kingdoms-rakushun/homepage/config/services.yaml rename to hosts/idols-aquamarine/homepage/config/services.yaml diff --git a/hosts/12kingdoms-rakushun/homepage/config/settings.yaml b/hosts/idols-aquamarine/homepage/config/settings.yaml similarity index 100% rename from hosts/12kingdoms-rakushun/homepage/config/settings.yaml rename to hosts/idols-aquamarine/homepage/config/settings.yaml diff --git a/hosts/12kingdoms-rakushun/homepage/config/widgets.yaml b/hosts/idols-aquamarine/homepage/config/widgets.yaml similarity index 100% rename from hosts/12kingdoms-rakushun/homepage/config/widgets.yaml rename to hosts/idols-aquamarine/homepage/config/widgets.yaml diff --git a/hosts/12kingdoms-rakushun/homepage/default.nix b/hosts/idols-aquamarine/homepage/default.nix similarity index 100% rename from hosts/12kingdoms-rakushun/homepage/default.nix rename to hosts/idols-aquamarine/homepage/default.nix diff --git a/hosts/12kingdoms-rakushun/prometheus/README.md b/hosts/idols-aquamarine/prometheus/README.md similarity index 100% rename from hosts/12kingdoms-rakushun/prometheus/README.md rename to hosts/idols-aquamarine/prometheus/README.md diff --git a/hosts/12kingdoms-rakushun/prometheus/alert_rules/coredns_embedded-exporter.yml b/hosts/idols-aquamarine/prometheus/alert_rules/coredns_embedded-exporter.yml similarity index 100% rename from hosts/12kingdoms-rakushun/prometheus/alert_rules/coredns_embedded-exporter.yml rename to hosts/idols-aquamarine/prometheus/alert_rules/coredns_embedded-exporter.yml diff --git a/hosts/12kingdoms-rakushun/prometheus/alert_rules/etcd_embedded-exporter.yml b/hosts/idols-aquamarine/prometheus/alert_rules/etcd_embedded-exporter.yml similarity index 100% rename from hosts/12kingdoms-rakushun/prometheus/alert_rules/etcd_embedded-exporter.yml rename to hosts/idols-aquamarine/prometheus/alert_rules/etcd_embedded-exporter.yml diff --git a/hosts/12kingdoms-rakushun/prometheus/alert_rules/istio_embedded-exporter.yml b/hosts/idols-aquamarine/prometheus/alert_rules/istio_embedded-exporter.yml similarity index 100% rename from hosts/12kingdoms-rakushun/prometheus/alert_rules/istio_embedded-exporter.yml rename to hosts/idols-aquamarine/prometheus/alert_rules/istio_embedded-exporter.yml diff --git a/hosts/12kingdoms-rakushun/prometheus/alert_rules/kubestate-exporter.yml b/hosts/idols-aquamarine/prometheus/alert_rules/kubestate-exporter.yml similarity index 100% rename from hosts/12kingdoms-rakushun/prometheus/alert_rules/kubestate-exporter.yml rename to hosts/idols-aquamarine/prometheus/alert_rules/kubestate-exporter.yml diff --git a/hosts/12kingdoms-rakushun/prometheus/alert_rules/node-exporter.yml b/hosts/idols-aquamarine/prometheus/alert_rules/node-exporter.yml similarity index 100% rename from hosts/12kingdoms-rakushun/prometheus/alert_rules/node-exporter.yml rename to hosts/idols-aquamarine/prometheus/alert_rules/node-exporter.yml diff --git a/hosts/12kingdoms-rakushun/prometheus/default.nix b/hosts/idols-aquamarine/prometheus/default.nix similarity index 96% rename from hosts/12kingdoms-rakushun/prometheus/default.nix rename to hosts/idols-aquamarine/prometheus/default.nix index df073d47..fbfa32d6 100644 --- a/hosts/12kingdoms-rakushun/prometheus/default.nix +++ b/hosts/idols-aquamarine/prometheus/default.nix @@ -83,7 +83,7 @@ metrics_path = "/metrics"; static_configs = [ { - targets = ["${myvars.networking.hostsAddr.rakushun.ipv4}:9153"]; + targets = ["${myvars.networking.hostsAddr.aquamarine.ipv4}:9153"]; labels.type = "app"; labels.app = "v2ray"; } @@ -96,7 +96,7 @@ metrics_path = "/metrics"; static_configs = [ { - targets = ["${myvars.networking.hostsAddr.rakushun.ipv4}:10000"]; + targets = ["${myvars.networking.hostsAddr.aquamarine.ipv4}:10000"]; labels.type = "app"; labels.app = "v2ray"; } diff --git a/hosts/12kingdoms-rakushun/restic.nix b/hosts/idols-aquamarine/restic.nix similarity index 100% rename from hosts/12kingdoms-rakushun/restic.nix rename to hosts/idols-aquamarine/restic.nix diff --git a/hosts/12kingdoms-rakushun/sftpgo.nix b/hosts/idols-aquamarine/sftpgo.nix similarity index 100% rename from hosts/12kingdoms-rakushun/sftpgo.nix rename to hosts/idols-aquamarine/sftpgo.nix diff --git a/hosts/12kingdoms-rakushun/transmission.nix b/hosts/idols-aquamarine/transmission.nix similarity index 100% rename from hosts/12kingdoms-rakushun/transmission.nix rename to hosts/idols-aquamarine/transmission.nix diff --git a/hosts/12kingdoms-rakushun/uptime-kuma.nix b/hosts/idols-aquamarine/uptime-kuma.nix similarity index 100% rename from hosts/12kingdoms-rakushun/uptime-kuma.nix rename to hosts/idols-aquamarine/uptime-kuma.nix diff --git a/outputs/aarch64-linux/src/12kingdoms-rakushun.nix b/outputs/aarch64-linux/src/12kingdoms-rakushun.nix index 07dc55d3..df5a4c31 100644 --- a/outputs/aarch64-linux/src/12kingdoms-rakushun.nix +++ b/outputs/aarch64-linux/src/12kingdoms-rakushun.nix @@ -24,13 +24,10 @@ "hosts/12kingdoms-${name}" ]) ++ [ - {modules.secrets.server.application.enable = true;} - {modules.secrets.server.operation.enable = true;} - {modules.secrets.server.webserver.enable = true;} ]; - home-modules = map mylib.relativeToRoot [ - "home/linux/tui.nix" - ]; + home-modules = + map mylib.relativeToRoot [ + ]; }; inherit (inputs) nixos-rk3588; diff --git a/outputs/x86_64-linux/src/idols-aquamarine.nix b/outputs/x86_64-linux/src/idols-aquamarine.nix index 0bd12d22..0e621d34 100644 --- a/outputs/x86_64-linux/src/idols-aquamarine.nix +++ b/outputs/x86_64-linux/src/idols-aquamarine.nix @@ -26,7 +26,13 @@ "hosts/idols-${name}" ]) ++ [ + {modules.secrets.server.application.enable = true;} + {modules.secrets.server.operation.enable = true;} + {modules.secrets.server.webserver.enable = true;} ]; + home-modules = map mylib.relativeToRoot [ + "home/linux/tui.nix" + ]; }; systemArgs = modules // args; From 8c795c7d0d15e9b6ed62b378bbb82a533d72c6a6 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 31 Jul 2024 11:52:48 +0800 Subject: [PATCH 2/8] feat: change data directories, add disko for usb storage --- hosts/idols-aquamarine/caddy.nix | 14 ++--- hosts/idols-aquamarine/default.nix | 7 ++- hosts/idols-aquamarine/disko-fs.nix | 58 +++++++++++++++++++++ hosts/idols-aquamarine/filesystems.nix | 12 ----- hosts/idols-aquamarine/gitea.nix | 2 +- hosts/idols-aquamarine/grafana/default.nix | 2 +- hosts/idols-aquamarine/homepage/default.nix | 2 +- hosts/idols-aquamarine/sftpgo.nix | 2 +- hosts/idols-aquamarine/transmission.nix | 2 +- hosts/idols-aquamarine/uptime-kuma.nix | 2 +- 10 files changed, 77 insertions(+), 26 deletions(-) create mode 100644 hosts/idols-aquamarine/disko-fs.nix delete mode 100644 hosts/idols-aquamarine/filesystems.nix diff --git a/hosts/idols-aquamarine/caddy.nix b/hosts/idols-aquamarine/caddy.nix index fdf82082..3adcbbbc 100644 --- a/hosts/idols-aquamarine/caddy.nix +++ b/hosts/idols-aquamarine/caddy.nix @@ -17,7 +17,7 @@ in { # Reload Caddy instead of restarting it when configuration file changes. enableReload = true; user = "caddy"; # User account under which caddy runs. - dataDir = "/var/lib/caddy"; + dataDir = "/data/apps/caddy"; logDir = "/var/log/caddy"; # Additional lines of configuration appended to the global config section of the Caddyfile. @@ -36,7 +36,7 @@ in { # https://caddyserver.com/docs/caddyfile/directives/file_server virtualHosts."file.writefor.fun".extraConfig = '' - root * /var/lib/caddy/fileserver/ + root * /data/apps/caddy/fileserver/ ${hostCommonConfig} file_server browse { hide .git @@ -83,15 +83,15 @@ in { # Create Directories systemd.tmpfiles.rules = [ - "d /var/lib/caddy/fileserver/ 0755 caddy caddy" + "d /data/apps/caddy/fileserver/ 0755 caddy caddy" # directory for virtual machine's images - "d /var/lib/caddy/fileserver/vms 0755 caddy caddy" + "d /data/apps/caddy/fileserver/vms 0755 caddy caddy" ]; - # Add all my wallpapers into /var/lib/caddy/fileserver/wallpapers + # Add all my wallpapers into /data/apps/caddy/fileserver/wallpapers # Install the homepage-dashboard configuration files system.activationScripts.installCaddyWallpapers = '' - mkdir -p /var/lib/caddy/fileserver/wallpapers - ${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F644 ${wallpapers}/ /var/lib/caddy/fileserver/wallpapers/ + mkdir -p /data/apps/caddy/fileserver/wallpapers + ${pkgs.rsync}/bin/rsync -avz --chmod=D2755,F644 ${wallpapers}/ /data/apps/caddy/fileserver/wallpapers/ ''; } diff --git a/hosts/idols-aquamarine/default.nix b/hosts/idols-aquamarine/default.nix index 248f9782..d6a56da3 100644 --- a/hosts/idols-aquamarine/default.nix +++ b/hosts/idols-aquamarine/default.nix @@ -2,6 +2,7 @@ mylib, myvars, pkgs, + disko, ... }: ############################################################# @@ -12,7 +13,11 @@ let hostName = "aquamarine"; # Define your hostname. in { - imports = mylib.scanPaths ./.; + imports = + (mylib.scanPaths ./.) + ++ [ + disko.nixosModules.default + ]; # supported file systems, so we can mount any removable disks with these filesystems boot.supportedFilesystems = [ diff --git a/hosts/idols-aquamarine/disko-fs.nix b/hosts/idols-aquamarine/disko-fs.nix new file mode 100644 index 00000000..0b81cd85 --- /dev/null +++ b/hosts/idols-aquamarine/disko-fs.nix @@ -0,0 +1,58 @@ +# auto disk partitioning: +# nix run github:nix-community/disko -- --mode disko ./disko-fs.nix +{ + disko.devices = { + disk.data-apps = { + type = "disk"; + device = "/dev/disk/by-id/ata-WDC_WD40EJRX-89T1XY0_WD-WCC7K0XDCZE6"; + content = { + type = "gpt"; + partitions.data-apps = { + size = "100%"; + content = { + type = "btrfs"; + # extraArgs = ["-f"]; # Override existing partition + subvolumes = { + "@persistent" = { + mountpoint = "/data/apps"; + mountOptions = ["compress-force=zstd:1" "noatime"]; + }; + "@backups" = { + mountpoint = "/data/backups"; + mountOptions = ["compress-force=zstd:1" "noatime"]; + }; + "@snapshots" = { + mountpoint = "/data/apps-snapshots"; + mountOptions = ["compress-force=zstd:1" "noatime"]; + }; + }; + }; + }; + }; + }; + disk.data-fileshare = { + type = "disk"; + device = "/dev/disk/by-id/ata-WDC_WD40EZRZ-22GXCB0_WD-WCC7K7VV9613"; + content = { + type = "gpt"; + partitions.data-fileshare = { + size = "100%"; + content = { + type = "btrfs"; + # extraArgs = ["-f"]; # Override existing partition + subvolumes = { + "@persistent" = { + mountpoint = "/data/fileshare"; + mountOptions = ["compress-force=zstd:1" "noatime"]; + }; + "@snapshots" = { + mountpoint = "/data/fileshare-snapshots"; + mountOptions = ["compress-force=zstd:1" "noatime"]; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/idols-aquamarine/filesystems.nix b/hosts/idols-aquamarine/filesystems.nix deleted file mode 100644 index bd3fe0ef..00000000 --- a/hosts/idols-aquamarine/filesystems.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - fileSystems."/data/downloads" = { - device = "/dev/disk/by-label/Downloads"; - fsType = "ntfs-3g"; - options = ["rw" "uid=1000"]; - }; - fileSystems."/data/games" = { - device = "/dev/disk/by-label/Games"; - fsType = "ntfs-3g"; - options = ["rw" "uid=1000"]; - }; -} diff --git a/hosts/idols-aquamarine/gitea.nix b/hosts/idols-aquamarine/gitea.nix index 3b920dfd..6621a6ba 100644 --- a/hosts/idols-aquamarine/gitea.nix +++ b/hosts/idols-aquamarine/gitea.nix @@ -5,7 +5,7 @@ in { enable = true; user = "gitea"; group = "gitea"; - stateDir = "/var/lib/gitea"; + stateDir = "/data/apps/gitea"; appName = "Ryan Yin's Gitea Service"; lfs.enable = true; # Enable a timer that runs gitea dump to generate backup-files of the current gitea database and repositories. diff --git a/hosts/idols-aquamarine/grafana/default.nix b/hosts/idols-aquamarine/grafana/default.nix index 7520bdc9..7499f8b5 100644 --- a/hosts/idols-aquamarine/grafana/default.nix +++ b/hosts/idols-aquamarine/grafana/default.nix @@ -5,7 +5,7 @@ }: { services.grafana = { enable = true; - dataDir = "/var/lib/grafana"; + dataDir = "/data/apps/grafana"; # DeclarativePlugins = with pkgs.grafanaPlugins; [ grafana-piechart-panel ]; settings = { server = { diff --git a/hosts/idols-aquamarine/homepage/default.nix b/hosts/idols-aquamarine/homepage/default.nix index 9147284d..fa8a442f 100644 --- a/hosts/idols-aquamarine/homepage/default.nix +++ b/hosts/idols-aquamarine/homepage/default.nix @@ -1,5 +1,5 @@ {pkgs, ...}: let - configDir = "/var/lib/homepage-dashboard"; + configDir = "/data/apps/homepage-dashboard"; in { # https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/misc/homepage-dashboard.nix services.homepage-dashboard = { diff --git a/hosts/idols-aquamarine/sftpgo.nix b/hosts/idols-aquamarine/sftpgo.nix index 997b4717..ce78a042 100644 --- a/hosts/idols-aquamarine/sftpgo.nix +++ b/hosts/idols-aquamarine/sftpgo.nix @@ -5,7 +5,7 @@ services.sftpgo = { enable = true; user = "sftpgo"; - dataDir = "/var/lib/sftpgo"; + dataDir = "/data/apps/sftpgo"; extraArgs = [ "--log-level" "info" diff --git a/hosts/idols-aquamarine/transmission.nix b/hosts/idols-aquamarine/transmission.nix index ea58eefc..a03177ac 100644 --- a/hosts/idols-aquamarine/transmission.nix +++ b/hosts/idols-aquamarine/transmission.nix @@ -3,7 +3,7 @@ myvars, ... }: let - dataDir = "/var/lib/transmission"; + dataDir = "/data/apps/transmission"; name = "transmission"; in { # the headless Transmission BitTorrent daemon diff --git a/hosts/idols-aquamarine/uptime-kuma.nix b/hosts/idols-aquamarine/uptime-kuma.nix index 825bb1be..6e57821a 100644 --- a/hosts/idols-aquamarine/uptime-kuma.nix +++ b/hosts/idols-aquamarine/uptime-kuma.nix @@ -6,7 +6,7 @@ settings = { "UPTIME_KUMA_HOST" = "127.0.0.1"; "UPTIME_KUMA_PORT" = "3350"; - "DATA_DIR" = "/var/lib/uptime-kuma/"; + "DATA_DIR" = "/data/apps/uptime-kuma/"; }; }; } From 41dc24e350045d72ec5f31141fad1b3cfc0392fc Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 31 Jul 2024 15:07:53 +0800 Subject: [PATCH 3/8] feat: aqua - no fail if usb storage is not available --- hosts/idols-aquamarine/disko-fs.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hosts/idols-aquamarine/disko-fs.nix b/hosts/idols-aquamarine/disko-fs.nix index 0b81cd85..cb0c9461 100644 --- a/hosts/idols-aquamarine/disko-fs.nix +++ b/hosts/idols-aquamarine/disko-fs.nix @@ -15,15 +15,19 @@ subvolumes = { "@persistent" = { mountpoint = "/data/apps"; - mountOptions = ["compress-force=zstd:1" "noatime"]; + mountOptions = [ + "compress-force=zstd:1" + # https://www.freedesktop.org/software/systemd/man/latest/systemd.mount.html + "nofail" + ]; }; "@backups" = { mountpoint = "/data/backups"; - mountOptions = ["compress-force=zstd:1" "noatime"]; + mountOptions = ["compress-force=zstd:1" "noatime" "nofail"]; }; "@snapshots" = { mountpoint = "/data/apps-snapshots"; - mountOptions = ["compress-force=zstd:1" "noatime"]; + mountOptions = ["compress-force=zstd:1" "noatime" "nofail"]; }; }; }; @@ -43,11 +47,11 @@ subvolumes = { "@persistent" = { mountpoint = "/data/fileshare"; - mountOptions = ["compress-force=zstd:1" "noatime"]; + mountOptions = ["compress-force=zstd:1" "nofail"]; }; "@snapshots" = { mountpoint = "/data/fileshare-snapshots"; - mountOptions = ["compress-force=zstd:1" "noatime"]; + mountOptions = ["compress-force=zstd:1" "noatime" "nofail"]; }; }; }; From 15e0b150e9e8332e6d69be5d79c88a21a957d543 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 31 Jul 2024 15:38:48 +0800 Subject: [PATCH 4/8] fix: home page --- hosts/idols-aquamarine/homepage/default.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hosts/idols-aquamarine/homepage/default.nix b/hosts/idols-aquamarine/homepage/default.nix index fa8a442f..038410cb 100644 --- a/hosts/idols-aquamarine/homepage/default.nix +++ b/hosts/idols-aquamarine/homepage/default.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: let +{ + lib, + pkgs, + ... +}: let configDir = "/data/apps/homepage-dashboard"; in { # https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/misc/homepage-dashboard.nix @@ -8,7 +12,7 @@ in { openFirewall = false; }; systemd.services.homepage-dashboard.environment = { - HOMEPAGE_CONFIG_DIR = configDir; + HOMEPAGE_CONFIG_DIR = lib.mkForce configDir; # 1. The value of env var HOMEPAGE_VAR_XXX will replace {{HOMEPAGE_VAR_XXX}} in any config # HOMEPAGE_VAR_XXX_APIKEY = "myapikey"; From b3127a18c9ffb0158aae584ac4f6d128daa6006b Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 31 Jul 2024 15:42:40 +0800 Subject: [PATCH 5/8] fix: uptime kuma --- hosts/idols-aquamarine/uptime-kuma.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts/idols-aquamarine/uptime-kuma.nix b/hosts/idols-aquamarine/uptime-kuma.nix index 6e57821a..d4e9c9ac 100644 --- a/hosts/idols-aquamarine/uptime-kuma.nix +++ b/hosts/idols-aquamarine/uptime-kuma.nix @@ -1,9 +1,9 @@ -{ +{lib, ...}: { # https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/monitoring/uptime-kuma.nix services.uptime-kuma = { enable = true; # https://github.com/louislam/uptime-kuma/wiki/Environment-Variables - settings = { + settings = lib.mkForce { "UPTIME_KUMA_HOST" = "127.0.0.1"; "UPTIME_KUMA_PORT" = "3350"; "DATA_DIR" = "/data/apps/uptime-kuma/"; From 5178a3e63857f04e42232b0e0a815eefd2882826 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 31 Jul 2024 15:52:41 +0800 Subject: [PATCH 6/8] fix: sftpgo - directory --- hosts/idols-aquamarine/sftpgo.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hosts/idols-aquamarine/sftpgo.nix b/hosts/idols-aquamarine/sftpgo.nix index ce78a042..05811ce0 100644 --- a/hosts/idols-aquamarine/sftpgo.nix +++ b/hosts/idols-aquamarine/sftpgo.nix @@ -2,6 +2,11 @@ # Read SFTPGO_DEFAULT_ADMIN_USERNAME and SFTPGO_DEFAULT_ADMIN_PASSWORD from a file systemd.services.sftpgo.serviceConfig.EnvironmentFile = config.age.secrets."sftpgo.env".path; + # Create Directories + systemd.tmpfiles.rules = [ + "d /data/apps/sftpgo 0755 stfpgo stfpgo" + ]; + services.sftpgo = { enable = true; user = "sftpgo"; From fc81143c106b00ca4b9b3264513a11687a8f279e Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 31 Jul 2024 16:01:02 +0800 Subject: [PATCH 7/8] chore: update mysecrets --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 57ee7fe5..9de15aa5 100644 --- a/flake.lock +++ b/flake.lock @@ -686,10 +686,10 @@ "mysecrets": { "flake": false, "locked": { - "lastModified": 1722319213, - "narHash": "sha256-yiG+fBKr8ChhZPNREPQFuSLsYxNLjQIx3BabUIr5dp8=", + "lastModified": 1722412796, + "narHash": "sha256-bV+DbfqItujekh62XWpqC2ldkw6KqAo6LOpKLh9M7Sc=", "ref": "refs/heads/main", - "rev": "bbdba5e791ef8bdfc5e285c7cb651222453b49d8", + "rev": "8e3cf78c9f6b016625681f668e154b3705851a0d", "shallow": true, "type": "git", "url": "ssh://git@github.com/ryan4yin/nix-secrets.git" From 64dd1fc2f368da41407446fbdf280f6a1c98bb10 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Wed, 31 Jul 2024 16:20:32 +0800 Subject: [PATCH 8/8] fix: typo --- hosts/idols-aquamarine/sftpgo.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hosts/idols-aquamarine/sftpgo.nix b/hosts/idols-aquamarine/sftpgo.nix index 05811ce0..7638bce5 100644 --- a/hosts/idols-aquamarine/sftpgo.nix +++ b/hosts/idols-aquamarine/sftpgo.nix @@ -1,16 +1,18 @@ -{config, ...}: { +{config, ...}: let + user = "sftpgo"; + dataDir = "/data/apps/sftpgo"; +in { # Read SFTPGO_DEFAULT_ADMIN_USERNAME and SFTPGO_DEFAULT_ADMIN_PASSWORD from a file systemd.services.sftpgo.serviceConfig.EnvironmentFile = config.age.secrets."sftpgo.env".path; # Create Directories systemd.tmpfiles.rules = [ - "d /data/apps/sftpgo 0755 stfpgo stfpgo" + "d ${dataDir} 0755 ${user} ${user}" ]; services.sftpgo = { enable = true; - user = "sftpgo"; - dataDir = "/data/apps/sftpgo"; + inherit user dataDir; extraArgs = [ "--log-level" "info"