2020-04-15 14:57:41 +02:00
|
|
|
{ config, pkgs, ... }:
|
2020-04-16 10:35:20 +02:00
|
|
|
let
|
|
|
|
|
flixLocation = "/media/flix";
|
|
|
|
|
cacheLocation = "/var/cache/flix";
|
2020-09-15 23:04:44 +02:00
|
|
|
indexFilename = "index";
|
|
|
|
|
flixUser = "flix";
|
|
|
|
|
flixGroup = "users";
|
2020-04-15 14:57:41 +02:00
|
|
|
in {
|
|
|
|
|
fileSystems.${flixLocation} = {
|
|
|
|
|
device = "prism.r:/export";
|
|
|
|
|
fsType = "nfs";
|
2020-07-11 20:44:20 +02:00
|
|
|
options = [
|
|
|
|
|
"noauto"
|
|
|
|
|
"noatime"
|
|
|
|
|
"nodiratime"
|
|
|
|
|
"x-systemd.automount"
|
|
|
|
|
"x-systemd.device-timeout=1"
|
|
|
|
|
"x-systemd.idle-timeout=1min"
|
|
|
|
|
"x-systemd.requires=tinc.retiolum.service"
|
|
|
|
|
"x-systemd.requires=wpa_supplicant.service"
|
|
|
|
|
"user"
|
|
|
|
|
"_netdev"
|
|
|
|
|
];
|
2020-04-15 14:57:41 +02:00
|
|
|
};
|
|
|
|
|
|
2020-09-15 23:04:44 +02:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
|
"d '${cacheLocation}' 0750 ${flixUser} ${flixGroup} - -"
|
|
|
|
|
];
|
2020-04-16 10:35:20 +02:00
|
|
|
|
|
|
|
|
systemd.services.flix-index = {
|
2020-04-15 14:57:41 +02:00
|
|
|
description = "Flix indexing service";
|
2020-04-16 10:35:20 +02:00
|
|
|
wants = [ "network-online.target" ];
|
2020-09-15 23:04:44 +02:00
|
|
|
script = "cp ${flixLocation}/download/index ./${indexFilename}";
|
2020-04-15 14:57:41 +02:00
|
|
|
startAt = "hourly";
|
2020-09-15 23:04:44 +02:00
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "oneshot";
|
|
|
|
|
User = flixUser;
|
|
|
|
|
Group = flixGroup;
|
|
|
|
|
WorkingDirectory = cacheLocation;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
users.extraUsers.${flixUser} = {
|
|
|
|
|
isSystemUser = true;
|
|
|
|
|
createHome = true;
|
|
|
|
|
home = cacheLocation;
|
|
|
|
|
extraGroups = [ flixGroup ];
|
2020-04-15 14:57:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
environment.systemPackages = [
|
|
|
|
|
(pkgs.writeDashBin "flixmenu" ''
|
|
|
|
|
set -efu
|
2020-09-15 23:04:44 +02:00
|
|
|
cd "${flixLocation}/download"
|
2020-04-15 14:57:41 +02:00
|
|
|
|
2020-09-15 23:04:44 +02:00
|
|
|
[ -f "${cacheLocation}/${indexFilename}" ] || exit 1
|
2020-04-15 14:57:41 +02:00
|
|
|
|
2020-09-15 23:04:44 +02:00
|
|
|
${pkgs.dmenu}/bin/dmenu -i -p flix -l 5 "$@" < ${cacheLocation}/${indexFilename} \
|
2020-04-16 10:35:20 +02:00
|
|
|
| ${pkgs.findutils}/bin/xargs -I '{}' ${pkgs.utillinux}/bin/setsid ${pkgs.xdg_utils}/bin/xdg-open '{}'
|
2020-04-15 14:57:41 +02:00
|
|
|
'')
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
}
|