ipfs: nixpkgs-fmt

+56 -43
+56 -43
nixos/modules/services/network-filesystems/ipfs.nix
··· 5 5 opt = options.services.ipfs; 6 6 7 7 ipfsFlags = toString ([ 8 - (optionalString cfg.autoMount "--mount") 9 - (optionalString cfg.enableGC "--enable-gc") 10 - (optionalString (cfg.serviceFdlimit != null) "--manage-fdlimit=false") 11 - (optionalString (cfg.defaultMode == "offline") "--offline") 8 + (optionalString cfg.autoMount "--mount") 9 + (optionalString cfg.enableGC "--enable-gc") 10 + (optionalString (cfg.serviceFdlimit != null) "--manage-fdlimit=false") 11 + (optionalString (cfg.defaultMode == "offline") "--offline") 12 12 (optionalString (cfg.defaultMode == "norouting") "--routing=none") 13 13 ] ++ cfg.extraFlags); 14 14 15 15 splitMulitaddr = addrRaw: lib.tail (lib.splitString "/" addrRaw); 16 16 17 - multiaddrToListenStream = addrRaw: let 17 + multiaddrToListenStream = addrRaw: 18 + let 18 19 addr = splitMulitaddr addrRaw; 19 20 s = builtins.elemAt addr; 20 - in if s 0 == "ip4" && s 2 == "tcp" 21 - then "${s 1}:${s 3}" 21 + in 22 + if s 0 == "ip4" && s 2 == "tcp" 23 + then "${s 1}:${s 3}" 22 24 else if s 0 == "ip6" && s 2 == "tcp" 23 - then "[${s 1}]:${s 3}" 25 + then "[${s 1}]:${s 3}" 24 26 else if s 0 == "unix" 25 - then "/${lib.concatStringsSep "/" (lib.tail addr)}" 27 + then "/${lib.concatStringsSep "/" (lib.tail addr)}" 26 28 else null; # not valid for listen stream, skip 27 29 28 - multiaddrToListenDatagram = addrRaw: let 30 + multiaddrToListenDatagram = addrRaw: 31 + let 29 32 addr = splitMulitaddr addrRaw; 30 33 s = builtins.elemAt addr; 31 - in if s 0 == "ip4" && s 2 == "udp" 32 - then "${s 1}:${s 3}" 34 + in 35 + if s 0 == "ip4" && s 2 == "udp" 36 + then "${s 1}:${s 3}" 33 37 else if s 0 == "ip6" && s 2 == "udp" 34 - then "[${s 1}]:${s 3}" 38 + then "[${s 1}]:${s 3}" 35 39 else null; # not valid for listen datagram, skip 36 40 37 - in { 41 + in 42 + { 38 43 39 44 ###### interface 40 45 ··· 65 70 66 71 dataDir = mkOption { 67 72 type = types.str; 68 - default = if versionAtLeast config.system.stateVersion "17.09" 69 - then "/var/lib/ipfs" 70 - else "/var/lib/ipfs/.ipfs"; 73 + default = 74 + if versionAtLeast config.system.stateVersion "17.09" 75 + then "/var/lib/ipfs" 76 + else "/var/lib/ipfs/.ipfs"; 71 77 description = "The data dir for IPFS"; 72 78 }; 73 79 ··· 137 143 These are applied last, so may override configuration set by other options in this module. 138 144 Keep in mind that this configuration is stateful; i.e., unsetting anything in here does not reset the value to the default! 139 145 ''; 140 - default = {}; 146 + default = { }; 141 147 example = { 142 148 Datastore.StorageMax = "100GB"; 143 149 Discovery.MDNS.Enabled = false; ··· 153 159 extraFlags = mkOption { 154 160 type = types.listOf types.str; 155 161 description = "Extra flags passed to the IPFS daemon"; 156 - default = []; 162 + default = [ ]; 157 163 }; 158 164 159 165 localDiscovery = mkOption { ··· 168 174 type = types.nullOr types.int; 169 175 default = null; 170 176 description = "The fdlimit for the IPFS systemd unit or <literal>null</literal> to have the daemon attempt to manage it"; 171 - example = 64*1024; 177 + example = 64 * 1024; 172 178 }; 173 179 174 180 startWhenNeeded = mkOption { ··· 235 241 ipfs --offline config Mounts.IPFS ${cfg.ipfsMountDir} 236 242 ipfs --offline config Mounts.IPNS ${cfg.ipnsMountDir} 237 243 '' + concatStringsSep "\n" (collect 238 - isString 239 - (mapAttrsRecursive 240 - (path: value: 241 - # Using heredoc below so that the value is never improperly quoted 242 - '' 243 - read value <<EOF 244 - ${builtins.toJSON value} 245 - EOF 246 - ipfs --offline config --json "${concatStringsSep "." path}" "$value" 247 - '') 248 - ({ Addresses.API = cfg.apiAddress; 249 - Addresses.Gateway = cfg.gatewayAddress; 250 - Addresses.Swarm = cfg.swarmAddress; 251 - } // 252 - cfg.extraConfig)) 253 - ); 244 + isString 245 + (mapAttrsRecursive 246 + (path: value: 247 + # Using heredoc below so that the value is never improperly quoted 248 + '' 249 + read value <<EOF 250 + ${builtins.toJSON value} 251 + EOF 252 + ipfs --offline config --json "${concatStringsSep "." path}" "$value" 253 + '') 254 + ({ 255 + Addresses.API = cfg.apiAddress; 256 + Addresses.Gateway = cfg.gatewayAddress; 257 + Addresses.Swarm = cfg.swarmAddress; 258 + } // 259 + cfg.extraConfig)) 260 + ); 254 261 serviceConfig = { 255 - ExecStart = ["" "${cfg.package}/bin/ipfs daemon ${ipfsFlags}"]; 262 + ExecStart = [ "" "${cfg.package}/bin/ipfs daemon ${ipfsFlags}" ]; 256 263 User = cfg.user; 257 264 Group = cfg.group; 258 265 } // optionalAttrs (cfg.serviceFdlimit != null) { LimitNOFILE = cfg.serviceFdlimit; }; ··· 263 270 systemd.sockets.ipfs-gateway = { 264 271 wantedBy = [ "sockets.target" ]; 265 272 socketConfig = { 266 - ListenStream = let 273 + ListenStream = 274 + let 267 275 fromCfg = multiaddrToListenStream cfg.gatewayAddress; 268 - in [ "" ] ++ lib.optional (fromCfg != null) fromCfg; 269 - ListenDatagram = let 276 + in 277 + [ "" ] ++ lib.optional (fromCfg != null) fromCfg; 278 + ListenDatagram = 279 + let 270 280 fromCfg = multiaddrToListenDatagram cfg.gatewayAddress; 271 - in [ "" ] ++ lib.optional (fromCfg != null) fromCfg; 281 + in 282 + [ "" ] ++ lib.optional (fromCfg != null) fromCfg; 272 283 }; 273 284 }; 274 285 ··· 276 287 wantedBy = [ "sockets.target" ]; 277 288 # We also include "%t/ipfs.sock" because there is no way to put the "%t" 278 289 # in the multiaddr. 279 - socketConfig.ListenStream = let 290 + socketConfig.ListenStream = 291 + let 280 292 fromCfg = multiaddrToListenStream cfg.apiAddress; 281 - in [ "" "%t/ipfs.sock" ] ++ lib.optional (fromCfg != null) fromCfg; 293 + in 294 + [ "" "%t/ipfs.sock" ] ++ lib.optional (fromCfg != null) fromCfg; 282 295 }; 283 296 284 297 };