summaryrefslogtreecommitdiffstats
path: root/krebs/3modules
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/3modules')
-rw-r--r--krebs/3modules/external/palo.nix6
-rw-r--r--krebs/3modules/github-hosts-sync.nix28
-rw-r--r--krebs/3modules/github-known-hosts.nix10
-rw-r--r--krebs/3modules/lass/default.nix1
-rw-r--r--krebs/3modules/syncthing.nix39
5 files changed, 61 insertions, 23 deletions
diff --git a/krebs/3modules/external/palo.nix b/krebs/3modules/external/palo.nix
index cefac0959..05808714c 100644
--- a/krebs/3modules/external/palo.nix
+++ b/krebs/3modules/external/palo.nix
@@ -34,7 +34,10 @@ in {
retiolum = {
ip4.addr = "10.243.23.3";
tinc.port = 720;
- aliases = [ "kruck.r" ];
+ aliases = [
+ "kruck.r"
+ "video.kruck.r"
+ ];
tinc.pubkey = tinc-for "palo";
};
};
@@ -49,6 +52,7 @@ in {
tinc.pubkey = tinc-for "palo";
};
};
+ syncthing.id = "FLY7DHI-TJLEQBJ-JZNC4YV-NBX53Z2-ZBRWADL-BKSFXYZ-L4FMDVH-MOSEVAQ";
};
workhorse = {
owner = config.krebs.users.palo;
diff --git a/krebs/3modules/github-hosts-sync.nix b/krebs/3modules/github-hosts-sync.nix
index 3b626dc46..0b7d56098 100644
--- a/krebs/3modules/github-hosts-sync.nix
+++ b/krebs/3modules/github-hosts-sync.nix
@@ -11,17 +11,25 @@ let
api = {
enable = mkEnableOption "krebs.github-hosts-sync";
- port = mkOption {
- type = types.int; # TODO port type
- default = 1028;
- };
dataDir = mkOption {
type = types.str; # TODO path (but not just into store)
default = "/var/lib/github-hosts-sync";
};
+ srcDir = mkOption {
+ type = types.str;
+ default = "${config.krebs.tinc.retiolum.confDir}/hosts";
+ };
ssh-identity-file = mkOption {
type = types.suffixed-str [".ssh.id_ed25519" ".ssh.id_rsa"];
- default = toString <secrets/github-hosts-sync.ssh.id_rsa>;
+ default = toString <secrets/github-hosts-sync.ssh.id_ed25519>;
+ };
+ url = mkOption {
+ type = types.str;
+ default = "git@github.com:krebs/hosts.git";
+ };
+ workTree = mkOption {
+ type = types.absolute-pathname;
+ default = "${cfg.dataDir}/cache";
};
};
@@ -30,13 +38,18 @@ let
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
environment = {
- port = toString cfg.port;
+ GITHUB_HOST_SYNC_USER_MAIL = user.mail;
+ GITHUB_HOST_SYNC_USER_NAME = user.name;
+ GITHUB_HOST_SYNC_SRCDIR = cfg.srcDir;
+ GITHUB_HOST_SYNC_WORKTREE = cfg.workTree;
+ GITHUB_HOST_SYNC_URL = cfg.url;
};
serviceConfig = {
PermissionsStartOnly = "true";
SyslogIdentifier = "github-hosts-sync";
User = user.name;
- Restart = "always";
+ Type = "oneshot";
+ RemainAfterExit = true;
ExecStartPre = pkgs.writeDash "github-hosts-sync-init" ''
set -euf
install -m 0711 -o ${user.name} -d ${cfg.dataDir}
@@ -56,6 +69,7 @@ let
};
user = rec {
+ mail = "${name}@${config.krebs.build.host.name}";
name = "github-hosts-sync";
uid = genid_uint31 name;
};
diff --git a/krebs/3modules/github-known-hosts.nix b/krebs/3modules/github-known-hosts.nix
index def06f17a..bae8b96bf 100644
--- a/krebs/3modules/github-known-hosts.nix
+++ b/krebs/3modules/github-known-hosts.nix
@@ -28,12 +28,22 @@
"140.82.125.*"
"140.82.126.*"
"140.82.127.*"
+ "13.114.40.48"
"13.229.188.59"
+ "13.234.176.102"
+ "13.234.210.38"
+ "13.236.229.21"
+ "13.237.44.5"
"13.250.177.223"
+ "15.164.81.167"
"18.194.104.89"
"18.195.85.27"
"35.159.8.160"
+ "52.192.72.89"
+ "52.64.108.95"
+ "52.69.186.44"
"52.74.223.119"
+ "52.78.231.108"
];
publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
};
diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix
index 41f3852b9..f4c8f5c6a 100644
--- a/krebs/3modules/lass/default.nix
+++ b/krebs/3modules/lass/default.nix
@@ -35,6 +35,7 @@ in {
default._domainkey 60 IN TXT "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUv3DMndFellqu208feABEzT/PskOfTSdJCOF/HELBR0PHnbBeRoeHEm9XAcOe/Mz2t/ysgZ6JFXeFxCtoM5fG20brUMRzsVRxb9Ur5cEvOYuuRrbChYcKa+fopu8pYrlrqXD3miHISoy6ErukIYCRpXWUJHi1TlNQhLWFYqAaywIDAQAB"
cache 60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr}
cgit 60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr}
+ codi 60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr}
go 60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr}
io 60 IN NS ions.lassul.us.
ions 60 IN A ${config.krebs.hosts.prism.nets.internet.ip4.addr}
diff --git a/krebs/3modules/syncthing.nix b/krebs/3modules/syncthing.nix
index 897ba1e7f..9c6acfb0c 100644
--- a/krebs/3modules/syncthing.nix
+++ b/krebs/3modules/syncthing.nix
@@ -22,7 +22,7 @@ let
getApiKey = pkgs.writeDash "getAPIKey" ''
${pkgs.libxml2}/bin/xmllint \
--xpath 'string(configuration/gui/apikey)'\
- ${config.services.syncthing.dataDir}/config.xml
+ ${config.services.syncthing.configDir}/config.xml
'';
updateConfig = pkgs.writeDash "merge-syncthing-config" ''
@@ -31,9 +31,9 @@ let
${pkgs.untilport}/bin/untilport localhost 8384
API_KEY=$(${getApiKey})
CFG=$(${pkgs.curl}/bin/curl -Ss -H "X-API-Key: $API_KEY" localhost:8384/rest/system/config)
- echo "$CFG" | ${pkgs.jq}/bin/jq -s '.[] * {
- "devices": ${builtins.toJSON devices},
- "folders": ${builtins.toJSON folders}
+ echo "$CFG" | ${pkgs.jq}/bin/jq -s '.[] as $in | $in * {
+ "devices": (${builtins.toJSON devices}${optionalString (! cfg.overridePeers) " + $in.devices"}),
+ "folders": (${builtins.toJSON folders}${optionalString (! cfg.overrideFolders) " + $in.folders"})
}' | ${pkgs.curl}/bin/curl -Ss -H "X-API-Key: $API_KEY" localhost:8384/rest/system/config -d @-
${pkgs.curl}/bin/curl -Ss -H "X-API-Key: $API_KEY" localhost:8384/rest/system/restart -X POST
'';
@@ -45,11 +45,6 @@ in
enable = mkEnableOption "syncthing-init";
- id = mkOption {
- type = types.str;
- default = config.krebs.build.host.name;
- };
-
cert = mkOption {
type = types.nullOr types.absolute-pathname;
default = null;
@@ -60,6 +55,13 @@ in
default = null;
};
+ overridePeers = mkOption {
+ type = types.bool;
+ default = true;
+ description = ''
+ Whether to delete the peers which are not configured via the peers option
+ '';
+ };
peers = mkOption {
default = {};
type = types.attrsOf (types.submodule ({
@@ -80,6 +82,13 @@ in
}));
};
+ overrideFolders = mkOption {
+ type = types.bool;
+ default = true;
+ description = ''
+ Whether to delete the folders which are not configured via the peers option
+ '';
+ };
folders = mkOption {
default = {};
type = types.attrsOf (types.submodule ({ config, ... }: {
@@ -135,14 +144,14 @@ in
systemd.services.syncthing = mkIf (cfg.cert != null || cfg.key != null) {
preStart = ''
${optionalString (cfg.cert != null) ''
- cp ${toString cfg.cert} ${config.services.syncthing.dataDir}/cert.pem
- chown ${config.services.syncthing.user}:${config.services.syncthing.group} ${config.services.syncthing.dataDir}/cert.pem
- chmod 400 ${config.services.syncthing.dataDir}/cert.pem
+ cp ${toString cfg.cert} ${config.services.syncthing.configDir}/cert.pem
+ chown ${config.services.syncthing.user}:${config.services.syncthing.group} ${config.services.syncthing.configDir}/cert.pem
+ chmod 400 ${config.services.syncthing.configDir}/cert.pem
''}
${optionalString (cfg.key != null) ''
- cp ${toString cfg.key} ${config.services.syncthing.dataDir}/key.pem
- chown ${config.services.syncthing.user}:${config.services.syncthing.group} ${config.services.syncthing.dataDir}/key.pem
- chmod 400 ${config.services.syncthing.dataDir}/key.pem
+ cp ${toString cfg.key} ${config.services.syncthing.configDir}/key.pem
+ chown ${config.services.syncthing.user}:${config.services.syncthing.group} ${config.services.syncthing.configDir}/key.pem
+ chmod 400 ${config.services.syncthing.configDir}/key.pem
''}
'';
};