summary refs log tree commit diff
path: root/pkgs/os-specific/linux/ldm/default.nix
blob: 072b53b02ec229042183dbca47b4a0c333bf5dde (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
38
39
40
41
42
43
{ lib, stdenv, fetchgit, udev, util-linux, mountPath ? "/media/" }:

assert mountPath != "";

let
  version = "0.5";
  git = "https://github.com/LemonBoy/ldm.git";
in
stdenv.mkDerivation rec {
  pname = "ldm";
  inherit version;

  # There is a stable release, but we'll use the lvm branch, which
  # contains important fixes for LVM setups.
  src = fetchgit {
    url = meta.repositories.git;
    rev = "refs/tags/v${version}";
    sha256 = "0lxfypnbamfx6p9ar5k9wra20gvwn665l4pp2j4vsx4yi5q7rw2n";
  };

  buildInputs = [ udev util-linux ];

  postPatch = ''
    substituteInPlace ldm.c \
      --replace "/mnt/" "${mountPath}"
    sed '16i#include <sys/stat.h>' -i ldm.c
  '';

  buildFlags = [ "ldm" ];

  installPhase = ''
    mkdir -p $out/bin
    cp -v ldm $out/bin
  '';

  meta = {
    description = "A lightweight device mounter, with libudev as only dependency";
    license = lib.licenses.mit;

    platforms = lib.platforms.linux;
    repositories.git = git;
  };
}