modules: extract hyprspace module

This commit is contained in:
Max Headroom 2022-02-05 19:09:02 +01:00
parent 86205708cd
commit 3f57cd9aa6
3 changed files with 5 additions and 4 deletions

View file

@ -24,7 +24,6 @@
./services/fbi ./services/fbi
./services/gitlab ./services/gitlab
./services/hydra ./services/hydra
./services/hyprspace
./services/ipfs ./services/ipfs
./services/jokes ./services/jokes
./services/nextcloud ./services/nextcloud
@ -41,6 +40,7 @@
./services/vault ./services/vault
./services/warehouse ./services/warehouse
./services/websites ./services/websites
aspect.modules.hyprspace
] ]
# TODO: fix users # TODO: fix users
# ++ (import ../../users "server").groups.admin # ++ (import ../../users "server").groups.admin

View file

@ -7,6 +7,7 @@ let
enterprise = import ./enterprise; enterprise = import ./enterprise;
fail2ban = import ./fail2ban; fail2ban = import ./fail2ban;
hydra = import ./hydra; hydra = import ./hydra;
hyprspace = import ./hyprspace;
ipfs = import ./ipfs; ipfs = import ./ipfs;
nix-builder = import ./nix-builder; nix-builder = import ./nix-builder;
nix-config = import ./nix-config; nix-config = import ./nix-config;

View file

@ -1,7 +1,7 @@
{ pkgs, inputs, lib, hosts, config, ... }: { pkgs, inputs, lib, hosts, config, ... }:
let let
inherit (config.networking) hostName; inherit (config.networking) hostName;
inherit (inputs.self.packages.x86_64-linux) hyprspace; inherit (inputs.self.packages.${pkgs.system}) hyprspace;
hyprspaceCapableNodes = lib.filterAttrs (_: host: host ? hypr) hosts; hyprspaceCapableNodes = lib.filterAttrs (_: host: host ? hypr) hosts;
peersFormatted = builtins.mapAttrs (_: x: { "${x.hypr.addr}".id = x.hypr.id; }) hyprspaceCapableNodes; peersFormatted = builtins.mapAttrs (_: x: { "${x.hypr.addr}".id = x.hypr.id; }) hyprspaceCapableNodes;
peersFiltered = lib.filterAttrs (name: _: name != hostName) peersFormatted; peersFiltered = lib.filterAttrs (name: _: name != hostName) peersFormatted;
@ -25,7 +25,7 @@ let
in { in {
networking.hosts = lib.mapAttrs' (k: v: lib.nameValuePair (v.hypr.addr) ([k "${k}.hypr"])) hyprspaceCapableNodes; networking.hosts = lib.mapAttrs' (k: v: lib.nameValuePair (v.hypr.addr) ([k "${k}.hypr"])) hyprspaceCapableNodes;
age.secrets.hyprspace-key = { age.secrets.hyprspace-key = {
file = ../../../../secrets/hyprspace-key- + "${hostName}.age"; file = ../../secrets/hyprspace-key- + "${hostName}.age";
mode = "0400"; mode = "0400";
}; };
systemd.services.hyprspace = { systemd.services.hyprspace = {
@ -44,7 +44,7 @@ in {
chmod 0400 ${runConfig} chmod 0400 ${runConfig}
''; '';
path = [ pkgs.iproute2 ]; environment.HYPRSPACE_SWARM_KEY = config.age.secrets.ipfs-swarm-key.path;
serviceConfig = { serviceConfig = {
ExecStart = "${hyprspace}/bin/hyprspace up hyprspace -f -c ${runConfig}"; ExecStart = "${hyprspace}/bin/hyprspace up hyprspace -f -c ${runConfig}";
ExecStop = "${hyprspace}/bin/hyprspace down hyprspace"; ExecStop = "${hyprspace}/bin/hyprspace down hyprspace";