nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 fetchurl,
6 fetchpatch,
7 meson,
8 ninja,
9 m4,
10 gperf,
11 getent,
12 acl,
13 audit,
14 dbus,
15 libcap,
16 libselinux,
17 pam,
18 gettext,
19 pkg-config,
20 udev,
21 eudev,
22 util-linux,
23 libxslt,
24 python3Packages,
25 docbook5,
26 docbook_xsl,
27 docbook_xsl_ns,
28 docbook_xml_dtd_42,
29 docbook_xml_dtd_45,
30 udevCheckHook,
31
32 # Defaulting to false because usually the rationale for using elogind is to
33 # use it in situation where a systemd dependency does not work (especially
34 # when building with musl, which elogind explicitly supports).
35 enableSystemd ? false,
36}:
37
38stdenv.mkDerivation rec {
39 pname = "elogind";
40 version = "255.5";
41
42 src = fetchFromGitHub {
43 owner = "elogind";
44 repo = "elogind";
45 rev = "v${version}";
46 hash = "sha256-4KZr/NiiGVwzdDROhiX3GEQTUyIGva6ezb+xC2U3bkg=";
47 };
48
49 nativeBuildInputs = [
50 meson
51 ninja
52 m4
53 pkg-config
54 gperf
55 getent
56 libcap
57 gettext
58 libxslt.bin # xsltproc
59 docbook5
60 docbook_xsl
61 docbook_xsl_ns
62 docbook_xml_dtd_42
63 docbook_xml_dtd_45 # needed for docbook without Internet
64
65 python3Packages.python
66 python3Packages.jinja2
67 ]
68 ++ lib.optionals enableSystemd [
69 # udevCheckHook introduces a dependency on systemdMinimal
70 udevCheckHook
71 ];
72
73 buildInputs = [
74 acl
75 audit
76 dbus
77 libcap
78 libselinux
79 pam
80 util-linux
81 ]
82 ++ (if enableSystemd then [ udev ] else [ eudev ]);
83
84 postPatch = ''
85 substituteInPlace meson.build --replace-fail "install_emptydir(elogindstatedir)" ""
86 '';
87
88 patches = [
89 (fetchurl {
90 url = "https://github.com/chimera-linux/cports/raw/49d65fe38be815b9918a15ac2d2ff2b123fc559a/main/elogind/patches/strerror_r.patch";
91 hash = "sha256-amqXP12mLtrkWuAURb3/aoQeeTSRYlYqL2q2zrKbhxk=";
92 })
93 (fetchurl {
94 url = "https://github.com/chimera-linux/cports/raw/49d65fe38be815b9918a15ac2d2ff2b123fc559a/main/elogind/patches/strerror_r_1.patch";
95 hash = "sha256-tVUlmPValUPApqRX+Cqkzn7bkIILYSuCouvgRsdl9XE=";
96 })
97 (fetchpatch {
98 url = "https://github.com/chimera-linux/cports/raw/49d65fe38be815b9918a15ac2d2ff2b123fc559a/main/elogind/patches/xxx-musl-fixes.patch";
99 includes = [
100 "src/basic/missing_prctl.h"
101 "src/libelogind/sd-journal/journal-file.h"
102 ];
103 hash = "sha256-JYPB9AKbQpVgid5BhwBTvcebE5rxDFRMYhKRNS8KPTc=";
104 })
105 (fetchurl {
106 url = "https://github.com/chimera-linux/cports/raw/49d65fe38be815b9918a15ac2d2ff2b123fc559a/main/elogind/patches/gshadow.patch";
107 hash = "sha256-YBy1OeWD1EluLTeUvqUvZKyrZyoUbGg1mxwqG5+VNO0=";
108 })
109 (fetchurl {
110 name = "FTW.patch";
111 url = "https://git.openembedded.org/openembedded-core/plain/meta/recipes-core/systemd/systemd/0005-add-missing-FTW_-macros-for-musl.patch?id=6bc5e3f3cd882c81c972dbd27aacc1ce00e5e59a";
112 hash = "sha256-SGvP0GT43vfyHxrmvl4AbsWQz8CPmNGyH001s3lTxng=";
113 })
114 (fetchurl {
115 name = "malloc_info.patch";
116 url = "https://git.openembedded.org/openembedded-core/plain/meta/recipes-core/systemd/systemd/0016-pass-correct-parameters-to-getdents64.patch?id=6bc5e3f3cd882c81c972dbd27aacc1ce00e5e59a";
117 hash = "sha256-8aOw+BTtl5Qta8aqLmliKSHEirTjp1xLM195EmBdEDI=";
118 })
119 (fetchpatch {
120 name = "malloc_trim.patch";
121 url = "https://git.openembedded.org/openembedded-core/plain/meta/recipes-core/systemd/systemd/0020-sd-event-Make-malloc_trim-conditional-on-glibc.patch?id=6bc5e3f3cd882c81c972dbd27aacc1ce00e5e59a";
122 stripLen = 3;
123 extraPrefix = [ "src/libelogind/" ];
124 hash = "sha256-rtSnCEK+frhnlwl/UW3YHxB8MUCAq48jEzQRURpxdXk=";
125 })
126 (fetchurl {
127 name = "malloc_info.patch";
128 url = "https://git.openembedded.org/openembedded-core/plain/meta/recipes-core/systemd/systemd/0021-shared-Do-not-use-malloc_info-on-musl.patch?id=6bc5e3f3cd882c81c972dbd27aacc1ce00e5e59a";
129 hash = "sha256-ZyOCmM5LcwJ7mHiZr0lQjV4G+XMxjhsUm7g7L3OzDDM=";
130 })
131 ./Add-missing-musl_missing.h-includes-for-basename.patch
132 ./Remove-outdated-musl-hack-in-rlimit_nofile_safe.patch
133 ];
134
135 # Inspired by the systemd `preConfigure`.
136 # Conceptually we should patch all files required during the build, but not scripts
137 # supposed to run at run-time of the software (important for cross-compilation).
138 # This package seems to have mostly scripts that run at build time.
139 preConfigure = ''
140 for dir in tools src/test; do
141 patchShebangs $dir
142 done
143
144 patchShebangs src/basic/generate-*.{sh,py}
145 '';
146
147 mesonFlags = [
148 (lib.mesonOption "dbuspolicydir" "${placeholder "out"}/share/dbus-1/system.d")
149 (lib.mesonOption "dbussystemservicedir" "${placeholder "out"}/share/dbus-1/system-services")
150 (lib.mesonOption "sysconfdir" "${placeholder "out"}/etc")
151 (lib.mesonBool "utmp" (!stdenv.hostPlatform.isMusl))
152 (lib.mesonEnable "xenctrl" false)
153 ];
154
155 meta = with lib; {
156 homepage = "https://github.com/elogind/elogind";
157 description = ''The systemd project's "logind", extracted to a standalone package'';
158 platforms = platforms.linux; # probably more
159 license = licenses.lgpl21Plus;
160 maintainers = with maintainers; [ nh2 ];
161 };
162}