Merge pull request #246447 from 999eagle/update/invidious
invidious: unstable-2023-06-06 -> unstable-2023-08-07
This commit is contained in:
commit
be9b7ddbdc
|
@ -7,6 +7,9 @@ let
|
|||
|
||||
settingsFile = settingsFormat.generate "invidious-settings" cfg.settings;
|
||||
|
||||
generatedHmacKeyFile = "/var/lib/invidious/hmac_key";
|
||||
generateHmac = cfg.hmacKeyFile == null;
|
||||
|
||||
serviceConfig = {
|
||||
systemd.services.invidious = {
|
||||
description = "Invidious (An alternative YouTube front-end)";
|
||||
|
@ -14,22 +17,47 @@ let
|
|||
after = [ "network-online.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
script =
|
||||
let
|
||||
jqFilter = "."
|
||||
+ lib.optionalString (cfg.database.host != null) "[0].db.password = \"'\"'\"$(cat ${lib.escapeShellArg cfg.database.passwordFile})\"'\"'\""
|
||||
+ " | .[0]"
|
||||
+ lib.optionalString (cfg.extraSettingsFile != null) " * .[1]";
|
||||
jqFiles = [ settingsFile ] ++ lib.optional (cfg.extraSettingsFile != null) cfg.extraSettingsFile;
|
||||
in
|
||||
''
|
||||
export INVIDIOUS_CONFIG="$(${pkgs.jq}/bin/jq -s "${jqFilter}" ${lib.escapeShellArgs jqFiles})"
|
||||
exec ${cfg.package}/bin/invidious
|
||||
'';
|
||||
preStart = lib.optionalString generateHmac ''
|
||||
if [[ ! -e "${generatedHmacKeyFile}" ]]; then
|
||||
${pkgs.pwgen}/bin/pwgen 20 1 > "${generatedHmacKeyFile}"
|
||||
chmod 0600 "${generatedHmacKeyFile}"
|
||||
fi
|
||||
'';
|
||||
|
||||
script = ''
|
||||
configParts=()
|
||||
''
|
||||
# autogenerated hmac_key
|
||||
+ lib.optionalString generateHmac ''
|
||||
configParts+=("$(${pkgs.jq}/bin/jq -R '{"hmac_key":.}' <"${generatedHmacKeyFile}")")
|
||||
''
|
||||
# generated settings file
|
||||
+ ''
|
||||
configParts+=("$(< ${lib.escapeShellArg settingsFile})")
|
||||
''
|
||||
# optional database password file
|
||||
+ lib.optionalString (cfg.database.host != null) ''
|
||||
configParts+=("$(${pkgs.jq}/bin/jq -R '{"db":{"password":.}}' ${lib.escapeShellArg cfg.database.passwordFile})")
|
||||
''
|
||||
# optional extra settings file
|
||||
+ lib.optionalString (cfg.extraSettingsFile != null) ''
|
||||
configParts+=("$(< ${lib.escapeShellArg cfg.extraSettingsFile})")
|
||||
''
|
||||
# explicitly specified hmac key file
|
||||
+ lib.optionalString (cfg.hmacKeyFile != null) ''
|
||||
configParts+=("$(< ${lib.escapeShellArg cfg.hmacKeyFile})")
|
||||
''
|
||||
# merge all parts into a single configuration with later elements overriding previous elements
|
||||
+ ''
|
||||
export INVIDIOUS_CONFIG="$(${pkgs.jq}/bin/jq -s 'reduce .[] as $item ({}; . * $item)' <<<"''${configParts[*]}")"
|
||||
exec ${cfg.package}/bin/invidious
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
RestartSec = "2s";
|
||||
DynamicUser = true;
|
||||
StateDirectory = "invidious";
|
||||
StateDirectoryMode = "0750";
|
||||
|
||||
CapabilityBoundingSet = "";
|
||||
PrivateDevices = true;
|
||||
|
@ -171,6 +199,18 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
hmacKeyFile = lib.mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = lib.mdDoc ''
|
||||
A path to a file containing the `hmac_key`. If `null`, a key will be generated automatically on first
|
||||
start.
|
||||
|
||||
If non-`null`, this option overrides any `hmac_key` specified in {option}`services.invidious.settings` or
|
||||
via {option}`services.invidious.extraSettingsFile`.
|
||||
'';
|
||||
};
|
||||
|
||||
extraSettingsFile = lib.mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
|
|
|
@ -97,12 +97,16 @@ crystal.buildCrystalPackage rec {
|
|||
cp -r config/sql $out/share/invidious/config
|
||||
'';
|
||||
|
||||
# Invidious tries to open config/config.yml and connect to the database, even
|
||||
# when running --help. This specifies a minimal configuration in an
|
||||
# environment variable. Even though the database is bogus, --help still
|
||||
# works.
|
||||
# Invidious tries to open and validate config/config.yml, even when
|
||||
# running --help. This specifies a minimal configuration in an
|
||||
# environment variable. Even though the database and hmac_key are
|
||||
# bogus, --help still works.
|
||||
installCheckPhase = ''
|
||||
INVIDIOUS_CONFIG="database_url: sqlite3:///dev/null" $out/bin/invidious --help
|
||||
INVIDIOUS_CONFIG="$(cat <<EOF
|
||||
database_url: sqlite3:///dev/null
|
||||
hmac_key: "this-is-required"
|
||||
EOF
|
||||
)" $out/bin/invidious --help
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl crystal crystal2nix jq git moreutils nix nix-prefetch pkg-config
|
||||
#!nix-shell -i bash -p curl crystal crystal2nix jq git moreutils nix nix-prefetch pkg-config pcre
|
||||
git_url='https://github.com/iv-org/invidious.git'
|
||||
git_branch='master'
|
||||
git_dir='/var/tmp/invidious.git'
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
"sha256": "sha256-EU6T9yQCdOLx98Io8o01rEsgxDFF/Xoy42LgPopD2/A="
|
||||
},
|
||||
"invidious": {
|
||||
"rev": "545a5937d87d31622e87bb2ba8151f8aecd66c81",
|
||||
"sha256": "sha256-1Ra3nLO2DsnTvyovteF0cOIl07GHbJyPbTYBRIyKuAs=",
|
||||
"version": "unstable-2023-06-06"
|
||||
"rev": "34508966027fce3f460d9670eeecef67b92565a0",
|
||||
"sha256": "sha256-z+6YHhESb0Ws9DRaVH4AR2i/SaWgM9OhTzxdY1bkv/0=",
|
||||
"version": "unstable-2023-08-07"
|
||||
},
|
||||
"lsquic": {
|
||||
"sha256": "sha256-hG8cUvhbCNeMOsKkaJlgGpzUrIx47E/WhmPIdI5F3qM=",
|
||||
|
|
Loading…
Reference in a new issue