1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/configs/flix.nix

81 lines
2.0 KiB
Nix
Raw Normal View History

2022-03-10 21:52:12 +01:00
{
config,
pkgs,
...
}: let
2020-04-16 10:35:20 +02:00
flixLocation = "/media/flix";
cacheLocation = "/var/cache/flix";
indexFilename = "index";
flixUser = "flix";
flixGroup = "users";
2021-03-23 21:00:21 +01:00
inherit (import <niveum/lib>) tmpfilesConfig;
in {
fileSystems.${flixLocation} = {
device = "prism.r:/export";
fsType = "nfs";
options = [
"noauto"
"noatime"
"nodiratime"
"x-systemd.automount"
"x-systemd.device-timeout=1"
"x-systemd.idle-timeout=1min"
"x-systemd.requires=tinc.retiolum.service"
"user"
"_netdev"
];
};
systemd.tmpfiles.rules = [
2021-03-23 21:00:21 +01:00
(tmpfilesConfig {
type = "d";
path = cacheLocation;
mode = "0750";
user = flixUser;
group = flixGroup;
})
];
2020-04-16 10:35:20 +02:00
systemd.services.flix-index = {
description = "Flix indexing service";
2022-03-10 21:52:12 +01:00
wants = ["network-online.target"];
script = "cp ${flixLocation}/download/index ./${indexFilename}";
startAt = "hourly";
serviceConfig = {
Type = "oneshot";
User = flixUser;
Group = flixGroup;
WorkingDirectory = cacheLocation;
};
};
users.extraUsers.${flixUser} = {
isSystemUser = true;
createHome = true;
home = cacheLocation;
2021-12-01 17:38:47 +01:00
group = flixGroup;
};
environment.systemPackages = [
2021-10-19 22:42:00 +02:00
(pkgs.writers.writeDashBin "mpv-simpsons" ''
2021-02-06 14:02:09 +01:00
set -efu
cd "${flixLocation}/download"
[ -f "${cacheLocation}/${indexFilename}" ] || exit 1
cat "${cacheLocation}/${indexFilename}" \
| ${pkgs.gnugrep}/bin/grep -i 'simpsons.*mkv' \
| shuf \
| ${pkgs.findutils}/bin/xargs -d '\n' ${pkgs.mpv}/bin/mpv
'')
2021-10-19 22:42:00 +02:00
(pkgs.writers.writeDashBin "flixmenu" ''
set -efu
cd "${flixLocation}/download"
[ -f "${cacheLocation}/${indexFilename}" ] || exit 1
${pkgs.dmenu}/bin/dmenu -i -p flix -l 5 "$@" < ${cacheLocation}/${indexFilename} \
2022-10-06 10:05:11 +02:00
| ${pkgs.findutils}/bin/xargs -I '{}' ${pkgs.util-linux}/bin/setsid ${pkgs.xdg-utils}/bin/xdg-open '{}'
'')
];
}