summaryrefslogtreecommitdiff
path: root/custom/uucp.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2017-03-31 17:04:11 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2017-03-31 17:04:11 +0200
commit2ef74e42fd443a03c35d450b1316a98479fef4c3 (patch)
treea04eea24a6224e9bc3f56510b5b399ee044dcb10 /custom/uucp.nix
parent305303b97a40e1962ab355f6ce3c9a9bb1c9cab4 (diff)
downloadnixos-2ef74e42fd443a03c35d450b1316a98479fef4c3.tar
nixos-2ef74e42fd443a03c35d450b1316a98479fef4c3.tar.gz
nixos-2ef74e42fd443a03c35d450b1316a98479fef4c3.tar.bz2
nixos-2ef74e42fd443a03c35d450b1316a98479fef4c3.tar.xz
nixos-2ef74e42fd443a03c35d450b1316a98479fef4c3.zip
Call all uucp hosts on network up
Diffstat (limited to 'custom/uucp.nix')
-rw-r--r--custom/uucp.nix76
1 files changed, 48 insertions, 28 deletions
diff --git a/custom/uucp.nix b/custom/uucp.nix
index 0b4b1306..822aa92f 100644
--- a/custom/uucp.nix
+++ b/custom/uucp.nix
@@ -6,7 +6,7 @@ let
6 portSpec = name: '' 6 portSpec = name: ''
7 port ${name} 7 port ${name}
8 type pipe 8 type pipe
9 protocol ${if builtins.hasAttr name config.services.uucp.protocols then config.services.uucp.protocols."${name}" else config.services.uucp.defaultProtocol} 9 protocol ${if builtins.hasAttr name cfg.protocols then cfg.protocols."${name}" else cfg.defaultProtocol}
10 reliable true 10 reliable true
11 command ${pkgs.openssh}/bin/ssh -x -o batchmode=yes ${name} 11 command ${pkgs.openssh}/bin/ssh -x -o batchmode=yes ${name}
12 ''; 12 '';
@@ -15,10 +15,12 @@ let
15 time Any 15 time Any
16 port ${name} 16 port ${name}
17 chat "" 17 chat ""
18 protocol ${if builtins.hasAttr name config.services.uucp.protocols then config.services.uucp.protocols."${name}" else config.services.uucp.defaultProtocol} 18 protocol ${if builtins.hasAttr name cfg.protocols then cfg.protocols."${name}" else cfg.defaultProtocol}
19 command-path ${concatStringsSep " " config.services.uucp.commandPath} 19 command-path ${concatStringsSep " " cfg.commandPath}
20 commands ${concatStringsSep " " (if builtins.hasAttr name config.services.uucp.commands then config.services.uucp.commands."${name}" else config.services.uucp.defaultCommands)} 20 commands ${concatStringsSep " " (if builtins.hasAttr name cfg.commands then cfg.commands."${name}" else cfg.defaultCommands)}
21 ''; 21 '';
22
23 cfg = config.services.uucp;
22in { 24in {
23 options = { 25 options = {
24 services.uucp = { 26 services.uucp = {
@@ -134,6 +136,15 @@ in {
134 ''; 136 '';
135 }; 137 };
136 138
139 nmDispatch = mkOption {
140 type = config.networking.networkmanager.enable;
141 default = false;
142 description = ''
143 Install a network-manager dispatcher script to automatically
144 call all remotes when networking is available
145 '';
146 };
147
137 extraConfig = mkOption { 148 extraConfig = mkOption {
138 type = types.string; 149 type = types.string;
139 default = '' 150 default = ''
@@ -152,19 +163,19 @@ in {
152 }; 163 };
153 }; 164 };
154 165
155 config = mkIf config.services.uucp.enable { 166 config = mkIf cfg.enable {
156 environment.etc."uucp/config" = { 167 environment.etc."uucp/config" = {
157 text = '' 168 text = ''
158 hostname ${config.services.uucp.nodeName} 169 hostname ${cfg.nodeName}
159 170
160 spool ${config.services.uucp.spoolDir} 171 spool ${cfg.spoolDir}
161 lockdir ${config.services.uucp.lockDir} 172 lockdir ${cfg.lockDir}
162 pubdir ${config.services.uucp.pubDir} 173 pubdir ${cfg.pubDir}
163 logfile ${config.services.uucp.logFile} 174 logfile ${cfg.logFile}
164 statfile ${config.services.uucp.statFile} 175 statfile ${cfg.statFile}
165 debugfile ${config.services.uucp.debugFile} 176 debugfile ${cfg.debugFile}
166 177
167 ${config.services.uucp.extraConfig} 178 ${cfg.extraConfig}
168 ''; 179 '';
169 }; 180 };
170 181
@@ -173,28 +184,28 @@ in {
173 isSystemUser = true; 184 isSystemUser = true;
174 isNormalUser = false; 185 isNormalUser = false;
175 createHome = true; 186 createHome = true;
176 home = config.services.uucp.spoolDir; 187 home = cfg.spoolDir;
177 description = "User for uucp over ssh"; 188 description = "User for uucp over ssh";
178 useDefaultShell = true; 189 useDefaultShell = true;
179 } // config.services.uucp.sshUser; 190 } // cfg.sshUser;
180 191
181 system.activationScripts."uucp-sshconfig" = '' 192 system.activationScripts."uucp-sshconfig" = ''
182 mkdir -p ${config.users.users."uucp".home}/.ssh 193 mkdir -p ${config.users.users."uucp".home}/.ssh
183 chown ${config.users.users."uucp".name}:${config.users.users."uucp".group} ${config.users.users."uucp".home}/.ssh 194 chown ${config.users.users."uucp".name}:${config.users.users."uucp".group} ${config.users.users."uucp".home}/.ssh
184 chmod 700 ${config.users.users."uucp".home}/.ssh 195 chmod 700 ${config.users.users."uucp".home}/.ssh
185 ln -fs ${builtins.toFile "ssh-config" config.services.uucp.sshConfig} ${config.users.users."uucp".home}/.ssh/config 196 ln -fs ${builtins.toFile "ssh-config" cfg.sshConfig} ${config.users.users."uucp".home}/.ssh/config
186 ''; 197 '';
187 198
188 system.activationScripts."uucp-logs" = '' 199 system.activationScripts."uucp-logs" = ''
189 touch ${config.services.uucp.logFile} 200 touch ${cfg.logFile}
190 chown ${config.users.users."uucp".name}:${config.users.users."uucp".group} ${config.services.uucp.logFile} 201 chown ${config.users.users."uucp".name}:${config.users.users."uucp".group} ${cfg.logFile}
191 chmod 644 ${config.services.uucp.logFile} 202 chmod 644 ${cfg.logFile}
192 touch ${config.services.uucp.statFile} 203 touch ${cfg.statFile}
193 chown ${config.users.users."uucp".name}:${config.users.users."uucp".group} ${config.services.uucp.statFile} 204 chown ${config.users.users."uucp".name}:${config.users.users."uucp".group} ${cfg.statFile}
194 chmod 644 ${config.services.uucp.statFile} 205 chmod 644 ${cfg.statFile}
195 touch ${config.services.uucp.debugFile} 206 touch ${cfg.debugFile}
196 chown ${config.users.users."uucp".name}:${config.users.users."uucp".group} ${config.services.uucp.debugFile} 207 chown ${config.users.users."uucp".name}:${config.users.users."uucp".group} ${cfg.debugFile}
197 chmod 644 ${config.services.uucp.debugFile} 208 chmod 644 ${cfg.debugFile}
198 ''; 209 '';
199 210
200 environment.etc."uucp/port" = { 211 environment.etc."uucp/port" = {
@@ -202,10 +213,10 @@ in {
202 port ssh 213 port ssh
203 type stdin 214 type stdin
204 protocol e 215 protocol e
205 '' + concatStringsSep "\n" (map portSpec config.services.uucp.remoteNodes); 216 '' + concatStringsSep "\n" (map portSpec cfg.remoteNodes);
206 }; 217 };
207 environment.etc."uucp/sys" = { 218 environment.etc."uucp/sys" = {
208 text = config.services.uucp.extraSys + "\n" + concatStringsSep "\n" (map sysSpec config.services.uucp.remoteNodes); 219 text = cfg.extraSys + "\n" + concatStringsSep "\n" (map sysSpec cfg.remoteNodes);
209 }; 220 };
210 221
211 security.wrappers = let 222 security.wrappers = let
@@ -264,6 +275,15 @@ in {
264 uucp 275 uucp
265 ]; 276 ];
266 277
267 services.cron.systemCronJobs = (map (name: "${config.services.uucp.interval} ${config.security.wrapperDir}/uucico -D -S ${name}") (if (config.services.uucp.interval != null) then config.services.uucp.remoteNodes else [])); 278 services.cron.systemCronJobs = (map (name: "${cfg.interval} ${config.security.wrapperDir}/uucico -D -S ${name}") (if (cfg.interval != null) then cfg.remoteNodes else []));
279
280 networking.networkmanager.dispatcherScripts = optional cfg.nmDispatch {
281 type = "basic";
282 source = ''
283 #!${pkgs.stdenv.shell}
284
285 ${map (name: "${config.security.wrapperDir}/uucico -D -S ${name}") cfg.remoteNodes}
286 '';
287 };
268 }; 288 };
269} 289}