collectd: fix build and modernize derivation slightly

1. I experienced intermittent connection failures to <https://collectd.org> and I suspect it's hosted on hobbyist equipment.
This made the `src` derivation flaky, so I switched to the upstream GitHub repository.
It seems better to use the actual source instead of a prepared tarball from the release process anyway.

2. When building out of the source instead of the release tarball, we need to run Bison and Flex to generate the parser and lexer, and we need Perl for `pod2man`.

3. As the [build error on Hydra](https://hydra.nixos.org/build/300269816) notes, `src/virt.c` makes use of some token `ATTRIBUTE_UNUSED` but it's not defined anywhere. Define it.

4. Switch all hashes to use the SRI style.

5. Switch to `finalAttrs` fixpoint style for better overriding.

6. Reduce the scope of `with lib;` in the `meta` section.

Bit of a smörgåsbord but not too bad.

authored by philiptaron.tngl.sh and committed by Bjørn Forsman 97734f4a 18975e6d

+27 -13
+27 -13
pkgs/tools/system/collectd/default.nix
··· 1 { 2 lib, 3 stdenv, 4 - fetchurl, 5 fetchpatch, 6 callPackage, 7 autoreconfHook, 8 pkg-config, 9 libtool, 10 nixosTests, 11 ... 12 }@args: 13 let 14 plugins = callPackage ./plugins.nix args; 15 in 16 - stdenv.mkDerivation rec { 17 version = "5.12.0"; 18 - pname = "collectd"; 19 20 - src = fetchurl { 21 - url = "https://collectd.org/files/${pname}-${version}.tar.bz2"; 22 - sha256 = "1mh97afgq6qgmpvpr84zngh58m0sl1b4wimqgvvk376188q09bjv"; 23 }; 24 25 patches = [ 26 # fix -t never printing syntax errors 27 # should be included in next release 28 (fetchpatch { 29 url = "https://github.com/collectd/collectd/commit/3f575419e7ccb37a3b10ecc82adb2e83ff2826e1.patch"; 30 - sha256 = "0jwjdlfl0dp7mlbwygp6h0rsbaqfbgfm5z07lr5l26z6hhng2h2y"; 31 }) 32 (fetchpatch { 33 name = "no_include_longintrepr.patch"; ··· 39 nativeBuildInputs = [ 40 pkg-config 41 autoreconfHook 42 ]; 43 buildInputs = [ 44 libtool 45 ] ++ plugins.buildInputs; ··· 52 ++ plugins.configureFlags 53 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ "--with-fp-layout=nothing" ]; 54 55 # do not create directories in /var during installPhase 56 postConfigure = '' 57 - substituteInPlace Makefile --replace '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/' '#' 58 ''; 59 60 postInstall = '' ··· 69 inherit (nixosTests) collectd; 70 }; 71 72 - meta = with lib; { 73 description = "Daemon which collects system performance statistics periodically"; 74 homepage = "https://collectd.org"; 75 - license = licenses.gpl2Plus; 76 - platforms = platforms.unix; 77 - maintainers = with maintainers; [ bjornfor ]; 78 }; 79 - }
··· 1 { 2 lib, 3 stdenv, 4 + fetchFromGitHub, 5 fetchpatch, 6 callPackage, 7 autoreconfHook, 8 pkg-config, 9 libtool, 10 + bison, 11 + flex, 12 + perl, 13 nixosTests, 14 ... 15 }@args: 16 let 17 plugins = callPackage ./plugins.nix args; 18 in 19 + stdenv.mkDerivation (finalAttrs: { 20 + pname = "collectd"; 21 version = "5.12.0"; 22 23 + src = fetchFromGitHub { 24 + owner = "collectd"; 25 + repo = "collectd"; 26 + tag = "collectd-${finalAttrs.version}"; 27 + hash = "sha256-UTlCY1GPRpbdQFLFUDjNr1PgEdGv4WNtjr8TYbxHK5A="; 28 }; 29 30 + # All of these are going to be included in the next release 31 patches = [ 32 # fix -t never printing syntax errors 33 # should be included in next release 34 (fetchpatch { 35 + name = "fix-broken-dash-t-option.patch"; 36 url = "https://github.com/collectd/collectd/commit/3f575419e7ccb37a3b10ecc82adb2e83ff2826e1.patch"; 37 + hash = "sha256-XkDxLITmG0FLpgf8Ut1bDqulM4DmPs8Xrec2QB1tkks="; 38 }) 39 (fetchpatch { 40 name = "no_include_longintrepr.patch"; ··· 46 nativeBuildInputs = [ 47 pkg-config 48 autoreconfHook 49 + bison 50 + flex 51 + perl # for pod2man 52 ]; 53 + 54 buildInputs = [ 55 libtool 56 ] ++ plugins.buildInputs; ··· 63 ++ plugins.configureFlags 64 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ "--with-fp-layout=nothing" ]; 65 66 + # Used in `src/virt.c` 67 + env.NIX_CFLAGS_COMPILE = "-DATTRIBUTE_UNUSED=__attribute__((unused))"; 68 + 69 # do not create directories in /var during installPhase 70 postConfigure = '' 71 + substituteInPlace Makefile --replace-fail '$(mkinstalldirs) $(DESTDIR)$(localstatedir)/' '#' 72 ''; 73 74 postInstall = '' ··· 83 inherit (nixosTests) collectd; 84 }; 85 86 + meta = { 87 description = "Daemon which collects system performance statistics periodically"; 88 homepage = "https://collectd.org"; 89 + license = lib.licenses.gpl2Plus; 90 + platforms = lib.platforms.unix; 91 + maintainers = with lib.maintainers; [ bjornfor ]; 92 }; 93 + })