From b736a8a80116dc7c03ba7b3e481ade72a488e894 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Sun, 24 Dec 2023 22:30:54 +0200 Subject: [PATCH] eris-go: 20231119 -> 20231219 --- .../network-filesystems/eris-server.nix | 56 +++++++++++-------- .../er/eris-go/package.nix} | 20 +++++-- pkgs/top-level/all-packages.nix | 2 - 3 files changed, 50 insertions(+), 28 deletions(-) rename pkgs/{servers/eris-go/default.nix => by-name/er/eris-go/package.nix} (53%) diff --git a/nixos/modules/services/network-filesystems/eris-server.nix b/nixos/modules/services/network-filesystems/eris-server.nix index 66eccfac408c..104676a52c61 100644 --- a/nixos/modules/services/network-filesystems/eris-server.nix +++ b/nixos/modules/services/network-filesystems/eris-server.nix @@ -3,6 +3,7 @@ let cfg = config.services.eris-server; stateDirectoryPath = "\${STATE_DIRECTORY}"; + nullOrStr = with lib.types; nullOr str; in { options.services.eris-server = { @@ -26,7 +27,7 @@ in { }; listenCoap = lib.mkOption { - type = lib.types.str; + type = nullOrStr; default = ":5683"; example = "[::1]:5683"; description = '' @@ -39,8 +40,8 @@ in { }; listenHttp = lib.mkOption { - type = lib.types.str; - default = ""; + type = nullOrStr; + default = null; example = "[::1]:8080"; description = "Server HTTP listen address. Do not listen by default."; }; @@ -58,8 +59,8 @@ in { }; mountpoint = lib.mkOption { - type = lib.types.str; - default = ""; + type = nullOrStr; + default = null; example = "/eris"; description = '' Mountpoint for FUSE namespace that exposes "urn:eris:…" files. @@ -69,33 +70,44 @@ in { }; config = lib.mkIf cfg.enable { + assertions = [{ + assertion = lib.strings.versionAtLeast cfg.package.version "20231219"; + message = + "Version of `config.services.eris-server.package` is incompatible with this module"; + }]; + systemd.services.eris-server = let - cmd = - "${cfg.package}/bin/eris-go server --coap '${cfg.listenCoap}' --http '${cfg.listenHttp}' ${ - lib.optionalString cfg.decode "--decode " - }${ - lib.optionalString (cfg.mountpoint != "") - ''--mountpoint "${cfg.mountpoint}" '' - }${lib.strings.escapeShellArgs cfg.backends}"; + cmd = "${cfg.package}/bin/eris-go server" + + (lib.optionalString (cfg.listenCoap != null) + " --coap '${cfg.listenCoap}'") + + (lib.optionalString (cfg.listenHttp != null) + " --http '${cfg.listenHttp}'") + + (lib.optionalString cfg.decode " --decode") + + (lib.optionalString (cfg.mountpoint != null) + " --mountpoint '${cfg.mountpoint}'"); in { description = "ERIS block server"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - script = lib.mkIf (cfg.mountpoint != "") '' + environment.ERIS_STORE_URL = toString cfg.backends; + script = lib.mkIf (cfg.mountpoint != null) '' export PATH=${config.security.wrapperDir}:$PATH ${cmd} ''; serviceConfig = let - umounter = lib.mkIf (cfg.mountpoint != "") + umounter = lib.mkIf (cfg.mountpoint != null) "-${config.security.wrapperDir}/fusermount -uz ${cfg.mountpoint}"; - in { - ExecStartPre = umounter; - ExecStart = lib.mkIf (cfg.mountpoint == "") cmd; - ExecStopPost = umounter; - Restart = "always"; - RestartSec = 20; - AmbientCapabilities = "CAP_NET_BIND_SERVICE"; - }; + in if (cfg.mountpoint == null) then { + ExecStart = cmd; + } else + { + ExecStartPre = umounter; + ExecStopPost = umounter; + } // { + Restart = "always"; + RestartSec = 20; + AmbientCapabilities = "CAP_NET_BIND_SERVICE"; + }; }; }; diff --git a/pkgs/servers/eris-go/default.nix b/pkgs/by-name/er/eris-go/package.nix similarity index 53% rename from pkgs/servers/eris-go/default.nix rename to pkgs/by-name/er/eris-go/package.nix index a215a59d547a..50a37c008ffd 100644 --- a/pkgs/servers/eris-go/default.nix +++ b/pkgs/by-name/er/eris-go/package.nix @@ -1,18 +1,30 @@ -{ lib, stdenv, buildGoModule, fetchFromGitea, nixosTests }: +{ lib, stdenv, buildGoModule, fetchFromGitea, mandoc, tup, nixosTests }: buildGoModule rec { pname = "eris-go"; - version = "20230914"; + version = "20231219"; + outputs = [ "out" "man" ]; src = fetchFromGitea { domain = "codeberg.org"; owner = "eris"; repo = "eris-go"; rev = version; - hash = "sha256-7aEsCQ+bZ//6Z+XXAEHgsAd61L+QgRl77+UtHr/BM1g="; + hash = "sha256-eXLfBkJgG51ZjR1qXRE2BgTrIpQsPW5SKeMlGd3J1NE="; }; - vendorHash = "sha256-Z6rirsiiBzH0herQAkxZp1Xr++489qNoiD4fqoLt9/A="; + vendorHash = "sha256-pA/fz7JpDwdTRFfLDY0M6p9TeBOK68byhy/0Cw53p4M="; + + nativeBuildInputs = [ mandoc tup ]; + + postConfigure = '' + rm -f *.md + tupConfigure + ''; + postBuild = "tupBuild"; + postInstall = '' + install -D *.1.man -t $man/share/man/man1 + ''; skipNetworkTests = true; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f06f95777a49..419ebf4580dd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7997,8 +7997,6 @@ with pkgs; endlessh-go = callPackage ../servers/endlessh-go { }; - eris-go = callPackage ../servers/eris-go { }; - ericw-tools = callPackage ../applications/misc/ericw-tools { }; cryfs = callPackage ../tools/filesystems/cryfs { };