summaryrefslogtreecommitdiff
path: root/custom/uucp-mediaserver/scripts.nix
blob: 1766f1b2351c7748ef74b9dd76588f228425dbdf (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
{ stdenv, zsh, config }:

with stdenv.lib;

let
  mkSymlinks = name: ''
    ln -s $out/libexec/mediaspace $out/bin/mediaspace.${name}
    ln -s $out/libexec/queue $out/bin/queue.${name}
    ln -s $out/libexec/queuesize $out/bin/queuesize.${name}
    ln -s $out/libexec/queuestatus $out/bin/queuestatus.${name}
    ln -s $out/libexec/update-queuesize $out/bin/update-queuesize.${name}
  '';
in stdenv.mkDerivation {
  name = "uucp-mediaserver";
  src = ./scripts;

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

  inherit (config) queueDir;
  inherit zsh;

  buildPhase = ''
    substituteAllInPlace mediaspace
    substituteAllInPlace queue
    substituteAllInPlace queuesize
    substituteAllInPlace queuestatus
    substituteAllInPlace update-queuesize
  '';
  
  installPhase = ''
    mkdir -p $out/libexec

    install -m 755 -t $out/libexec mediaspace queue queuesize queuestatus update-queuesize
  
    mkdir -p $out/bin

    ${concatStringsSep "\n" (map mkSymlinks config.remoteNodes)}
  '';
}