From 82dd065f7ab665f3cda63bbe9d7c0d308b649d93 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Tue, 4 Apr 2023 13:20:32 +0200 Subject: [PATCH] swapspace: patch paths to binaries and install systemd unit file This will be useful when creating a NixOS module for this program. --- pkgs/tools/admin/swapspace/default.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/admin/swapspace/default.nix b/pkgs/tools/admin/swapspace/default.nix index 4d961a810a4..49737edf8bf 100644 --- a/pkgs/tools/admin/swapspace/default.nix +++ b/pkgs/tools/admin/swapspace/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, autoreconfHook, installShellFiles }: +{ lib, stdenv, fetchFromGitHub, autoreconfHook, installShellFiles, util-linux }: stdenv.mkDerivation rec { pname = "swapspace"; @@ -16,8 +16,23 @@ stdenv.mkDerivation rec { installShellFiles ]; + postPatch = '' + substituteInPlace 'swapspace.service' \ + --replace '/usr/local/sbin/' "$out/bin/" + substituteInPlace 'src/support.c' \ + --replace '/sbin/swapon' '${lib.getBin util-linux}/bin/swapon' \ + --replace '/sbin/swapoff' '${lib.getBin util-linux}/bin/swapoff' + substituteInPlace 'src/swaps.c' \ + --replace 'mkswap' '${lib.getBin util-linux}/bin/mkswap' + + # Don't create empty directory $out/var/lib/swapspace + substituteInPlace 'Makefile.am' \ + --replace 'install-data-local:' 'do-not-execute:' + ''; + postInstall = '' installManPage doc/swapspace.8 + install --mode=444 -D 'swapspace.service' "$out/etc/systemd/system/swapspace.service" ''; meta = with lib; {