1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00
Files
niveum/configs/flix.nix
2020-09-15 23:04:44 +02:00

63 lines
1.5 KiB
Nix

{ config, pkgs, ... }:
let
flixLocation = "/media/flix";
cacheLocation = "/var/cache/flix";
indexFilename = "index";
flixUser = "flix";
flixGroup = "users";
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"
"x-systemd.requires=wpa_supplicant.service"
"user"
"_netdev"
];
};
systemd.tmpfiles.rules = [
"d '${cacheLocation}' 0750 ${flixUser} ${flixGroup} - -"
];
systemd.services.flix-index = {
description = "Flix indexing service";
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;
extraGroups = [ flixGroup ];
};
environment.systemPackages = [
(pkgs.writeDashBin "flixmenu" ''
set -efu
cd "${flixLocation}/download"
[ -f "${cacheLocation}/${indexFilename}" ] || exit 1
${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 '{}'
'')
];
}