More principled initial peers
This commit is contained in:
17
flake.nix
17
flake.nix
@@ -40,10 +40,22 @@
|
||||
dir = lib.mkOption {
|
||||
description = "directory in which to place the listening socket";
|
||||
default = "${config.home.homeDirectory}/.ssh/frajtano";
|
||||
type = lib.types.path;
|
||||
};
|
||||
initialPeers = lib.mkOption {
|
||||
description = "initially spawned peers - will be passed to /usr/bin/env";
|
||||
type = with lib.types; listOf (listOf str);
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
config = let
|
||||
peers = lib.strings.concatMapStringsSep ", " (args: ''{:spawn, {"${pkgs.coreutils}/bin/env", [${lib.concatMapStringsSep ", " (s: ''~S{${s}}'') args}]}}'') cfg.initialPeers;
|
||||
configFile = pkgs.writeText "config.exs" ''
|
||||
import Config
|
||||
config :frajtano, initial_peers: [${peers}]
|
||||
'';
|
||||
in lib.mkIf cfg.enable {
|
||||
home.sessionVariables.FRAJTANO_DIR = cfg.dir;
|
||||
home.packages = [self.packages.${pkgs.system}.default];
|
||||
|
||||
@@ -51,7 +63,7 @@
|
||||
Unit.Description = "frajtano";
|
||||
Unit.After = ["default.target"];
|
||||
Service.Type = "notify";
|
||||
Service.Environment = ["'FRAJTANO_DIR=${cfg.dir}'"];
|
||||
Service.Environment = ["'FRAJTANO_DIR=${cfg.dir}'" "'FRAJTANO_CONFIG=${configFile}'"];
|
||||
Service.ExecSearchPath = ["${self.packages.${pkgs.system}.default}/bin"];
|
||||
Service.ExecStart = "frajtano start";
|
||||
Install.WantedBy = ["default.target"];
|
||||
@@ -62,6 +74,7 @@
|
||||
config = {
|
||||
EnvironmentVariables = {
|
||||
FRAJTANO_DIR = cfg.dir;
|
||||
FRAJTANO_CONFIG = configFile;
|
||||
};
|
||||
ProgramArguments = ["${self.packages.${pkgs.system}.default}/bin/frajtano" "start"];
|
||||
RunAtLoad = true;
|
||||
|
||||
Reference in New Issue
Block a user