nix package definition for development
[oweals/gnunet.git] / default.nix
1 # Nix package for GNUnet development
2 #
3 ## INSTALL
4 #
5 # To build and install the package in the user environment, use:
6 #
7 # $ nix-env -f . -i
8 #
9 ## BUILD ONLY
10 #
11 # To build the package and add it to the nix store, use:
12 #
13 # $ nix-build
14 #
15 ## SHELL
16 #
17 # To launch a shell with all dependencies installed in the environment, use one of the following:
18 #    $ nix-shell
19 #
20 # After entering nix-shell, build it:
21 #
22 # $ configurePhase
23 # $ buildPhase
24 #
25 ## NIXPKGS
26 #
27 # For all of the above commands, nixpkgs to use can be set the following way:
28 #
29 # a) by default it uses nixpkgs pinned to a known working version
30 #
31 # b) use nixpkgs from the system:
32 #    --arg pkgs 0
33 #
34 # c) use nixpkgs at a given path
35 #    --arg pkgs /path/to/nixpkgs
36 #
37
38 { pkgs ? null }:
39
40 let
41   syspkgs = import <nixpkgs> { };
42   pinpkgs = syspkgs.fetchFromGitHub {
43     owner = "NixOS";
44     repo = "nixpkgs";
45
46     # binary cache exists for revisions in https://nixos.org/releases/nixos/<release>/<build>/git-revision
47     rev = "c4469edac1fc1fa5e5b5aa2ceadeda8f3f92d30a"; # https://nixos.org/releases/nixos/16.09/nixos-16.09beta430.c4469ed/git-revision
48     sha256 = "1x6hmf815d5anfxrxl6iivfkk60q5qxa6waa9xnwhwkbc14rhvn9";
49   };
50   usepkgs = if null == pkgs then
51              import pinpkgs {}
52             else
53               if 0 == pkgs then
54                 import <nixpkgs> { }
55               else
56                 import pkgs {};
57
58 in with usepkgs; usepkgs.stdenv.mkDerivation rec {
59   src = ./.;
60   name = "gnunet-dev";
61
62   buildInputs = [
63     makeWrapper pkgconfig
64     adns curl gettext gmp gnutls gss ncurses openldap zlib sqlite mariadb postgresql
65     libextractor libgcrypt libgnurl libidn libmicrohttpd
66     libpsl libtool libunistring libxml2
67   ];
68
69   patchPhase = ''
70     test -e Makefile && make distclean
71   '';
72
73   configureFlags = [
74     "--enable-gcc-hardening"
75     "--enable-linker-hardening"
76
77     "--enable-experimental"
78     "--enable-logging=verbose"
79     "--enable-poisoning"
80   ];
81
82   preConfigure = ''
83     ./bootstrap
84     configureFlags="$configureFlags --with-nssdir=$out/lib"
85   '';
86
87   doCheck = false;
88
89   postInstall = ''
90     # Tests can be run this way
91     #export GNUNET_PREFIX="$out"
92     #export PATH="$out/bin:$PATH"
93     #make -k check
94   '';
95
96   meta = with stdenv.lib; {
97     description = "GNU's decentralized anonymous and censorship-resistant P2P framework";
98
99     longDescription = ''
100       GNUnet is a framework for secure peer-to-peer networking that
101       does not use any centralized or otherwise trusted services.  A
102       first service implemented on top of the networking layer
103       allows anonymous censorship-resistant file-sharing.  Anonymity
104       is provided by making messages originating from a peer
105       indistinguishable from messages that the peer is routing.  All
106       peers act as routers and use link-encrypted connections with
107       stable bandwidth utilization to communicate with each other.
108       GNUnet uses a simple, excess-based economic model to allocate
109       resources.  Peers in GNUnet monitor each others behavior with
110       respect to resource usage; peers that contribute to the
111       network are rewarded with better service.
112     '';
113
114     homepage = http://gnunet.org/;
115
116     license = licenses.gpl3Plus;
117     platforms = platforms.gnu;
118     maintainers = with maintainers; [ ];
119   };
120 }