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

fix(flix): use global cache location

This commit is contained in:
Kierán Meinhardt
2020-04-16 10:35:20 +02:00
parent 72fd9982e4
commit 64666ba42e

View File

@@ -1,40 +1,42 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
let flixLocation = "/media/flix"; let
flixLocation = "/media/flix";
cacheLocation = "/var/cache/flix";
in { in {
imports = [ <stockholm/krebs/3modules/permown.nix> ];
fileSystems.${flixLocation} = { fileSystems.${flixLocation} = {
device = "prism.r:/export"; device = "prism.r:/export";
fsType = "nfs"; fsType = "nfs";
}; };
systemd.user.services.flix-index = { krebs.permown.${cacheLocation} = {
description = "Flix indexing service"; owner = config.users.users.me.name;
after = [ "network.target" ]; group = "users";
wantedBy = [ "default.target" ]; umask = "0000";
script = '' };
cachedir="${config.users.users.me.home}/.cache"
flix_cache="$cachedir/flix_index"
[ -d "$cachedir" ] || mkdir -p "$cachedir" systemd.services.flix-index = {
description = "Flix indexing service";
wants = [ "network-online.target" ];
script = ''
flix_cache="${cacheLocation}/flix_index"
find ${flixLocation} -type f > "$flix_cache" find ${flixLocation} -type f > "$flix_cache"
''; '';
startAt = "hourly"; startAt = "hourly";
serviceConfig = { serviceConfig.Type = "oneshot";
Type = "oneshot";
User = config.users.users.me.name;
};
}; };
environment.systemPackages = [ environment.systemPackages = [
(pkgs.writeDashBin "flixmenu" '' (pkgs.writeDashBin "flixmenu" ''
set -efu set -efu
cachedir="${config.users.users.me.home}/.cache" flix_cache="${cacheLocation}/flix_index"
flix_cache="$cachedir/flix_index"
[ -f "$flix_cache" ] || exit 1 [ -f "$flix_cache" ] || exit 1
${pkgs.dmenu}/bin/dmenu -i -p flix -l 5 "$@" < "$flix_cache" \ ${pkgs.dmenu}/bin/dmenu -i -p flix -l 5 "$@" < "$flix_cache" \
| ${pkgs.findutils}/bin/xargs -I '{}' ${pkgs.xdg_utils}/bin/xdg-open '{}' | ${pkgs.findutils}/bin/xargs -I '{}' ${pkgs.utillinux}/bin/setsid ${pkgs.xdg_utils}/bin/xdg-open '{}'
'') '')
]; ];