summaryrefslogtreecommitdiff
path: root/custom/run-opossum@bragi.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-06-17 14:51:10 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-06-17 14:51:10 +0200
commit8605a066d9eee11a5be37178434848d7b553e27d (patch)
tree78802b29cef39ba5b4fb478f74f31373c4f7c613 /custom/run-opossum@bragi.nix
parent14491e42011baa2bea5e8bcd954b0a86648d99da (diff)
downloadnixos-8605a066d9eee11a5be37178434848d7b553e27d.tar
nixos-8605a066d9eee11a5be37178434848d7b553e27d.tar.gz
nixos-8605a066d9eee11a5be37178434848d7b553e27d.tar.bz2
nixos-8605a066d9eee11a5be37178434848d7b553e27d.tar.xz
nixos-8605a066d9eee11a5be37178434848d7b553e27d.zip
moved version outside block
Diffstat (limited to 'custom/run-opossum@bragi.nix')
-rw-r--r--custom/run-opossum@bragi.nix66
1 files changed, 66 insertions, 0 deletions
diff --git a/custom/run-opossum@bragi.nix b/custom/run-opossum@bragi.nix
new file mode 100644
index 00000000..34452ef7
--- /dev/null
+++ b/custom/run-opossum@bragi.nix
@@ -0,0 +1,66 @@
1{ stdenv
2, zsh
3, findutils
4, coreutils
5, makeWrapper
6, wombat
7, opossum
8}:
9
10let
11 version = "0.0.0";
12in stdenv.mkDerivation {
13 name = "run-opossum-${version}";
14 buildInputs = [ makeWrapper ];
15 src = builtins.toFile name ''
16 #!${zsh}/bin/zsh
17
18 oversized() {
19 l=$(du -BG -s -t 75 $BEUTEL | wc -l)
20 [[ $l -ge 1 ]]
21 }
22
23 echo "Started $(date)" > $LOGFILE
24 opossum &>> $LOGFILE
25
26 wombat search "(not (seen or hidden)) and (not forced)" | \
27 xargs -r -n 1 -d '\n' -- wombat force \
28 &>> $LOGFILE
29
30 find $BEUTEL -type f -iname '*.tgz.bak' -delete
31
32 if oversized; then
33 wombat search "(seen or hidden) and forced" | \
34 while (read file && oversized); do
35 wombat reset $file
36 find $BEUTEL -type f -iname '*.tgz.bak' -delete
37 done
38
39 wombat search "seen or hidden" | \
40 while (read file && oversized); do
41 wombat delete $file
42 size=$(du -BG $BEUTEL)
43 done
44 fi
45
46 echo "Ended $(date)" >> $LOGFILE
47 '';
48 phases = [ "buildPhase"
49 "installPhase"
50 ];
51 buildPhase = ''
52 cp -prd --no-preserve=timestamps $src run-opossum
53 '';
54 installPhase = ''
55 mkdir -p $out/bin
56 cp run-opossum.sh $out/bin
57 chmod +x $out/bin/run-opossum
58 wrapProgram $out/bin/run-opossum \
59 --prefix PATH : ${wombat}/bin \
60 --prefix PATH : ${opossum}/bin \
61 --prefix PATH : ${findutils}/bin \
62 --prefix PATH : ${coreutils}/bin \
63 --set BEUTEL $HOME/.beutel \
64 --set LOGFILE $HOME/.last_opossum.log
65 '';
66}