nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromBitbucket
4, mlton
5, pkg-config
6, getopt
7, boehmgc
8, darwin
9, libbacktrace
10, libpng
11, ncurses
12, readline
13}:
14
15stdenv.mkDerivation rec {
16 pname = "c0";
17 version = "unstable-2022-10-25";
18
19 src = fetchFromBitbucket {
20 owner = "c0-lang";
21 repo = "c0";
22 rev = "7ef3bc9ca232ec41936e93ec8957051e48cacfba";
23 sha256 = "sha256-uahF8fOp2ZJE8EhZke46sbPmN0MNHzsLkU4EXkV710U=";
24 };
25
26 patches = [
27 ./use-system-libraries.patch
28 ];
29
30 postPatch = ''
31 substituteInPlace cc0/Makefile \
32 --replace '$(shell ./get_version.sh)' '${version}'
33 substituteInPlace cc0/compiler/bin/buildid \
34 --replace '`../get_version.sh`' '${version}' \
35 --replace '`date`' '1970-01-01T00:00:00Z' \
36 --replace '`hostname`' 'nixpkgs'
37 '' + lib.optionalString stdenv.isDarwin ''
38 for f in cc0/compiler/bin/coin-o0-support cc0/compiler/bin/cc0-o0-support; do
39 substituteInPlace $f --replace '$(brew --prefix gnu-getopt)' '${getopt}'
40 done
41 '';
42
43 preConfigure = ''
44 cd cc0/
45 '';
46
47 nativeBuildInputs = [
48 getopt
49 mlton
50 pkg-config
51 ] ++ lib.optionals stdenv.isDarwin [ darwin.sigtool ];
52
53 buildInputs = [
54 boehmgc
55 libbacktrace
56 libpng
57 ncurses
58 readline
59 ];
60
61 strictDeps = true;
62
63 installFlags = [ "PREFIX=$(out)" ];
64
65 postInstall = ''
66 mkdir -p $out/share/emacs/site-lisp
67 mv $out/c0-mode/ $out/share/emacs/site-lisp/
68 '';
69
70 meta = with lib; {
71 description = "A small safe subset of the C programming language, augmented with contracts";
72 homepage = "https://c0.cs.cmu.edu/";
73 license = licenses.mit;
74 maintainers = [ maintainers.marsam ];
75 platforms = platforms.unix;
76 # line 1: ../../bin/wrappergen: cannot execute: required file not found
77 # make[2]: *** [../../lib.mk:83:
78 broken = stdenv.isLinux;
79 };
80}