diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index db028db407e9..9081ca0d04ac 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -52,6 +52,8 @@ - [boot.kernel.sysfs](options.html#opt-boot.kernel.sysfs) allows setting of sysfs attributes. +- [local-content-share](https://github.com/Tanq16/local-content-share), a simple web-app for storing/sharing text snippets and files in your local network. Available as [services.local-content-share](#opt-services.local-content-share.enable). + - Docker now defaults to 28.x, because version 27.x stopped receiving security updates and bug fixes after [May 2, 2025](https://github.com/moby/moby/pull/49910). - [Corteza](https://cortezaproject.org/), a low-code platform. Available as [services.corteza](#opt-services.corteza.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8754c3a0ad2c..6fa014c30bcc 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -863,6 +863,7 @@ ./services/misc/lifecycled.nix ./services/misc/litellm.nix ./services/misc/llama-cpp.nix + ./services/misc/local-content-share.nix ./services/misc/logkeys.nix ./services/misc/mame.nix ./services/misc/mbpfan.nix diff --git a/nixos/modules/services/misc/local-content-share.nix b/nixos/modules/services/misc/local-content-share.nix new file mode 100644 index 000000000000..cac9a32ec409 --- /dev/null +++ b/nixos/modules/services/misc/local-content-share.nix @@ -0,0 +1,63 @@ +{ + pkgs, + lib, + config, + ... +}: +let + cfg = config.services.local-content-share; +in +{ + options.services.local-content-share = { + enable = lib.mkEnableOption "Local-Content-Share"; + + package = lib.mkPackageOption pkgs "local-content-share" { }; + + listenAddress = lib.mkOption { + type = lib.types.str; + default = ""; + example = "127.0.0.1"; + description = '' + Address on which the service will be available. + + The service will listen on all interfaces if set to an empty string. + ''; + }; + + port = lib.mkOption { + type = lib.types.port; + default = 8080; + description = "Port on which the service will be available"; + }; + + openFirewall = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Whether to automatically open the specified port in the firewall"; + }; + }; + + config = lib.mkIf cfg.enable { + systemd.services.local-content-share = { + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + Type = "simple"; + DynamicUser = true; + User = "local-content-share"; + StateDirectory = "local-content-share"; + StateDirectoryMode = "0700"; + WorkingDirectory = "/var/lib/local-content-share"; + ExecStart = "${lib.getExe' cfg.package "local-content-share"} -listen=${cfg.listenAddress}:${toString cfg.port}"; + Restart = "on-failure"; + }; + }; + + networking.firewall = lib.mkIf cfg.openFirewall { + allowedTCPPorts = [ cfg.port ]; + }; + }; + + meta.maintainers = with lib.maintainers; [ e-v-o-l-v-e ]; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index e8794f0cd502..2262a95404e7 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -849,6 +849,7 @@ in litestream = runTest ./litestream.nix; lk-jwt-service = runTest ./matrix/lk-jwt-service.nix; lldap = runTest ./lldap.nix; + local-content-share = runTest ./local-content-share.nix; localsend = runTest ./localsend.nix; locate = runTest ./locate.nix; login = runTest ./login.nix; diff --git a/nixos/tests/local-content-share.nix b/nixos/tests/local-content-share.nix new file mode 100644 index 000000000000..eb3d43ddce21 --- /dev/null +++ b/nixos/tests/local-content-share.nix @@ -0,0 +1,25 @@ +{ pkgs, lib, ... }: +{ + name = "local-content-share"; + meta.maintainers = pkgs.local-content-share.meta.maintainers; + + nodes.machine = + { pkgs, ... }: + { + services.local-content-share = { + enable = true; + port = 8081; + }; + }; + + testScript = + { nodes, ... }: + let + cfg = nodes.machine.services.local-content-share; + in + '' + machine.wait_for_unit("local-content-share.service") + machine.wait_for_open_port(${toString cfg.port}) + machine.wait_until_succeeds("curl -sS -f http://127.0.0.1:${toString cfg.port}/", timeout=300) + ''; +} diff --git a/pkgs/by-name/lo/local-content-share/package.nix b/pkgs/by-name/lo/local-content-share/package.nix index 2bc7e31e98b1..d4baff49ff2c 100644 --- a/pkgs/by-name/lo/local-content-share/package.nix +++ b/pkgs/by-name/lo/local-content-share/package.nix @@ -2,6 +2,7 @@ lib, buildGoModule, fetchFromGitHub, + nixosTests, }: buildGoModule (finalAttrs: { @@ -20,6 +21,8 @@ buildGoModule (finalAttrs: { # no test file in upstream doCheck = false; + passthru.tests.nixos = nixosTests.local-content-share; + meta = { description = "Storing/sharing text/files in your local network with no setup on client devices"; homepage = "https://github.com/Tanq16/local-content-share";