1{ lib, stdenv, fetchFromGitHub, autoreconfHook, installShellFiles, util-linux }:
2
3stdenv.mkDerivation rec {
4 pname = "swapspace";
5 version = "1.18";
6
7 src = fetchFromGitHub {
8 owner = "Tookmund";
9 repo = "Swapspace";
10 rev = "v${version}";
11 sha256 = "sha256-tzsw10cpu5hldkm0psWcFnWToWQejout/oGHJais6yw=";
12 };
13
14 nativeBuildInputs = [
15 autoreconfHook
16 installShellFiles
17 ];
18
19 postPatch = ''
20 substituteInPlace 'swapspace.service' \
21 --replace '/usr/local/sbin/' "$out/bin/"
22 substituteInPlace 'src/support.c' \
23 --replace '/sbin/swapon' '${lib.getBin util-linux}/bin/swapon' \
24 --replace '/sbin/swapoff' '${lib.getBin util-linux}/bin/swapoff'
25 substituteInPlace 'src/swaps.c' \
26 --replace 'mkswap' '${lib.getBin util-linux}/bin/mkswap'
27
28 # Don't create empty directory $out/var/lib/swapspace
29 substituteInPlace 'Makefile.am' \
30 --replace 'install-data-local:' 'do-not-execute:'
31 '';
32
33 postInstall = ''
34 installManPage doc/swapspace.8
35 install --mode=444 -D 'swapspace.service' "$out/etc/systemd/system/swapspace.service"
36 '';
37
38 meta = with lib; {
39 description = "Dynamic swap manager for Linux";
40 homepage = "https://github.com/Tookmund/Swapspace";
41 license = licenses.gpl2Only;
42 platforms = platforms.linux;
43 maintainers = with maintainers; [ misuzu Luflosi ];
44 };
45}