Skip to content

Feat/support more options #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
987 changes: 36 additions & 951 deletions flake.lock

Large diffs are not rendered by default.

44 changes: 12 additions & 32 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,28 @@
url = "github:holochain/holonix?ref=main-0.3";
};

tryorama-0_3 = {
url = "github:holochain/tryorama?ref=main-0.3";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};

holonix-0_4 = {
url = "github:holochain/holonix?ref=main-0.4";
inputs = {
holochain.url = "github:holochain/holochain?ref=holochain-0.4.1";
};
};

tryorama-0_4 = {
url = "github:holochain/tryorama?ref=main-0.4";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};

holonix-0_5 = {
url = "github:holochain/holonix?ref=main";
inputs = {
holochain.url = "github:holochain/holochain?ref=holochain-0.5.0-dev.18";
};
};

tryorama-0_5 = {
url = "github:holochain/tryorama?ref=main";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};

outputs = inputs @ {
self,
nixpkgs,
flake-parts,
holonix-0_3,
tryorama-0_3,
holonix-0_4,
tryorama-0_4,
holonix-0_5,
tryorama-0_5,
...
}:
flake-parts.lib.mkFlake {inherit inputs;} ({withSystem, ...}: {
Expand All @@ -65,11 +41,6 @@
isSystemUser = true;
group = "holochain";
};

users.users.trycp = {
isSystemUser = true;
group = "holochain";
};
};
conductor-0_3 = {pkgs, ...}: {
imports = [./modules/conductor-0_3.nix];
Expand All @@ -89,9 +60,6 @@
lair-keystore-for-0_5 = {pkgs, ...}: {
imports = [./modules/lair-keystore-for-0_5.nix];
};
trycp-server = {pkgs, ...}: {
imports = [./modules/trycp-server.nix];
};
};

nixosConfigurations = let
Expand Down Expand Up @@ -290,14 +258,26 @@
inherit self system;
holonix = holonix-0_3;
});
holochain-0_3-with-in-proc-lair = pkgs.testers.runNixOSTest (import ./tests/holochain-0_3-with-in-proc-lair.nix {
inherit self system;
holonix = holonix-0_3;
});
holochain-0_4-with-lair = pkgs.testers.runNixOSTest (import ./tests/holochain-0_4-with-lair.nix {
inherit self system;
holonix = holonix-0_4;
});
holochain-0_4-with-in-proc-lair = pkgs.testers.runNixOSTest (import ./tests/holochain-0_4-with-in-proc-lair.nix {
inherit self system;
holonix = holonix-0_4;
});
holochain-0_5-with-lair = pkgs.testers.runNixOSTest (import ./tests/holochain-0_5-with-lair.nix {
inherit self system;
holonix = holonix-0_5;
});
holochain-0_5-with-in-proc-lair = pkgs.testers.runNixOSTest (import ./tests/holochain-0_5-with-in-proc-lair.nix {
inherit self system;
holonix = holonix-0_5;
});
holochain-and-lair-side-by-side = pkgs.testers.runNixOSTest (import ./tests/holochain-and-lair-side-by-side.nix {
inherit self system;
holonix-0_3 = holonix-0_3;
Expand Down
56 changes: 43 additions & 13 deletions modules/conductor-0_3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
with lib; let
# The input config for this service
cfg = config.services.conductor-0_3;

keystore_type = (cfg.config.keystore or {}).type or "lair_server";
in {
options.services.conductor-0_3 = {
enable = mkEnableOption "Holochain conductor";
Expand Down Expand Up @@ -40,11 +42,26 @@ in {
config = mkIf cfg.enable {
systemd.services.conductor-0_3 = {
wantedBy = ["multi-user.target"]; # Start on boot
after = [
"network.target"
"lair-keystore-for-0_3.service"
]; # Waits for network and lair started
bindsTo = ["lair-keystore-for-0_3.service"]; # Requires Lair, stop if Lair stops
after =
[
# Wait for the network to be ready before starting this service
"network.target"
]
++ (
if keystore_type == "lair_server"
then [
# When Lair is running as a separate service, wait for it to start
"lair-keystore-for-0_3.service"
]
else []
);
bindsTo =
if keystore_type == "lair_server"
then [
# When Lair us running as a separate service, require Lair to be running, stop if Lair stops
"lair-keystore-for-0_3.service"
]
else [];
description = "Holochain conductor: ${cfg.id}";
path = [cfg.package pkgs.yq];
restartIfChanged = true;
Expand All @@ -56,10 +73,15 @@ in {
};

# TODO should be able to pass this to Holochain as an arg rather than needing to modify the file
preStart = ''
lair_connection_url=$(yq -r .connectionUrl /var/lib/lair-${cfg.lairId}/lair-keystore-config.yaml)
yq -y "(.keystore.connection_url) = \"$lair_connection_url\"" /etc/holochain-${cfg.id}/conductor.yaml > /var/lib/conductor-${cfg.id}/conductor.yaml
'';
preStart =
if keystore_type == "lair_server"
then ''
lair_connection_url=$(yq -r .connectionUrl /var/lib/lair-${cfg.lairId}/lair-keystore-config.yaml)
yq -y "(.keystore.connection_url) = \"$lair_connection_url\"" /etc/holochain-${cfg.id}/conductor.yaml > /var/lib/conductor-${cfg.id}/conductor.yaml
''
else ''
cp /etc/holochain-${cfg.id}/conductor.yaml /var/lib/conductor-${cfg.id}/conductor.yaml
'';

script = ''
echo -n "${cfg.keystorePassphrase}" | holochain -c /var/lib/conductor-${cfg.id}/conductor.yaml --piped
Expand Down Expand Up @@ -100,10 +122,18 @@ in {
];
tuning_params = {gossip_strategy = "sharded-gossip";};
};
keystore =
{
type = keystore_type;
}
// (
if keystore_type == "lair_server_in_proc"
then {
lair_root = "/var/lib/conductor-${cfg.id}/keystore/";
}
else {}
);
}
// cfg.config
// {
keystore.type = "lair_server";
});
// cfg.config);
};
}
56 changes: 43 additions & 13 deletions modules/conductor-0_4.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
with lib; let
# The input config for this service
cfg = config.services.conductor-0_4;

keystore_type = (cfg.config.keystore or {}).type or "lair_server";
in {
options.services.conductor-0_4 = {
enable = mkEnableOption "Holochain conductor";
Expand Down Expand Up @@ -40,11 +42,26 @@ in {
config = mkIf cfg.enable {
systemd.services.conductor-0_4 = {
wantedBy = ["multi-user.target"]; # Start on boot
after = [
"network.target"
"lair-keystore-for-0_4.service"
]; # Waits for network and lair started
bindsTo = ["lair-keystore-for-0_4.service"]; # Requires Lair, stop if Lair stops
after =
[
# Wait for the network to be ready before starting this service
"network.target"
]
++ (
if keystore_type == "lair_server"
then [
# When Lair is running as a separate service, wait for it to start
"lair-keystore-for-0_4.service"
]
else []
);
bindsTo =
if keystore_type == "lair_server"
then [
# When Lair us running as a separate service, require Lair to be running, stop if Lair stops
"lair-keystore-for-0_4.service"
]
else [];
description = "Holochain conductor";
path = [cfg.package pkgs.yq];
restartIfChanged = true;
Expand All @@ -56,10 +73,15 @@ in {
};

# TODO should be able to pass this to Holochain as an arg rather than needing to modify the file
preStart = ''
lair_connection_url=$(yq -r .connectionUrl /var/lib/lair-${cfg.lairId}/lair-keystore-config.yaml)
yq -y "(.keystore.connection_url) = \"$lair_connection_url\"" /etc/holochain-${cfg.id}/conductor.yaml > /var/lib/conductor-${cfg.id}/conductor.yaml
'';
preStart =
if keystore_type == "lair_server"
then ''
lair_connection_url=$(yq -r .connectionUrl /var/lib/lair-${cfg.lairId}/lair-keystore-config.yaml)
yq -y "(.keystore.connection_url) = \"$lair_connection_url\"" /etc/holochain-${cfg.id}/conductor.yaml > /var/lib/conductor-${cfg.id}/conductor.yaml
''
else ''
cp /etc/holochain-${cfg.id}/conductor.yaml /var/lib/conductor-${cfg.id}/conductor.yaml
'';

script = ''
echo -n "${cfg.keystorePassphrase}" | holochain -c /var/lib/conductor-${cfg.id}/conductor.yaml --piped
Expand Down Expand Up @@ -107,10 +129,18 @@ in {
no_dpki = true;
network_seed = "deepkey-main";
};
keystore =
{
type = keystore_type;
}
// (
if keystore_type == "lair_server_in_proc"
then {
lair_root = "/var/lib/conductor-${cfg.id}/keystore/";
}
else {}
);
}
// cfg.config
// {
keystore.type = "lair_server";
});
// cfg.config);
};
}
56 changes: 43 additions & 13 deletions modules/conductor-0_5.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
with lib; let
# The input config for this service
cfg = config.services.conductor-0_5;

keystore_type = (cfg.config.keystore or {}).type or "lair_server";
in {
options.services.conductor-0_5 = {
enable = mkEnableOption "Holochain conductor";
Expand Down Expand Up @@ -40,11 +42,26 @@ in {
config = mkIf cfg.enable {
systemd.services.conductor-0_5 = {
wantedBy = ["multi-user.target"]; # Start on boot
after = [
"network.target"
"lair-keystore-for-0_5.service"
]; # Waits for network and lair started
bindsTo = ["lair-keystore-for-0_5.service"]; # Requires Lair, stop if Lair stops
after =
[
# Wait for the network to be ready before starting this service
"network.target"
]
++ (
if keystore_type == "lair_server"
then [
# When Lair is running as a separate service, wait for it to start
"lair-keystore-for-0_5.service"
]
else []
);
bindsTo =
if keystore_type == "lair_server"
then [
# When Lair us running as a separate service, require Lair to be running, stop if Lair stops
"lair-keystore-for-0_5.service"
]
else [];
description = "Holochain conductor";
path = [cfg.package pkgs.yq];
restartIfChanged = true;
Expand All @@ -56,10 +73,15 @@ in {
};

# TODO should be able to pass this to Holochain as an arg rather than needing to modify the file
preStart = ''
lair_connection_url=$(yq -r .connectionUrl /var/lib/lair-${cfg.lairId}/lair-keystore-config.yaml)
yq -y "(.keystore.connection_url) = \"$lair_connection_url\"" /etc/holochain-${cfg.id}/conductor.yaml > /var/lib/conductor-${cfg.id}/conductor.yaml
'';
preStart =
if keystore_type == "lair_server"
then ''
lair_connection_url=$(yq -r .connectionUrl /var/lib/lair-${cfg.lairId}/lair-keystore-config.yaml)
yq -y "(.keystore.connection_url) = \"$lair_connection_url\"" /etc/holochain-${cfg.id}/conductor.yaml > /var/lib/conductor-${cfg.id}/conductor.yaml
''
else ''
cp /etc/holochain-${cfg.id}/conductor.yaml /var/lib/conductor-${cfg.id}/conductor.yaml
'';

script = ''
echo -n "${cfg.keystorePassphrase}" | holochain -c /var/lib/conductor-${cfg.id}/conductor.yaml --piped
Expand Down Expand Up @@ -107,10 +129,18 @@ in {
no_dpki = true;
network_seed = "deepkey-main";
};
keystore =
{
type = keystore_type;
}
// (
if keystore_type == "lair_server_in_proc"
then {
lair_root = "/var/lib/conductor-${cfg.id}/keystore/";
}
else {}
);
}
// cfg.config
// {
keystore.type = "lair_server";
});
// cfg.config);
};
}
44 changes: 0 additions & 44 deletions modules/trycp-server.nix

This file was deleted.

Loading