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