added more options to piped and allow running individual components seporately

This commit is contained in:
Chaos 2022-12-03 15:01:58 +00:00
parent 23e7886423
commit f1722f84a4
No known key found for this signature in database
5 changed files with 61 additions and 34 deletions

View file

@ -47,7 +47,7 @@ let
(mapAttrsToList (n: v: "${n}:${cfgToString v}") backend_config));
in {
config = (lib.mkIf cfg.enable) {
config = lib.mkIf (cfg.enable && !cfg.disableBackend) {
systemd.tmpfiles.rules = [ "d /run/piped-backend - root root" ];
systemd.services.piped-backend = {

View file

@ -6,10 +6,32 @@ in {
enable = mkEnableOption "piped";
frontendDomain = mkOption { type = types.str; };
backendDomain = mkOption { type = types.str; };
backendDomain = mkOption {
type = types.nullOr types.str;
default = null;
description = "Set to null to use project default backend";
};
proxyDomain = mkOption { type = types.str; };
#rydProxyDomain = mkOption { type = types.str; };
disableFrontend = mkOption {
type = types.bool;
default = false;
description = "Don't host frontend";
};
disableBackend = mkOption {
type = types.bool;
default = false;
description = "Don't host backend";
};
disableProxy = mkOption {
type = types.bool;
default = false;
description = "Don't host proxy";
};
feedRetentionDays = mkOption {
type = types.number;
default = 30;

View file

@ -4,9 +4,8 @@ let
cfg = config.services.piped;
frontend-package =
(pkgs.piped-frontend.override { backendDomain = cfg.backendDomain; });
in {
config = (lib.mkIf cfg.enable) {
config = lib.mkIf (cfg.enable && !cfg.disableFrontend) {
services.nginx.virtualHosts."${cfg.frontendDomain}" = {
forceSSL = true;
enableACME = true;

View file

@ -23,35 +23,37 @@ let
access_log off;
'';
in {
systemd.tmpfiles.rules = [
"d /run/piped-proxy - nginx nginx"
"d /run/piped-proxy/socket - nginx nginx"
];
config = lib.mkIf (cfg.enable && !cfg.disableProxy) {
systemd.tmpfiles.rules = [
"d /run/piped-proxy - nginx nginx"
"d /run/piped-proxy/socket - nginx nginx"
];
systemd.services.piped-proxy = {
wantedBy = [ "multi-user.target" ];
environment.UDS = "1";
serviceConfig = {
User = "nginx";
WorkingDirectory = "/run/piped-proxy";
ExecStart = "${pkgs.piped-proxy}/bin/piped-proxy";
systemd.services.piped-proxy = {
wantedBy = [ "multi-user.target" ];
environment.UDS = "1";
serviceConfig = {
User = "nginx";
WorkingDirectory = "/run/piped-proxy";
ExecStart = "${pkgs.piped-proxy}/bin/piped-proxy";
};
};
};
services.nginx.virtualHosts."${cfg.proxyDomain}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://unix:/run/piped-proxy/socket/actix.sock";
extraConfig = proxy_nginx_extras + ''
add_header Cache-Control "public, max-age=604800";
'';
};
locations."~ (/videoplayback|/api/v4/|/api/manifest/)" = {
proxyPass = "http://unix:/run/piped-proxy/socket/actix.sock";
extraConfig = proxy_nginx_extras + ''
add_header Cache-Control private always;
'';
services.nginx.virtualHosts."${cfg.proxyDomain}" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://unix:/run/piped-proxy/socket/actix.sock";
extraConfig = proxy_nginx_extras + ''
add_header Cache-Control "public, max-age=604800";
'';
};
locations."~ (/videoplayback|/api/v4/|/api/manifest/)" = {
proxyPass = "http://unix:/run/piped-proxy/socket/actix.sock";
extraConfig = proxy_nginx_extras + ''
add_header Cache-Control private always;
'';
};
};
};
}

View file

@ -1,5 +1,6 @@
{ stdenv, nodejs, nodePackages, mkYarnPackage, rsync, fetchFromGitHub
, backendDomain ? "CHANGE_ME", }:
{ stdenv, nodejs, nodePackages, mkYarnPackage, rsync, fetchFromGitHub,
# Backend domain override, if unset then use project default
backendDomain ? null, }:
let
meta = builtins.fromJSON (builtins.readFile ../meta.json);
rev = meta.frontend.rev;
@ -18,8 +19,11 @@ in mkYarnPackage rec {
yarnNix = ./yarn.nix;
patchPhase = ''
sed -i "s#pipedapi.kavin.rocks#${backendDomain}#g" src/main.js
sed -i "s#pipedapi.kavin.rocks#${backendDomain}#g" src/components/PreferencesPage.vue
${if backendDomain != null then ''
sed -i "s#pipedapi.kavin.rocks#${backendDomain}#g" src/main.js
sed -i "s#pipedapi.kavin.rocks#${backendDomain}#g" src/components/PreferencesPage.vue
'' else
""}
'';
buildPhase = ''