|
7 | 7 | with lib; let
|
8 | 8 | # The input config for this service
|
9 | 9 | cfg = config.services.conductor-0_3;
|
| 10 | + |
| 11 | + keystore_type = (cfg.config.keystore or {}).type or "lair_server"; |
10 | 12 | in {
|
11 | 13 | options.services.conductor-0_3 = {
|
12 | 14 | enable = mkEnableOption "Holochain conductor";
|
|
40 | 42 | config = mkIf cfg.enable {
|
41 | 43 | systemd.services.conductor-0_3 = {
|
42 | 44 | wantedBy = ["multi-user.target"]; # Start on boot
|
43 |
| - after = [ |
44 |
| - "network.target" |
45 |
| - "lair-keystore-for-0_3.service" |
46 |
| - ]; # Waits for network and lair started |
47 |
| - bindsTo = ["lair-keystore-for-0_3.service"]; # Requires Lair, stop if Lair stops |
| 45 | + after = |
| 46 | + [ |
| 47 | + # Wait for the network to be ready before starting this service |
| 48 | + "network.target" |
| 49 | + ] |
| 50 | + ++ ( |
| 51 | + if keystore_type == "lair_server" |
| 52 | + then [ |
| 53 | + # When Lair is running as a separate service, wait for it to start |
| 54 | + "lair-keystore-for-0_3.service" |
| 55 | + ] |
| 56 | + else [] |
| 57 | + ); |
| 58 | + bindsTo = |
| 59 | + if keystore_type == "lair_server" |
| 60 | + then [ |
| 61 | + # When Lair us running as a separate service, require Lair to be running, stop if Lair stops |
| 62 | + "lair-keystore-for-0_3.service" |
| 63 | + ] |
| 64 | + else []; |
48 | 65 | description = "Holochain conductor: ${cfg.id}";
|
49 | 66 | path = [cfg.package pkgs.yq];
|
50 | 67 | restartIfChanged = true;
|
|
56 | 73 | };
|
57 | 74 |
|
58 | 75 | # TODO should be able to pass this to Holochain as an arg rather than needing to modify the file
|
59 |
| - preStart = '' |
60 |
| - lair_connection_url=$(yq -r .connectionUrl /var/lib/lair-${cfg.lairId}/lair-keystore-config.yaml) |
61 |
| - yq -y "(.keystore.connection_url) = \"$lair_connection_url\"" /etc/holochain-${cfg.id}/conductor.yaml > /var/lib/conductor-${cfg.id}/conductor.yaml |
62 |
| - ''; |
| 76 | + preStart = |
| 77 | + if keystore_type == "lair_server" |
| 78 | + then '' |
| 79 | + lair_connection_url=$(yq -r .connectionUrl /var/lib/lair-${cfg.lairId}/lair-keystore-config.yaml) |
| 80 | + yq -y "(.keystore.connection_url) = \"$lair_connection_url\"" /etc/holochain-${cfg.id}/conductor.yaml > /var/lib/conductor-${cfg.id}/conductor.yaml |
| 81 | + '' |
| 82 | + else '' |
| 83 | + cp /etc/holochain-${cfg.id}/conductor.yaml /var/lib/conductor-${cfg.id}/conductor.yaml |
| 84 | + ''; |
63 | 85 |
|
64 | 86 | script = ''
|
65 | 87 | echo -n "${cfg.keystorePassphrase}" | holochain -c /var/lib/conductor-${cfg.id}/conductor.yaml --piped
|
@@ -100,10 +122,18 @@ in {
|
100 | 122 | ];
|
101 | 123 | tuning_params = {gossip_strategy = "sharded-gossip";};
|
102 | 124 | };
|
| 125 | + keystore = |
| 126 | + { |
| 127 | + type = keystore_type; |
| 128 | + } |
| 129 | + // ( |
| 130 | + if keystore_type == "lair_server_in_proc" |
| 131 | + then { |
| 132 | + lair_root = "/var/lib/conductor-${cfg.id}/keystore/"; |
| 133 | + } |
| 134 | + else {} |
| 135 | + ); |
103 | 136 | }
|
104 |
| - // cfg.config |
105 |
| - // { |
106 |
| - keystore.type = "lair_server"; |
107 |
| - }); |
| 137 | + // cfg.config); |
108 | 138 | };
|
109 | 139 | }
|
0 commit comments