summaryrefslogtreecommitdiff
path: root/ymir/mlmmj-expose.nix
blob: 0e9e41a6449adb1fbb952b83fab54b314472ac19 (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
{ config, pkgs, ... }:

let
  dependencies = pkgs: with pkgs; [ filepath
                                    directory
                                    cryptonite
                                    bytestring
                                    uuid
                                    aeson
                                    aeson-pretty
                                    mtl
                                  ];

in rec {
  nixpkgs.overlays = [(self: super: {
    mlmmj-exposed = super.stdenv.mkDerivation rec {
      name = "mlmmj-expose";
      
      src = ./mlmmj-expose;

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

      env = self.haskellPackages.ghcWithPackages dependencies;
      inherit (pkgs) mlmmj;

      patchPhase = ''
        substituteInPlace mlmmj-expose.hs \
          --subst-var mlmmj
      '';

      buildPhase = ''
        ${env}/bin/ghc -o mlmmj-expose -odir . -hidir . mlmmj-expose.hs
      '';

      installPhase = ''
        mkdir -p $out/bin
        cp mlmmj-expose $out/bin/.mlmmj-expose

        for f in mlmmj-exposed mlmmj-expose mlmmj-get-exposed mlmmj-serve-exposed; do
          ln -s .mlmmj-expose $out/bin/$f
        done
      '';
    };
  })];
  environment.systemPackages = with pkgs; [ mlmmj-exposed ];
}