added more options to piped and allow running individual components seporately
This commit is contained in:
parent
23e7886423
commit
f1722f84a4
|
@ -47,7 +47,7 @@ let
|
||||||
(mapAttrsToList (n: v: "${n}:${cfgToString v}") backend_config));
|
(mapAttrsToList (n: v: "${n}:${cfgToString v}") backend_config));
|
||||||
|
|
||||||
in {
|
in {
|
||||||
config = (lib.mkIf cfg.enable) {
|
config = lib.mkIf (cfg.enable && !cfg.disableBackend) {
|
||||||
systemd.tmpfiles.rules = [ "d /run/piped-backend - root root" ];
|
systemd.tmpfiles.rules = [ "d /run/piped-backend - root root" ];
|
||||||
|
|
||||||
systemd.services.piped-backend = {
|
systemd.services.piped-backend = {
|
||||||
|
|
|
@ -6,10 +6,32 @@ in {
|
||||||
enable = mkEnableOption "piped";
|
enable = mkEnableOption "piped";
|
||||||
|
|
||||||
frontendDomain = mkOption { type = types.str; };
|
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; };
|
proxyDomain = mkOption { type = types.str; };
|
||||||
#rydProxyDomain = 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 {
|
feedRetentionDays = mkOption {
|
||||||
type = types.number;
|
type = types.number;
|
||||||
default = 30;
|
default = 30;
|
||||||
|
|
|
@ -4,9 +4,8 @@ let
|
||||||
cfg = config.services.piped;
|
cfg = config.services.piped;
|
||||||
frontend-package =
|
frontend-package =
|
||||||
(pkgs.piped-frontend.override { backendDomain = cfg.backendDomain; });
|
(pkgs.piped-frontend.override { backendDomain = cfg.backendDomain; });
|
||||||
|
|
||||||
in {
|
in {
|
||||||
config = (lib.mkIf cfg.enable) {
|
config = lib.mkIf (cfg.enable && !cfg.disableFrontend) {
|
||||||
services.nginx.virtualHosts."${cfg.frontendDomain}" = {
|
services.nginx.virtualHosts."${cfg.frontendDomain}" = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
|
|
|
@ -23,35 +23,37 @@ let
|
||||||
access_log off;
|
access_log off;
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
systemd.tmpfiles.rules = [
|
config = lib.mkIf (cfg.enable && !cfg.disableProxy) {
|
||||||
"d /run/piped-proxy - nginx nginx"
|
systemd.tmpfiles.rules = [
|
||||||
"d /run/piped-proxy/socket - nginx nginx"
|
"d /run/piped-proxy - nginx nginx"
|
||||||
];
|
"d /run/piped-proxy/socket - nginx nginx"
|
||||||
|
];
|
||||||
|
|
||||||
systemd.services.piped-proxy = {
|
systemd.services.piped-proxy = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
environment.UDS = "1";
|
environment.UDS = "1";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "nginx";
|
User = "nginx";
|
||||||
WorkingDirectory = "/run/piped-proxy";
|
WorkingDirectory = "/run/piped-proxy";
|
||||||
ExecStart = "${pkgs.piped-proxy}/bin/piped-proxy";
|
ExecStart = "${pkgs.piped-proxy}/bin/piped-proxy";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
services.nginx.virtualHosts."${cfg.proxyDomain}" = {
|
services.nginx.virtualHosts."${cfg.proxyDomain}" = {
|
||||||
forceSSL = true;
|
forceSSL = true;
|
||||||
enableACME = true;
|
enableACME = true;
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://unix:/run/piped-proxy/socket/actix.sock";
|
proxyPass = "http://unix:/run/piped-proxy/socket/actix.sock";
|
||||||
extraConfig = proxy_nginx_extras + ''
|
extraConfig = proxy_nginx_extras + ''
|
||||||
add_header Cache-Control "public, max-age=604800";
|
add_header Cache-Control "public, max-age=604800";
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
locations."~ (/videoplayback|/api/v4/|/api/manifest/)" = {
|
locations."~ (/videoplayback|/api/v4/|/api/manifest/)" = {
|
||||||
proxyPass = "http://unix:/run/piped-proxy/socket/actix.sock";
|
proxyPass = "http://unix:/run/piped-proxy/socket/actix.sock";
|
||||||
extraConfig = proxy_nginx_extras + ''
|
extraConfig = proxy_nginx_extras + ''
|
||||||
add_header Cache-Control private always;
|
add_header Cache-Control private always;
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ stdenv, nodejs, nodePackages, mkYarnPackage, rsync, fetchFromGitHub
|
{ stdenv, nodejs, nodePackages, mkYarnPackage, rsync, fetchFromGitHub,
|
||||||
, backendDomain ? "CHANGE_ME", }:
|
# Backend domain override, if unset then use project default
|
||||||
|
backendDomain ? null, }:
|
||||||
let
|
let
|
||||||
meta = builtins.fromJSON (builtins.readFile ../meta.json);
|
meta = builtins.fromJSON (builtins.readFile ../meta.json);
|
||||||
rev = meta.frontend.rev;
|
rev = meta.frontend.rev;
|
||||||
|
@ -18,8 +19,11 @@ in mkYarnPackage rec {
|
||||||
yarnNix = ./yarn.nix;
|
yarnNix = ./yarn.nix;
|
||||||
|
|
||||||
patchPhase = ''
|
patchPhase = ''
|
||||||
sed -i "s#pipedapi.kavin.rocks#${backendDomain}#g" src/main.js
|
${if backendDomain != null then ''
|
||||||
sed -i "s#pipedapi.kavin.rocks#${backendDomain}#g" src/components/PreferencesPage.vue
|
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 = ''
|
buildPhase = ''
|
||||||
|
|
Loading…
Reference in a new issue