Added chute

This commit is contained in:
niten 2021-12-18 12:12:09 -08:00
parent 3ae2c5ce8e
commit 8ad501e21d
4 changed files with 19 additions and 8 deletions

View File

@ -137,7 +137,11 @@ in {
};
settings = mkIf (cfg.ssh != null) {
server = {
# Displayed in the clone URL
SSH_DOMAIN = cfg.hostname;
SSH_PORT = mkForce cfg.ssh.listen-port;
# Actual ip/port on which to listen
SSH_LISTEN_PORT = cfg.ssh.listen-port;
SSH_LISTEN_HOST = cfg.ssh.listen-ip;
};

View File

@ -7,7 +7,7 @@ let
user-type = import ../types/user.nix { inherit lib; };
stringJoin = concatStringsSep;
join-lines = concatStringsSep "\n";
getUserGidNumber = user: group-map: group-map.${user.primary-group}.gid;
@ -57,7 +57,7 @@ let
'';
toMemberList = userList:
stringJoin "\n" (map (username: "memberUid: ${username}") userList);
join-lines (map (username: "memberUid: ${username}") userList);
groupLdif = base: name: opts: ''
dn: cn=${name},ou=groups,${base}
@ -69,15 +69,15 @@ let
'';
systemUsersLdif = base: user-map:
stringJoin "\n"
join-lines
(mapAttrsToList (name: opts: systemUserLdif base name opts) user-map);
groupsLdif = base: group-map:
stringJoin "\n"
join-lines
(mapAttrsToList (name: opts: groupLdif base name opts) group-map);
usersLdif = base: group-map: user-map:
stringJoin "\n"
join-lines
(mapAttrsToList (name: opts: userLdif base name group-map opts) user-map);
in {

View File

@ -305,6 +305,7 @@ in {
targets.${strip-ext cfg.systemd-target} = {
description = "Postgresql and associated systemd services.";
wantedBy = [ "multi-user.target" ];
};
services = {

View File

@ -5,7 +5,7 @@ let
cfg = config.informis.chute;
currencyOpts = { ... }: {
options = {
options = with types; {
stop-percentile = mkOption {
type = int;
description = "Percentile of observed max at which to sell.";
@ -50,9 +50,10 @@ let
description = "Chute ${stage} job for ${currency}";
path = [ package ];
environmentFile = credential-file;
execStart = "chute --currency=${currency} --stop-at-percent=${toString stop-at-percent}";
execStart = "${package}/bin/chute --currency=${currency} --stop-at-percent=${toString stop-at-percent}";
privateNetwork = false;
addressFamilies = [ "AF_INET" ];
memoryDenyWriteExecute = false; # Needed becuz Clojure
};
in {
@ -78,7 +79,7 @@ in {
config = mkIf (cfg.enable) {
fudo = {
system.services = concatMapAttrs (stage: stageOpts:
mapAttrs (currency: currencyOpts: {
concatMapAttrs (currency: currencyOpts: {
"chute-${stage}-${currency}" = chute-job-definition {
inherit stage currency;
credential-file = stageOpts.credential-file;
@ -87,5 +88,10 @@ in {
};
}) stageOpts.currencies) cfg.stages;
};
systemd.targets.chute = {
wantedBy = [ "multi-user.target" ];
description = "Chute cryptocurrency safety parachute.";
};
};
}