summaryrefslogtreecommitdiff
path: root/odin/strm.nix
blob: 094da07c2adbfe0533b897e22ffaff1a3fe59e4c (plain)
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
{ stdenv, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email, buildPerlPackage, perlPackages }:

let
  manual-youtube = buildPerlPackage {
    name = "manual_youtube";
  
    src = ./strm/manual_youtube;

    outputs = [ "out" ];
    phases = [ "unpackPhase" "configurePhase" "buildPhase" "installPhase" "fixupPhase" ];

    unpackPhase = ''
      cp $src manual_youtube

      cat >Makefile.PL <<EOF
      #!/usr/bin/env perl
      
      EOF
    '';

    configurePhase = ''
      preConfigure
    '';

    youtubedl = youtube-dl;

    buildPhase = ''
      substituteAllInPlace manual_youtube
    '';

    installPhase = ''
      mkdir -p $out/bin
    
      install -m 755 -t $out/bin \
        manual_youtube
    '';

    propagatedBuildInputs = with perlPackages; [ EmailMIME EmailDateFormat ];
  };
in stdenv.mkDerivation {
  name = "strm";
  src = ./strm;

  phases = [ "unpackPhase" "buildPhase" "installPhase" ];

  inherit zsh pv notmuch rss2email;
  ffmpeg = ffmpeg-full;
  youtubedl = youtube-dl;

  buildPhase = ''
    substituteAllInPlace download_youtube
    substituteAllInPlace cleanup_youtube
    substituteAllInPlace send_media
    substituteAllInPlace cache_media
    substituteAllInPlace send_kitty
    substituteAllInPlace rss_staggered
  '';

  installPhase = ''
    mkdir -p $out/bin

    install -m 755 -t $out/bin \
      download_youtube \
      cleanup_youtube \
      send_media \
      cache_media \
      send_kitty \
      rss_staggered

    ln -s ${manual-youtube}/bin/manual_youtube $out/bin
  '';
}