at 23.11-beta 51 lines 1.6 kB view raw
1{ lib, stdenv, fetchFromGitHub, runtimeShell }: 2 3stdenv.mkDerivation { 4 pname = "flockit"; 5 version = "2012-08-11"; 6 7 src = fetchFromGitHub { 8 owner = "smerritt"; 9 repo = "flockit"; 10 rev = "5c2b2092f8edcc8e3e2eb6ef66c968675dbfa686"; 11 sha256 = "0vajck9q2677gpn9a4flkyz7mw69ql1647cjwqh834nrcr2b5164"; 12 }; 13 14 installPhase = '' 15 mkdir -p $out/lib $out/bin 16 cp ./libflockit.so $out/lib 17 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 ''; 25 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 longDescription = '' 29 This library and tool exists solely because rsync doesn't have file locking. 30 31 It's not used like a normal library; you don't link against it, and you 32 don't have to patch your source code to use it. It's inserted between your 33 program and its libraries by use of LD_PRELOAD. 34 35 For example: 36 37 $ env LD_PRELOAD=$(nix-build -A pkgs.flockit)/lib/libflockit.so FLOCKIT_FILE_PREFIX=test rsync SRC DEST 38 39 Besides the library a handy executable is provided which can simplify the above to: 40 41 $ $(nix-build -A pkgs.flockit)/bin/flockit test rsync SRC DEST 42 43 Also see the following blog post: 44 https://www.swiftstack.com/blog/2012/08/15/old-school-monkeypatching/ 45 ''; 46 homepage = "https://github.com/smerritt/flockit"; 47 license = licenses.asl20; 48 platforms = platforms.linux; 49 maintainers = [ maintainers.basvandijk ]; 50 }; 51}