lol

Merge pull request #197104 from Luflosi/kubo-RFC42

authored by

Sandro and committed by
GitHub
432e5e65 816fd1fa

+66 -49
+11
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
··· 579 579 </listitem> 580 580 <listitem> 581 581 <para> 582 + The ipfs package and module were renamed to kubo. The kubo 583 + module now uses an RFC42-style <literal>settings</literal> 584 + option instead of <literal>extraConfig</literal> and the 585 + <literal>gatewayAddress</literal>, 586 + <literal>apiAddress</literal> and 587 + <literal>swarmAddress</literal> options were renamed. Using 588 + the old names will print a warning but still work. 589 + </para> 590 + </listitem> 591 + <listitem> 592 + <para> 582 593 <literal>pkgs.cosign</literal> does not provide the 583 594 <literal>cosigned</literal> binary anymore. The 584 595 <literal>sget</literal> binary has been moved into its own
+2
nixos/doc/manual/release-notes/rl-2211.section.md
··· 190 190 - PHP 7.4 is no longer supported due to upstream not supporting this 191 191 version for the entire lifecycle of the 22.11 release. 192 192 193 + - The ipfs package and module were renamed to kubo. The kubo module now uses an RFC42-style `settings` option instead of `extraConfig` and the `gatewayAddress`, `apiAddress` and `swarmAddress` options were renamed. Using the old names will print a warning but still work. 194 + 193 195 - `pkgs.cosign` does not provide the `cosigned` binary anymore. The `sget` binary has been moved into its own package. 194 196 195 197 - Emacs now uses the Lucid toolkit by default instead of GTK because of stability and compatibility issues.
+51 -47
nixos/modules/services/network-filesystems/kubo.nix
··· 3 3 let 4 4 cfg = config.services.kubo; 5 5 6 + settingsFormat = pkgs.formats.json {}; 7 + 6 8 kuboFlags = utils.escapeSystemdExecArgs ( 7 9 optional cfg.autoMount "--mount" ++ 8 10 optional cfg.enableGC "--enable-gc" ++ ··· 117 119 description = lib.mdDoc "Where to mount the IPNS namespace to"; 118 120 }; 119 121 120 - gatewayAddress = mkOption { 121 - type = types.str; 122 - default = "/ip4/127.0.0.1/tcp/8080"; 123 - description = lib.mdDoc "Where the IPFS Gateway can be reached"; 124 - }; 125 - 126 - apiAddress = mkOption { 127 - type = types.str; 128 - default = "/ip4/127.0.0.1/tcp/5001"; 129 - description = lib.mdDoc "Where Kubo exposes its API to"; 130 - }; 131 - 132 - swarmAddress = mkOption { 133 - type = types.listOf types.str; 134 - default = [ 135 - "/ip4/0.0.0.0/tcp/4001" 136 - "/ip6/::/tcp/4001" 137 - "/ip4/0.0.0.0/udp/4001/quic" 138 - "/ip6/::/udp/4001/quic" 139 - ]; 140 - description = lib.mdDoc "Where Kubo listens for incoming p2p connections"; 141 - }; 142 - 143 122 enableGC = mkOption { 144 123 type = types.bool; 145 124 default = false; ··· 152 131 description = lib.mdDoc "If set to true, the repo won't be initialized with help files"; 153 132 }; 154 133 155 - extraConfig = mkOption { 156 - type = types.attrs; 134 + settings = mkOption { 135 + type = lib.types.submodule { 136 + freeformType = settingsFormat.type; 137 + 138 + options = { 139 + Addresses.API = mkOption { 140 + type = types.str; 141 + default = "/ip4/127.0.0.1/tcp/5001"; 142 + description = lib.mdDoc "Where Kubo exposes its API to"; 143 + }; 144 + 145 + Addresses.Gateway = mkOption { 146 + type = types.str; 147 + default = "/ip4/127.0.0.1/tcp/8080"; 148 + description = lib.mdDoc "Where the IPFS Gateway can be reached"; 149 + }; 150 + 151 + Addresses.Swarm = mkOption { 152 + type = types.listOf types.str; 153 + default = [ 154 + "/ip4/0.0.0.0/tcp/4001" 155 + "/ip6/::/tcp/4001" 156 + "/ip4/0.0.0.0/udp/4001/quic" 157 + "/ip6/::/udp/4001/quic" 158 + ]; 159 + description = lib.mdDoc "Where Kubo listens for incoming p2p connections"; 160 + }; 161 + }; 162 + }; 157 163 description = lib.mdDoc '' 158 164 Attrset of daemon configuration to set using {command}`ipfs config`, every time the daemon starts. 159 - These are applied last, so may override configuration set by other options in this module. 165 + See [https://github.com/ipfs/kubo/blob/master/docs/config.md](https://github.com/ipfs/kubo/blob/master/docs/config.md) for reference. 160 166 Keep in mind that this configuration is stateful; i.e., unsetting anything in here does not reset the value to the default! 161 167 ''; 162 168 default = { }; ··· 244 250 then [ cfg.package.systemd_unit ] 245 251 else [ cfg.package.systemd_unit_hardened ]; 246 252 253 + services.kubo.settings = mkIf cfg.autoMount { 254 + Mounts.FuseAllowOther = lib.mkDefault true; 255 + Mounts.IPFS = lib.mkDefault cfg.ipfsMountDir; 256 + Mounts.IPNS = lib.mkDefault cfg.ipnsMountDir; 257 + }; 258 + 247 259 systemd.services.ipfs = { 248 260 path = [ "/run/wrappers" cfg.package ]; 249 261 environment.IPFS_PATH = cfg.dataDir; ··· 259 271 '' + '' 260 272 ipfs --offline config profile apply ${profile} >/dev/null 261 273 fi 262 - '' + optionalString cfg.autoMount '' 263 - ipfs --offline config Mounts.FuseAllowOther --json true 264 - ipfs --offline config Mounts.IPFS ${cfg.ipfsMountDir} 265 - ipfs --offline config Mounts.IPNS ${cfg.ipnsMountDir} 266 274 '' + '' 267 275 ipfs --offline config show \ 268 - | ${pkgs.jq}/bin/jq '. * $extraConfig' --argjson extraConfig ${ 269 - escapeShellArg (builtins.toJSON ( 270 - recursiveUpdate 271 - { 272 - Addresses.API = cfg.apiAddress; 273 - Addresses.Gateway = cfg.gatewayAddress; 274 - Addresses.Swarm = cfg.swarmAddress; 275 - } 276 - cfg.extraConfig 277 - )) 276 + | ${pkgs.jq}/bin/jq '. * $settings' --argjson settings ${ 277 + escapeShellArg (builtins.toJSON cfg.settings) 278 278 } \ 279 279 | ipfs --offline config replace - 280 280 ''; ··· 294 294 socketConfig = { 295 295 ListenStream = 296 296 let 297 - fromCfg = multiaddrToListenStream cfg.gatewayAddress; 297 + fromCfg = multiaddrToListenStream cfg.settings.Addresses.Gateway; 298 298 in 299 299 [ "" ] ++ lib.optional (fromCfg != null) fromCfg; 300 300 ListenDatagram = 301 301 let 302 - fromCfg = multiaddrToListenDatagram cfg.gatewayAddress; 302 + fromCfg = multiaddrToListenDatagram cfg.settings.Addresses.Gateway; 303 303 in 304 304 [ "" ] ++ lib.optional (fromCfg != null) fromCfg; 305 305 }; ··· 311 311 # in the multiaddr. 312 312 socketConfig.ListenStream = 313 313 let 314 - fromCfg = multiaddrToListenStream cfg.apiAddress; 314 + fromCfg = multiaddrToListenStream cfg.settings.Addresses.API; 315 315 in 316 316 [ "" "%t/ipfs.sock" ] ++ lib.optional (fromCfg != null) fromCfg; 317 317 }; ··· 332 332 (mkRenamedOptionModule [ "services" "ipfs" "autoMigrate" ] [ "services" "kubo" "autoMigrate" ]) 333 333 (mkRenamedOptionModule [ "services" "ipfs" "ipfsMountDir" ] [ "services" "kubo" "ipfsMountDir" ]) 334 334 (mkRenamedOptionModule [ "services" "ipfs" "ipnsMountDir" ] [ "services" "kubo" "ipnsMountDir" ]) 335 - (mkRenamedOptionModule [ "services" "ipfs" "gatewayAddress" ] [ "services" "kubo" "gatewayAddress" ]) 336 - (mkRenamedOptionModule [ "services" "ipfs" "apiAddress" ] [ "services" "kubo" "apiAddress" ]) 337 - (mkRenamedOptionModule [ "services" "ipfs" "swarmAddress" ] [ "services" "kubo" "swarmAddress" ]) 335 + (mkRenamedOptionModule [ "services" "ipfs" "gatewayAddress" ] [ "services" "kubo" "settings" "Addresses" "Gateway" ]) 336 + (mkRenamedOptionModule [ "services" "ipfs" "apiAddress" ] [ "services" "kubo" "settings" "Addresses" "API" ]) 337 + (mkRenamedOptionModule [ "services" "ipfs" "swarmAddress" ] [ "services" "kubo" "settings" "Addresses" "Swarm" ]) 338 338 (mkRenamedOptionModule [ "services" "ipfs" "enableGC" ] [ "services" "kubo" "enableGC" ]) 339 339 (mkRenamedOptionModule [ "services" "ipfs" "emptyRepo" ] [ "services" "kubo" "emptyRepo" ]) 340 - (mkRenamedOptionModule [ "services" "ipfs" "extraConfig" ] [ "services" "kubo" "extraConfig" ]) 340 + (mkRenamedOptionModule [ "services" "ipfs" "extraConfig" ] [ "services" "kubo" "settings" ]) 341 341 (mkRenamedOptionModule [ "services" "ipfs" "extraFlags" ] [ "services" "kubo" "extraFlags" ]) 342 342 (mkRenamedOptionModule [ "services" "ipfs" "localDiscovery" ] [ "services" "kubo" "localDiscovery" ]) 343 343 (mkRenamedOptionModule [ "services" "ipfs" "serviceFdlimit" ] [ "services" "kubo" "serviceFdlimit" ]) 344 344 (mkRenamedOptionModule [ "services" "ipfs" "startWhenNeeded" ] [ "services" "kubo" "startWhenNeeded" ]) 345 + (mkRenamedOptionModule [ "services" "kubo" "extraConfig" ] [ "services" "kubo" "settings" ]) 346 + (mkRenamedOptionModule [ "services" "kubo" "gatewayAddress" ] [ "services" "kubo" "settings" "Addresses" "Gateway" ]) 347 + (mkRenamedOptionModule [ "services" "kubo" "apiAddress" ] [ "services" "kubo" "settings" "Addresses" "API" ]) 348 + (mkRenamedOptionModule [ "services" "kubo" "swarmAddress" ] [ "services" "kubo" "settings" "Addresses" "Swarm" ]) 345 349 ]; 346 350 }
+2 -2
nixos/tests/kubo.nix
··· 9 9 enable = true; 10 10 # Also will add a unix domain socket socket API address, see module. 11 11 startWhenNeeded = true; 12 - apiAddress = "/ip4/127.0.0.1/tcp/2324"; 12 + settings.Addresses.API = "/ip4/127.0.0.1/tcp/2324"; 13 13 dataDir = "/mnt/ipfs"; 14 14 }; 15 15 }; ··· 17 17 nodes.fuse = { ... }: { 18 18 services.kubo = { 19 19 enable = true; 20 - apiAddress = "/ip4/127.0.0.1/tcp/2324"; 20 + settings.Addresses.API = "/ip4/127.0.0.1/tcp/2324"; 21 21 autoMount = true; 22 22 }; 23 23 };