mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-22 14:45:27 +00:00
Merge pull request #113185 from fabaff/libreddit
libreddit: init at 0.10.1
This commit is contained in:
commit
c8a731593b
|
@ -519,6 +519,7 @@
|
|||
./services/misc/logkeys.nix
|
||||
./services/misc/leaps.nix
|
||||
./services/misc/lidarr.nix
|
||||
./services/misc/libreddit.nix
|
||||
./services/misc/lifecycled.nix
|
||||
./services/misc/mame.nix
|
||||
./services/misc/matrix-appservice-discord.nix
|
||||
|
|
66
nixos/modules/services/misc/libreddit.nix
Normal file
66
nixos/modules/services/misc/libreddit.nix
Normal file
|
@ -0,0 +1,66 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.libreddit;
|
||||
|
||||
args = concatStringsSep " " ([
|
||||
"--port ${toString cfg.port}"
|
||||
"--address ${cfg.address}"
|
||||
] ++ optional cfg.redirect "--redirect-https");
|
||||
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.libreddit = {
|
||||
enable = mkEnableOption "Private front-end for Reddit";
|
||||
|
||||
address = mkOption {
|
||||
default = "0.0.0.0";
|
||||
example = "127.0.0.1";
|
||||
type = types.str;
|
||||
description = "The address to listen on";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
default = 8080;
|
||||
example = 8000;
|
||||
type = types.port;
|
||||
description = "The port to listen on";
|
||||
};
|
||||
|
||||
redirect = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Enable the redirecting to HTTPS";
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Open ports in the firewall for the libreddit web interface";
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.libreddit = {
|
||||
description = "Private front-end for Reddit";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
serviceConfig = {
|
||||
DynamicUser = true;
|
||||
ExecStart = "${pkgs.libreddit}/bin/libreddit ${args}";
|
||||
AmbientCapabilities = lib.mkIf (cfg.port < 1024) [ "CAP_NET_BIND_SERVICE" ];
|
||||
Restart = "on-failure";
|
||||
RestartSec = "2s";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall = mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ cfg.port ];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -223,6 +223,7 @@ in
|
|||
latestKernel.hardened = handleTest ./hardened.nix { latestKernel = true; };
|
||||
latestKernel.login = handleTest ./login.nix { latestKernel = true; };
|
||||
leaps = handleTest ./leaps.nix {};
|
||||
libreddit = handleTest ./libreddit.nix {};
|
||||
lidarr = handleTest ./lidarr.nix {};
|
||||
libreswan = handleTest ./libreswan.nix {};
|
||||
lightdm = handleTest ./lightdm.nix {};
|
||||
|
|
19
nixos/tests/libreddit.nix
Normal file
19
nixos/tests/libreddit.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
import ./make-test-python.nix ({ lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
name = "libreddit";
|
||||
meta.maintainers = with maintainers; [ fab ];
|
||||
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
{ services.libreddit.enable = true; };
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("libreddit.service")
|
||||
machine.wait_for_open_port("8080")
|
||||
# The service wants to get data from https://www.reddit.com
|
||||
machine.succeed("curl http://localhost:8080/")
|
||||
'';
|
||||
})
|
1466
pkgs/servers/libreddit/add-Cargo.lock.patch
Normal file
1466
pkgs/servers/libreddit/add-Cargo.lock.patch
Normal file
File diff suppressed because it is too large
Load diff
40
pkgs/servers/libreddit/default.nix
Normal file
40
pkgs/servers/libreddit/default.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, nixosTests
|
||||
, rustPlatform
|
||||
, fetchFromGitHub
|
||||
, Security
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "libreddit";
|
||||
version = "0.10.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "spikecodes";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "0f5xla6fgq4l9g95gwwvfxksaxj4zpayrsjacf53akjpxaqvqxdj";
|
||||
};
|
||||
|
||||
cargoSha256 = "039k6kncdgy6q2lbcssj5dm9npk0yss5m081ps4nmdj2vjrkphf0";
|
||||
|
||||
buildInputs = lib.optional stdenv.isDarwin Security;
|
||||
|
||||
cargoPatches = [
|
||||
# Patch file to add/update Cargo.lock in the source code
|
||||
# https://github.com/spikecodes/libreddit/issues/191
|
||||
./add-Cargo.lock.patch
|
||||
];
|
||||
|
||||
passthru.tests = {
|
||||
inherit (nixosTests) libreddit;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Private front-end for Reddit";
|
||||
homepage = "https://github.com/spikecodes/libreddit";
|
||||
license = with licenses; [ agpl3Only ];
|
||||
maintainers = with maintainers; [ fab ];
|
||||
};
|
||||
}
|
|
@ -6861,6 +6861,10 @@ in
|
|||
|
||||
libzmf = callPackage ../development/libraries/libzmf {};
|
||||
|
||||
libreddit = callPackage ../servers/libreddit {
|
||||
inherit (darwin.apple_sdk.frameworks) Security;
|
||||
};
|
||||
|
||||
librespeed-cli = callPackage ../tools/misc/librespeed-cli { };
|
||||
|
||||
libreswan = callPackage ../tools/networking/libreswan { };
|
||||
|
|
Loading…
Reference in a new issue