-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
104 lines (102 loc) · 3.15 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{ pkgs, srcs, ... }:
let
nnnWrapped = (pkgs.nnn.override {
withPcre = true;
}).overrideAttrs (old: {
src = srcs.nnn-src;
# Apply the:
# - `cd on quit` logic
# - configuration envvars
# - default to cwd when no args are specified
# We have to do this shitty hack postInstall in order to work with the
# home-manager module.
postInstall = old.postInstall + ''
mv $out/bin/nnn $out/bin/.nnn-unwrapped
# Echo the main script body without evaluating the script ('EOF' does
# that). This way variables are preserved for real runtime.
cat - > $out/bin/nnn <<'EOF'
#!${pkgs.bash}/bin/bash
[ "''${NNNLVL:-0}" -eq 0 ] || {
echo "nnn is already running"
exit 0
}
export NNN_OPTS=aAERx
# Because nnn.nvim requires its own FIFO, we disable auto-FIFO when -F is passed.
if [[ "$@" == *"-F1"* ]]; then
export NNN_OPTS=AERx
fi
export NNN_COLORS=4532
export NNN_FCOLORS=0a0b04010f07060c05030d09
export NNN_TMPFILE=$XDG_RUNTIME_DIR/nnn-lastd
export NNN_PREVIEWDIR=/home/blissful/.cache/nsxiv
export NNN_ORDER="V:/home/blissful/music/1. Releases - Added On;V:/home/blissful/music/1. Releases - Released On"
# Dynamically set an order for every subdirectory in the following directories:
export NNN_ORDER="$NNN_ORDER;$(${pkgs.findutils}/bin/find /home/blissful/images/ -mindepth 1 -maxdepth 1 -type d -printf 't:%p;' | ${pkgs.gnused}/bin/sed 's/;$//')"
export NNN_ORDER="$NNN_ORDER;$(${pkgs.findutils}/bin/find /home/blissful/studies/ -type d -printf 'v:%p;' | ${pkgs.gnused}/bin/sed 's/;$//')"
export NNN_ORDER="$NNN_ORDER;$(${pkgs.findutils}/bin/find /home/blissful/books/ -type d -printf 'v:%p;' | ${pkgs.gnused}/bin/sed 's/;$//')"
EOF
# And now echo the final program call but with evaluation (so that $out gets evaluated).
cat - >> $out/bin/nnn <<EOF
$out/bin/.nnn-unwrapped "\''${@:-.}"
EOF
cat - >> $out/bin/nnn <<'EOF'
[ ! -f "$NNN_TMPFILE" ] || {
. "$NNN_TMPFILE"
rm -f "$NNN_TMPFILE" > /dev/null
}
EOF
chmod +x $out/bin/nnn
'';
});
in
{
programs.nnn = {
enable = true;
package = nnnWrapped;
extraPackages = with pkgs; [
atool
bat
coreutils
ffmpegthumbnailer
file
fontpreview
glow
gnome-epub-thumbnailer
html2text
imagemagick
jq
mediainfo
mpv
nsxiv
p7zip
poppler_utils
unrar
unzip
w3m
];
plugins = {
mappings = {
";" = "preview-tui";
c = "copy-highlighted";
f = "fzopen";
i = "imgview";
r = "rose";
};
# We vendor plugins in order to be able to add our own.
src = ./plugins;
};
bookmarks = {
b = "~/books";
c = "~/music/3. Genres/Classical Music";
d = "~/downloads";
e = "/mnt/elements";
i = "~/images";
k = "~/music/3. Genres/K-Pop";
K = "~/kpop";
m = "~/music";
M = "~/.music-source";
p = "~/music/7. Playlists";
s = "~/studies";
};
};
}