summary refs log tree commit diff
path: root/pkgs/os-specific/gnu/hurd/default.nix
blob: 4bdb6e132fbb07485d3e8801fa7234c8a3a5d5a7 (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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{ fetchgit, stdenv, autoconf, automake, libtool, texinfo
, machHeaders, mig, headersOnly ? true
, cross ? null, gccCross ? null, glibcCross ? null
, hurdPartedCross ? null, libuuid ? null
, buildTarget ? "all", installTarget ? "install" }:

assert (cross != null) -> (gccCross != null);
assert (hurdPartedCross != null) -> (libuuid != null);

let
  # Unfortunately we can't use `master@{DATE}', see
  # <http://www.bramschoenmakers.nl/en/node/645>.
  date   = "20111115";
  rev    = "969fbb646ffd89a482302e303eaded79781c3331";
  suffix = if headersOnly
           then "-headers"
           else (if buildTarget != "all"
                 then "-minimal"
                 else "");
in
stdenv.mkDerivation ({
  name = "hurd${suffix}-${date}";

  src = fetchgit {
    url = "git://git.sv.gnu.org/hurd/hurd.git";
    sha256 = "b7f57ec2c6dcaf35ec03fb7979eb5506180ce4c6e2edf60a587f12ac5b11f004";
    inherit rev;
  };

  buildInputs = [ autoconf automake libtool texinfo mig ]
    ++ stdenv.lib.optional (hurdPartedCross != null) hurdPartedCross
    ++ stdenv.lib.optional (libuuid != null) libuuid
    ++ stdenv.lib.optional (gccCross != null) gccCross
    ++ stdenv.lib.optional (glibcCross != null) glibcCross;

  propagatedBuildInputs = [ machHeaders ];

  configureFlags = stdenv.lib.optionals headersOnly [ "--build=i586-pc-gnu" ]
    ++ (if hurdPartedCross != null
        then [ "--with-parted" ]
        else [ "--without-parted" ]);

  # Use `preConfigure' only for `autoreconf', so that users know they can
  # simply clear it when the autoconf phase is unneeded.
  preConfigure = "autoreconf -vfi";

  postConfigure =
    '' echo "removing \`-o root' from makefiles..."
       for mf in {utils,daemons}/Makefile
       do
         sed -i "$mf" -e's/-o root//g'
       done
    '';

  crossAttrs.dontPatchShebangs = true;

  meta = {
    description = "The GNU Hurd, GNU project's replacement for the Unix kernel";

    longDescription =
      '' The GNU Hurd is the GNU project's replacement for the Unix kernel.
         It is a collection of servers that run on the Mach microkernel to
         implement file systems, network protocols, file access control, and
         other features that are implemented by the Unix kernel or similar
         kernels (such as Linux).
      '';

    license = stdenv.lib.licenses.gpl2Plus;

    homepage = http://www.gnu.org/software/hurd/;

    maintainers = [ stdenv.lib.maintainers.ludo ];
  };
}

//

(if !headersOnly && buildTarget != null
 then assert installTarget != null; {
   # Use the default `buildPhase' and `installPhase' so that the usual hooks
   # can still be used.
   buildFlags = buildTarget;
   installTargets = installTarget;
 }
 else {})

//

(if headersOnly
 then { buildPhase = ":"; installPhase = "make install-headers"; }
 else (if (cross != null)
       then {
         crossConfig = cross.config;

         # The `configure' script wants to build executables so tell it where
         # to find `crt1.o' et al.
         LDFLAGS = "-B${glibcCross}/lib";
       }
       else { })))