Merge pull request #197104 from Luflosi/kubo-RFC42

Sandro 432e5e65 816fd1fa

Changed files
+66 -49
nixos
doc
manual
from_md
release-notes
release-notes
modules
services
network-filesystems
tests
+11
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
···
</listitem>
<listitem>
<para>
+
The ipfs package and module were renamed to kubo. The kubo
+
module now uses an RFC42-style <literal>settings</literal>
+
option instead of <literal>extraConfig</literal> and the
+
<literal>gatewayAddress</literal>,
+
<literal>apiAddress</literal> and
+
<literal>swarmAddress</literal> options were renamed. Using
+
the old names will print a warning but still work.
+
</para>
+
</listitem>
+
<listitem>
+
<para>
<literal>pkgs.cosign</literal> does not provide the
<literal>cosigned</literal> binary anymore. The
<literal>sget</literal> binary has been moved into its own
+2
nixos/doc/manual/release-notes/rl-2211.section.md
···
- PHP 7.4 is no longer supported due to upstream not supporting this
version for the entire lifecycle of the 22.11 release.
+
- 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.
+
- `pkgs.cosign` does not provide the `cosigned` binary anymore. The `sget` binary has been moved into its own package.
- 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
···
let
cfg = config.services.kubo;
+
settingsFormat = pkgs.formats.json {};
+
kuboFlags = utils.escapeSystemdExecArgs (
optional cfg.autoMount "--mount" ++
optional cfg.enableGC "--enable-gc" ++
···
description = lib.mdDoc "Where to mount the IPNS namespace to";
};
-
gatewayAddress = mkOption {
-
type = types.str;
-
default = "/ip4/127.0.0.1/tcp/8080";
-
description = lib.mdDoc "Where the IPFS Gateway can be reached";
-
};
-
-
apiAddress = mkOption {
-
type = types.str;
-
default = "/ip4/127.0.0.1/tcp/5001";
-
description = lib.mdDoc "Where Kubo exposes its API to";
-
};
-
-
swarmAddress = mkOption {
-
type = types.listOf types.str;
-
default = [
-
"/ip4/0.0.0.0/tcp/4001"
-
"/ip6/::/tcp/4001"
-
"/ip4/0.0.0.0/udp/4001/quic"
-
"/ip6/::/udp/4001/quic"
-
];
-
description = lib.mdDoc "Where Kubo listens for incoming p2p connections";
-
};
-
enableGC = mkOption {
type = types.bool;
default = false;
···
description = lib.mdDoc "If set to true, the repo won't be initialized with help files";
};
-
extraConfig = mkOption {
-
type = types.attrs;
+
settings = mkOption {
+
type = lib.types.submodule {
+
freeformType = settingsFormat.type;
+
+
options = {
+
Addresses.API = mkOption {
+
type = types.str;
+
default = "/ip4/127.0.0.1/tcp/5001";
+
description = lib.mdDoc "Where Kubo exposes its API to";
+
};
+
+
Addresses.Gateway = mkOption {
+
type = types.str;
+
default = "/ip4/127.0.0.1/tcp/8080";
+
description = lib.mdDoc "Where the IPFS Gateway can be reached";
+
};
+
+
Addresses.Swarm = mkOption {
+
type = types.listOf types.str;
+
default = [
+
"/ip4/0.0.0.0/tcp/4001"
+
"/ip6/::/tcp/4001"
+
"/ip4/0.0.0.0/udp/4001/quic"
+
"/ip6/::/udp/4001/quic"
+
];
+
description = lib.mdDoc "Where Kubo listens for incoming p2p connections";
+
};
+
};
+
};
description = lib.mdDoc ''
Attrset of daemon configuration to set using {command}`ipfs config`, every time the daemon starts.
-
These are applied last, so may override configuration set by other options in this module.
+
See [https://github.com/ipfs/kubo/blob/master/docs/config.md](https://github.com/ipfs/kubo/blob/master/docs/config.md) for reference.
Keep in mind that this configuration is stateful; i.e., unsetting anything in here does not reset the value to the default!
'';
default = { };
···
then [ cfg.package.systemd_unit ]
else [ cfg.package.systemd_unit_hardened ];
+
services.kubo.settings = mkIf cfg.autoMount {
+
Mounts.FuseAllowOther = lib.mkDefault true;
+
Mounts.IPFS = lib.mkDefault cfg.ipfsMountDir;
+
Mounts.IPNS = lib.mkDefault cfg.ipnsMountDir;
+
};
+
systemd.services.ipfs = {
path = [ "/run/wrappers" cfg.package ];
environment.IPFS_PATH = cfg.dataDir;
···
'' + ''
ipfs --offline config profile apply ${profile} >/dev/null
fi
-
'' + optionalString cfg.autoMount ''
-
ipfs --offline config Mounts.FuseAllowOther --json true
-
ipfs --offline config Mounts.IPFS ${cfg.ipfsMountDir}
-
ipfs --offline config Mounts.IPNS ${cfg.ipnsMountDir}
'' + ''
ipfs --offline config show \
-
| ${pkgs.jq}/bin/jq '. * $extraConfig' --argjson extraConfig ${
-
escapeShellArg (builtins.toJSON (
-
recursiveUpdate
-
{
-
Addresses.API = cfg.apiAddress;
-
Addresses.Gateway = cfg.gatewayAddress;
-
Addresses.Swarm = cfg.swarmAddress;
-
}
-
cfg.extraConfig
-
))
+
| ${pkgs.jq}/bin/jq '. * $settings' --argjson settings ${
+
escapeShellArg (builtins.toJSON cfg.settings)
} \
| ipfs --offline config replace -
'';
···
socketConfig = {
ListenStream =
let
-
fromCfg = multiaddrToListenStream cfg.gatewayAddress;
+
fromCfg = multiaddrToListenStream cfg.settings.Addresses.Gateway;
in
[ "" ] ++ lib.optional (fromCfg != null) fromCfg;
ListenDatagram =
let
-
fromCfg = multiaddrToListenDatagram cfg.gatewayAddress;
+
fromCfg = multiaddrToListenDatagram cfg.settings.Addresses.Gateway;
in
[ "" ] ++ lib.optional (fromCfg != null) fromCfg;
};
···
# in the multiaddr.
socketConfig.ListenStream =
let
-
fromCfg = multiaddrToListenStream cfg.apiAddress;
+
fromCfg = multiaddrToListenStream cfg.settings.Addresses.API;
in
[ "" "%t/ipfs.sock" ] ++ lib.optional (fromCfg != null) fromCfg;
};
···
(mkRenamedOptionModule [ "services" "ipfs" "autoMigrate" ] [ "services" "kubo" "autoMigrate" ])
(mkRenamedOptionModule [ "services" "ipfs" "ipfsMountDir" ] [ "services" "kubo" "ipfsMountDir" ])
(mkRenamedOptionModule [ "services" "ipfs" "ipnsMountDir" ] [ "services" "kubo" "ipnsMountDir" ])
-
(mkRenamedOptionModule [ "services" "ipfs" "gatewayAddress" ] [ "services" "kubo" "gatewayAddress" ])
-
(mkRenamedOptionModule [ "services" "ipfs" "apiAddress" ] [ "services" "kubo" "apiAddress" ])
-
(mkRenamedOptionModule [ "services" "ipfs" "swarmAddress" ] [ "services" "kubo" "swarmAddress" ])
+
(mkRenamedOptionModule [ "services" "ipfs" "gatewayAddress" ] [ "services" "kubo" "settings" "Addresses" "Gateway" ])
+
(mkRenamedOptionModule [ "services" "ipfs" "apiAddress" ] [ "services" "kubo" "settings" "Addresses" "API" ])
+
(mkRenamedOptionModule [ "services" "ipfs" "swarmAddress" ] [ "services" "kubo" "settings" "Addresses" "Swarm" ])
(mkRenamedOptionModule [ "services" "ipfs" "enableGC" ] [ "services" "kubo" "enableGC" ])
(mkRenamedOptionModule [ "services" "ipfs" "emptyRepo" ] [ "services" "kubo" "emptyRepo" ])
-
(mkRenamedOptionModule [ "services" "ipfs" "extraConfig" ] [ "services" "kubo" "extraConfig" ])
+
(mkRenamedOptionModule [ "services" "ipfs" "extraConfig" ] [ "services" "kubo" "settings" ])
(mkRenamedOptionModule [ "services" "ipfs" "extraFlags" ] [ "services" "kubo" "extraFlags" ])
(mkRenamedOptionModule [ "services" "ipfs" "localDiscovery" ] [ "services" "kubo" "localDiscovery" ])
(mkRenamedOptionModule [ "services" "ipfs" "serviceFdlimit" ] [ "services" "kubo" "serviceFdlimit" ])
(mkRenamedOptionModule [ "services" "ipfs" "startWhenNeeded" ] [ "services" "kubo" "startWhenNeeded" ])
+
(mkRenamedOptionModule [ "services" "kubo" "extraConfig" ] [ "services" "kubo" "settings" ])
+
(mkRenamedOptionModule [ "services" "kubo" "gatewayAddress" ] [ "services" "kubo" "settings" "Addresses" "Gateway" ])
+
(mkRenamedOptionModule [ "services" "kubo" "apiAddress" ] [ "services" "kubo" "settings" "Addresses" "API" ])
+
(mkRenamedOptionModule [ "services" "kubo" "swarmAddress" ] [ "services" "kubo" "settings" "Addresses" "Swarm" ])
];
}
+2 -2
nixos/tests/kubo.nix
···
enable = true;
# Also will add a unix domain socket socket API address, see module.
startWhenNeeded = true;
-
apiAddress = "/ip4/127.0.0.1/tcp/2324";
+
settings.Addresses.API = "/ip4/127.0.0.1/tcp/2324";
dataDir = "/mnt/ipfs";
};
};
···
nodes.fuse = { ... }: {
services.kubo = {
enable = true;
-
apiAddress = "/ip4/127.0.0.1/tcp/2324";
+
settings.Addresses.API = "/ip4/127.0.0.1/tcp/2324";
autoMount = true;
};
};