upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/nix/example-configuration.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix/example-configuration.nix')
-rw-r--r--nix/example-configuration.nix111
1 files changed, 93 insertions, 18 deletions
diff --git a/nix/example-configuration.nix b/nix/example-configuration.nix
index a00d970..34615be 100644
--- a/nix/example-configuration.nix
+++ b/nix/example-configuration.nix
@@ -1,4 +1,4 @@
1# Example NixOS configuration using ngit-grasp module 1# Example NixOS configurations using ngit-grasp module
2# 2#
3# Usage: 3# Usage:
4# 1. Add to your server's flake.nix inputs: 4# 1. Add to your server's flake.nix inputs:
@@ -7,48 +7,54 @@
7# 2. Import the module in your configuration: 7# 2. Import the module in your configuration:
8# imports = [ inputs.ngit-grasp.nixosModules.default ]; 8# imports = [ inputs.ngit-grasp.nixosModules.default ];
9# 9#
10# 3. Configure the service (example below) 10# 3. Configure one or more instances (examples below)
11 11
12{ inputs, ... }: 12{ inputs, ... }:
13 13
14{ 14{
15 imports = [ inputs.ngit-grasp.nixosModules.default ]; 15 imports = [ inputs.ngit-grasp.nixosModules.default ];
16 16
17 services.ngit-grasp = { 17 # ============================================================================
18 # EXAMPLE 1: Single Instance Configuration
19 # ============================================================================
20
21 services.ngit-grasp.production = {
18 enable = true; 22 enable = true;
19 domain = "ngit.danconwaydev.com"; 23 domain = "ngit.danconwaydev.com";
20 24
21 # Network 25 # Network
22 bindAddress = "127.0.0.1"; 26 bindAddress = "127.0.0.1";
23 port = 8082; # Same port as current ngit-relay for Caddy compatibility 27 port = 8082;
24 28
25 # Storage (reuse existing persistent path pattern) 29 # Storage
26 dataDir = "/persistent/ngit-danconwaydev-com-ngit-grasp"; 30 dataDir = "/persistent/ngit-danconwaydev-com-ngit-grasp";
27 31
28 # Identity 32 # Identity
29 relayName = "DanConwayDev's ngit-grasp"; 33 relayName = "DanConwayDev's ngit-grasp";
30 relayDescription = "personal instance of ngit-grasp, a Rust GRASP implementation with proactive sync"; 34 relayDescription =
31 35 "personal instance of ngit-grasp, a Rust GRASP implementation with proactive sync";
36
32 # Option 1: Use nsec file (recommended - more secure) 37 # Option 1: Use nsec file (recommended - more secure)
33 relayOwnerNsecFile = "/persistent/ngit-danconwaydev-com-ngit-grasp/relay-owner.nsec"; 38 relayOwnerNsecFile =
34 39 "/persistent/ngit-danconwaydev-com-ngit-grasp/relay-owner.nsec";
40
35 # Option 2: Inline nsec (less secure, ends up in nix store) 41 # Option 2: Inline nsec (less secure, ends up in nix store)
36 # relayOwnerNsec = "nsec1..."; 42 # relayOwnerNsec = "nsec1...";
37 43
38 # Option 3: Auto-generate (default if neither above is set) 44 # Option 3: Auto-generate (default if neither above is set)
39 # ngit-grasp will create .relay-owner.nsec in dataDir automatically 45 # ngit-grasp will create .relay-owner.nsec in dataDir automatically
40 46
41 # Sync 47 # Sync
42 syncBootstrapRelayUrl = "wss://relay.ngit.dev"; 48 syncBootstrapRelayUrl = "wss://relay.ngit.dev";
43 49
44 # Metrics 50 # Metrics
45 metricsEnabled = true; 51 metricsEnabled = true;
46 52
47 # Logging 53 # Logging
48 logLevel = "info"; # Options: trace, debug, info, warn, error 54 logLevel = "info"; # Options: trace, debug, info, warn, error
49 }; 55 };
50 56
51 # Caddy reverse proxy (unchanged from current setup) 57 # Caddy reverse proxy for production instance
52 services.caddy.virtualHosts."ngit.danconwaydev.com" = { 58 services.caddy.virtualHosts."ngit.danconwaydev.com" = {
53 extraConfig = '' 59 extraConfig = ''
54 reverse_proxy 127.0.0.1:8082 { 60 reverse_proxy 127.0.0.1:8082 {
@@ -57,4 +63,73 @@
57 } 63 }
58 ''; 64 '';
59 }; 65 };
66
67 # ============================================================================
68 # EXAMPLE 2: Multiple Instances on Same Server
69 # ============================================================================
70
71 # Uncomment to run multiple instances:
72
73 # # Production instance
74 # services.ngit-grasp.prod = {
75 # enable = true;
76 # domain = "ngit.example.com";
77 # port = 8082;
78 # dataDir = "/persistent/ngit-production";
79 # relayName = "Production GRASP Relay";
80 # syncBootstrapRelayUrl = "wss://relay.ngit.dev";
81 # logLevel = "info";
82 # };
83 #
84 # # Testing/staging instance
85 # services.ngit-grasp.staging = {
86 # enable = true;
87 # domain = "ngit-staging.example.com";
88 # port = 8083;
89 # dataDir = "/persistent/ngit-staging";
90 # relayName = "Staging GRASP Relay";
91 # syncBootstrapRelayUrl = "wss://relay.ngit.dev";
92 # logLevel = "debug"; # More verbose logging for testing
93 # };
94 #
95 # # Development instance with in-memory database
96 # services.ngit-grasp.dev = {
97 # enable = true;
98 # domain = "localhost";
99 # bindAddress = "127.0.0.1";
100 # port = 8084;
101 # dataDir = "/tmp/ngit-dev";
102 # databaseBackend = "memory"; # No persistence
103 # relayName = "Development GRASP Relay";
104 # metricsEnabled = false;
105 # logLevel = "trace"; # Maximum verbosity for debugging
106 # };
107 #
108 # # Caddy configuration for multiple instances
109 # services.caddy.virtualHosts = {
110 # "ngit.example.com" = {
111 # extraConfig = "reverse_proxy 127.0.0.1:8082";
112 # };
113 # "ngit-staging.example.com" = {
114 # extraConfig = "reverse_proxy 127.0.0.1:8083";
115 # };
116 # };
117
118 # ============================================================================
119 # NOTES
120 # ============================================================================
121
122 # Instance names (e.g., "production", "prod", "staging") can be anything.
123 # They are used for:
124 # - systemd service names: ngit-grasp-<name>
125 # - default user names: ngit-grasp-<name>
126 # - default data directories: /var/lib/ngit-grasp-<name>
127
128 # Systemd service management:
129 # systemctl status ngit-grasp-production
130 # systemctl restart ngit-grasp-staging
131 # journalctl -u ngit-grasp-prod -f
132
133 # Each instance runs as a separate user but shares the same group by default.
134 # You can customize user/group per instance if needed.
60} 135}