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