nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 cleanPackaging,
5 fetchurl,
6 nix-update-script,
7}:
8{
9 # : string
10 pname,
11 # : string
12 version,
13 # : string
14 sha256 ? lib.fakeSha256,
15 # : drv | null
16 manpages ? null,
17 # : string
18 description,
19 # : list Platform
20 platforms ? lib.platforms.all,
21 # : list string
22 outputs ? [
23 "bin"
24 "lib"
25 "dev"
26 "doc"
27 "out"
28 ],
29 # TODO(Profpatsch): automatically infer most of these
30 # : list string
31 configureFlags,
32 # : string
33 postConfigure ? null,
34 # mostly for moving and deleting files from the build directory
35 # : lines
36 postInstall,
37 # : list Maintainer
38 maintainers ? [ ],
39 # : passthru arguments (e.g. tests)
40 passthru ? { },
41 # : attributes to be merged into meta
42 broken ? false,
43}:
44
45let
46
47 # File globs that can always be deleted
48 commonNoiseFiles = [
49 ".gitignore"
50 "Makefile"
51 "INSTALL"
52 "configure"
53 "patch-for-solaris"
54 "src/**/*"
55 "tools/**/*"
56 "package/**/*"
57 "config.mak"
58 ];
59
60 # File globs that should be moved to $doc
61 commonMetaFiles = [
62 "COPYING"
63 "AUTHORS"
64 "NEWS"
65 "CHANGELOG"
66 "README"
67 "README.*"
68 "DCO"
69 "CONTRIBUTING"
70 ];
71
72in
73stdenv.mkDerivation {
74 inherit pname version;
75
76 src = fetchurl {
77 url = "https://skarnet.org/software/${pname}/${pname}-${version}.tar.gz";
78 inherit sha256;
79 };
80
81 outputs =
82 if manpages == null then
83 outputs
84 else
85 assert (
86 lib.assertMsg (!lib.elem "man" outputs)
87 "If you pass `manpages` to `skawarePackages.buildPackage`, you cannot have a `man` output already!"
88 );
89 # insert as early as possible, but keep the first element
90 if lib.length outputs > 0 then
91 [
92 (lib.head outputs)
93 "man"
94 ]
95 ++ lib.tail outputs
96 else
97 [ "man" ];
98
99 dontDisableStatic = true;
100 enableParallelBuilding = true;
101
102 configureFlags =
103 configureFlags
104 ++ [
105 "--enable-absolute-paths"
106 # We assume every nix-based cross target has urandom.
107 # This might not hold for e.g. BSD.
108 "--with-sysdep-devurandom=yes"
109 (if stdenv.hostPlatform.isDarwin then "--disable-shared" else "--enable-shared")
110 ]
111 # On darwin, the target triplet from -dumpmachine includes version number,
112 # but skarnet.org software uses the triplet to test binary compatibility.
113 # Explicitly setting target ensures code can be compiled against a skalibs
114 # binary built on a different version of darwin.
115 # http://www.skarnet.org/cgi-bin/archive.cgi?1:mss:623:heiodchokfjdkonfhdph
116 ++ (lib.optional stdenv.hostPlatform.isDarwin "--build=${stdenv.hostPlatform.system}");
117
118 inherit postConfigure;
119
120 makeFlags = lib.optionals stdenv.cc.isClang [
121 "AR=${stdenv.cc.targetPrefix}ar"
122 "RANLIB=${stdenv.cc.targetPrefix}ranlib"
123 ];
124
125 # TODO(Profpatsch): ensure that there is always a $doc output!
126 postInstall = ''
127 echo "Cleaning & moving common files"
128 ${
129 cleanPackaging.commonFileActions {
130 noiseFiles = commonNoiseFiles;
131 docFiles = commonMetaFiles;
132 }
133 } $doc/share/doc/${pname}
134
135 ${
136 if manpages == null then
137 ''echo "no manpages for this package"''
138 else
139 ''
140 echo "copying manpages"
141 cp -vr ${manpages} $man
142 ''
143 }
144
145 ${postInstall}
146 '';
147
148 postFixup = ''
149 ${cleanPackaging.checkForRemainingFiles}
150 '';
151
152 passthru = {
153 updateScript = nix-update-script {
154 extraArgs = [
155 "--url"
156 "https://github.com/skarnet/${pname}"
157 "--override-filename"
158 "pkgs/development/skaware-packages/${pname}/default.nix"
159 ];
160 };
161 }
162 // passthru
163 // (if manpages == null then { } else { inherit manpages; });
164
165 meta = {
166 homepage = "https://skarnet.org/software/${pname}/";
167 inherit broken description platforms;
168 license = lib.licenses.isc;
169 maintainers =
170 with lib.maintainers;
171 [
172 pmahoney
173 Profpatsch
174 qyliss
175 ]
176 ++ maintainers;
177 };
178
179}