base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / fl / flockit / package.nix
blobc1df7f368043eb8e3ba072acfde27558e632c0cd
1 { lib, stdenv, fetchFromGitHub, runtimeShell }:
3 stdenv.mkDerivation {
4   pname = "flockit";
5   version = "2012-08-11";
7   src = fetchFromGitHub {
8     owner  = "smerritt";
9     repo   = "flockit";
10     rev    = "5c2b2092f8edcc8e3e2eb6ef66c968675dbfa686";
11     sha256 = "0vajck9q2677gpn9a4flkyz7mw69ql1647cjwqh834nrcr2b5164";
12   };
14   installPhase = ''
15     mkdir -p $out/lib $out/bin
16     cp ./libflockit.so $out/lib
18     (cat <<EOI
19     #!${runtimeShell}
20     env LD_PRELOAD="$out/lib/libflockit.so" FLOCKIT_FILE_PREFIX=\$1 \''${@:2}
21     EOI
22     ) > $out/bin/flockit
23     chmod +x $out/bin/flockit
24   '';
26   meta = with lib; {
27     description = "LD_PRELOAD shim to add file locking to programs that don't do it (I'm looking at you, rsync!)";
28     mainProgram = "flockit";
29     longDescription = ''
30       This library and tool exists solely because rsync doesn't have file locking.
32       It's not used like a normal library; you don't link against it, and you
33       don't have to patch your source code to use it. It's inserted between your
34       program and its libraries by use of LD_PRELOAD.
36       For example:
38         $ env LD_PRELOAD=$(nix-build -A pkgs.flockit)/lib/libflockit.so FLOCKIT_FILE_PREFIX=test rsync SRC DEST
40       Besides the library a handy executable is provided which can simplify the above to:
42         $ $(nix-build -A pkgs.flockit)/bin/flockit test rsync SRC DEST
44       Also see the following blog post:
45       https://www.swiftstack.com/blog/2012/08/15/old-school-monkeypatching/
46     '';
47     homepage = "https://github.com/smerritt/flockit";
48     license = licenses.asl20;
49     platforms = platforms.linux;
50     maintainers = [ maintainers.basvandijk ];
51   };