1{ lib, stdenv, fetchgit, udev, util-linux, mountPath ? "/media/" }:
2
3assert mountPath != "";
4
5let
6 version = "0.5";
7in
8stdenv.mkDerivation rec {
9 pname = "ldm";
10 inherit version;
11
12 # There is a stable release, but we'll use the lvm branch, which
13 # contains important fixes for LVM setups.
14 src = fetchgit {
15 url = "https://github.com/LemonBoy/ldm";
16 rev = "refs/tags/v${version}";
17 sha256 = "0lxfypnbamfx6p9ar5k9wra20gvwn665l4pp2j4vsx4yi5q7rw2n";
18 };
19
20 buildInputs = [ udev util-linux ];
21
22 postPatch = ''
23 substituteInPlace ldm.c \
24 --replace "/mnt/" "${mountPath}"
25 sed '16i#include <sys/stat.h>' -i ldm.c
26 '';
27
28 buildFlags = [ "ldm" ];
29
30 installPhase = ''
31 mkdir -p $out/bin
32 cp -v ldm $out/bin
33 '';
34
35 meta = {
36 description = "Lightweight device mounter, with libudev as only dependency";
37 mainProgram = "ldm";
38 license = lib.licenses.mit;
39 platforms = lib.platforms.linux;
40 };
41}