mirror of
https://github.com/kmein/niveum
synced 2026-03-16 10:11:08 +01:00
feat(flix): update flix-index service and flixmenu
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
let
|
let
|
||||||
flixLocation = "/media/flix";
|
flixLocation = "/media/flix";
|
||||||
cacheLocation = "/var/cache/flix";
|
cacheLocation = "/var/cache/flix";
|
||||||
|
indexFilename = "index";
|
||||||
|
flixUser = "flix";
|
||||||
|
flixGroup = "users";
|
||||||
in {
|
in {
|
||||||
imports = [ <stockholm/krebs/3modules/permown.nix> ];
|
|
||||||
|
|
||||||
fileSystems.${flixLocation} = {
|
fileSystems.${flixLocation} = {
|
||||||
device = "prism.r:/export";
|
device = "prism.r:/export";
|
||||||
fsType = "nfs";
|
fsType = "nfs";
|
||||||
@@ -22,32 +23,38 @@ in {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
krebs.permown.${cacheLocation} = {
|
systemd.tmpfiles.rules = [
|
||||||
owner = config.users.users.me.name;
|
"d '${cacheLocation}' 0750 ${flixUser} ${flixGroup} - -"
|
||||||
group = "users";
|
];
|
||||||
umask = "0000";
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.flix-index = {
|
systemd.services.flix-index = {
|
||||||
description = "Flix indexing service";
|
description = "Flix indexing service";
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
script = ''
|
script = "cp ${flixLocation}/download/index ./${indexFilename}";
|
||||||
flix_cache="${cacheLocation}/flix_index"
|
|
||||||
|
|
||||||
find ${flixLocation}/download/sorted -type f > "$flix_cache"
|
|
||||||
'';
|
|
||||||
startAt = "hourly";
|
startAt = "hourly";
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = flixUser;
|
||||||
|
Group = flixGroup;
|
||||||
|
WorkingDirectory = cacheLocation;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
users.extraUsers.${flixUser} = {
|
||||||
|
isSystemUser = true;
|
||||||
|
createHome = true;
|
||||||
|
home = cacheLocation;
|
||||||
|
extraGroups = [ flixGroup ];
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
(pkgs.writeDashBin "flixmenu" ''
|
(pkgs.writeDashBin "flixmenu" ''
|
||||||
set -efu
|
set -efu
|
||||||
flix_cache="${cacheLocation}/flix_index"
|
cd "${flixLocation}/download"
|
||||||
|
|
||||||
[ -f "$flix_cache" ] || exit 1
|
[ -f "${cacheLocation}/${indexFilename}" ] || exit 1
|
||||||
|
|
||||||
${pkgs.dmenu}/bin/dmenu -i -p flix -l 5 "$@" < "$flix_cache" \
|
${pkgs.dmenu}/bin/dmenu -i -p flix -l 5 "$@" < ${cacheLocation}/${indexFilename} \
|
||||||
| ${pkgs.findutils}/bin/xargs -I '{}' ${pkgs.utillinux}/bin/setsid ${pkgs.xdg_utils}/bin/xdg-open '{}'
|
| ${pkgs.findutils}/bin/xargs -I '{}' ${pkgs.utillinux}/bin/setsid ${pkgs.xdg_utils}/bin/xdg-open '{}'
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user