From 8ad501e21d8fbde5c8aa68274eb7dac3995df64f Mon Sep 17 00:00:00 2001 From: niten Date: Sat, 18 Dec 2021 12:12:09 -0800 Subject: [PATCH] Added chute --- lib/fudo/git.nix | 4 ++++ lib/fudo/ldap.nix | 10 +++++----- lib/fudo/postgres.nix | 1 + lib/informis/chute.nix | 12 +++++++++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/fudo/git.nix b/lib/fudo/git.nix index 4988645..09268dc 100644 --- a/lib/fudo/git.nix +++ b/lib/fudo/git.nix @@ -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; }; diff --git a/lib/fudo/ldap.nix b/lib/fudo/ldap.nix index b925ca2..5a93339 100644 --- a/lib/fudo/ldap.nix +++ b/lib/fudo/ldap.nix @@ -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 { diff --git a/lib/fudo/postgres.nix b/lib/fudo/postgres.nix index a3ea125..9aedfbd 100644 --- a/lib/fudo/postgres.nix +++ b/lib/fudo/postgres.nix @@ -305,6 +305,7 @@ in { targets.${strip-ext cfg.systemd-target} = { description = "Postgresql and associated systemd services."; + wantedBy = [ "multi-user.target" ]; }; services = { diff --git a/lib/informis/chute.nix b/lib/informis/chute.nix index e5d935d..087c92e 100644 --- a/lib/informis/chute.nix +++ b/lib/informis/chute.nix @@ -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."; + }; }; }