summary refs log tree commit diff
path: root/pkgs/os-specific/linux/sdnotify-wrapper/default.nix
blob: cf09f0476767f130b80154266cb4b40362fc8818 (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
{ lib, runCommandCC, skawarePackages }:

with skawarePackages;

let
  # From https://skarnet.org/software/misc/sdnotify-wrapper.c,
  # which is unversioned.
  src = ./sdnotify-wrapper.c;

in runCommandCC "sdnotify-wrapper" {

   outputs = [ "bin" "doc" "out" ];

   meta = {
     homepage = "https://skarnet.org/software/misc/sdnotify-wrapper.c";
     description = "Use systemd sd_notify without having to link against libsystemd";
     platforms = lib.platforms.all;
     license = lib.licenses.isc;
     maintainers = with lib.maintainers; [ Profpatsch ];
   };

} ''
  mkdir -p $bin/bin
  mkdir $out

  # the -lskarnet has to come at the end to support static builds
  $CC \
    -o $bin/bin/sdnotify-wrapper \
    -I${skalibs.dev}/include \
    -L${skalibs.lib}/lib \
    ${src} \
    -lskarnet

  mkdir -p $doc/share/doc/sdnotify-wrapper
  # copy the documentation comment
  sed -ne '/Usage:/,/*\//p' ${src} > $doc/share/doc/sdnotify-wrapper/README
''