1 { lib, stdenv, fetchFromGitHub, runtimeShell }:
5 version = "2012-08-11";
7 src = fetchFromGitHub {
10 rev = "5c2b2092f8edcc8e3e2eb6ef66c968675dbfa686";
11 sha256 = "0vajck9q2677gpn9a4flkyz7mw69ql1647cjwqh834nrcr2b5164";
15 mkdir -p $out/lib $out/bin
16 cp ./libflockit.so $out/lib
20 env LD_PRELOAD="$out/lib/libflockit.so" FLOCKIT_FILE_PREFIX=\$1 \''${@:2}
23 chmod +x $out/bin/flockit
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";
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.
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/
47 homepage = "https://github.com/smerritt/flockit";
48 license = licenses.asl20;
49 platforms = platforms.linux;
50 maintainers = [ maintainers.basvandijk ];