about summary refs log tree commit diff
path: root/default.nix
blob: 2d42a8465a97a9e6f5543a03c913f7a6550f733b (plain) (blame)
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
{ pkgs ? import <nixpkgs> {} }:

let
  hl = pkgs.haskell.lib;

  src = builtins.path {
    name = "spacecookie-source";
    path = ./.;
    filter = pkgs.nix-gitignore.gitignoreFilter
      (builtins.readFile ./.gitignore) ./.;
  };

  profiled = pkgs.haskellPackages.override {
    overrides = self: super: {
      mkDerivation = args: super.mkDerivation (args // {
        enableLibraryProfiling = true;
      });

      spacecookie = hl.overrideCabal
        (self.callPackage ./spacecookie.nix {})
        (drv: {
          version = "unstable";
          # build from sdist to make sure it isn't missing anything
          src = self.cabalSdist {
            src = ./.;
            name = "spacecookie-unstable-sdist.tar.gz";
          };
          # run integration test
          preCheck = ''
            export SPACECOOKIE_TEST_BIN=./dist/build/spacecookie/spacecookie
          '';
          # install man pages
          postInstall = ''
            install -Dm644 docs/man/*.1 -t "$out/share/man/man1"
            install -Dm644 docs/man/*.5 -t "$out/share/man/man5"
          '';
        });
    };
  };

in

if !pkgs.lib.inNixShell
then profiled.spacecookie
else profiled.spacecookie.env