-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flockit: init at 2012-08-11 #27902
flockit: init at 2012-08-11 #27902
Conversation
Off topic. I was hoping for a flockit executable. Having to setup LD_PRELOAD yourself seems more work. |
@bjornfor how about this? Now the following:
can be simplified to:
|
Yes, that's an interface I like. Upstream it? |
cp ./libflockit.so $out/lib | ||
|
||
(cat <<EOI | ||
#!${bash}/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sh
won't do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably would. I will change it to #!/bin/sh
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it.
Do note that #!/bin/sh
is automatically rewritten to #!${pkgs.bash}/bin/sh
during the post-installation fixups:
post-installation fixup
...
/nix/store/fd7sj17pyja2wpm2yh5jzmim8nhkra15-flockit-2012-08-11/bin/flockit: interpreter directive changed from "/bin/sh" to "/nix/store/jjg5zsfjl35b239f6znp0nfa9775qy2a-bash-4.4-p12/bin/sh"
chmod +x $out/bin/flockit | ||
''; | ||
|
||
meta = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to build on Darwin (see TravisCI), so should probably have a platform
attribute to limit its exposure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I will add it.
The flockit library and tool exists solely because rsync doesn't have file locking. It's not used like a normal library; you don't link against it, and you don't have to patch your source code to use it. It's inserted between your program and its libraries by use of LD_PRELOAD. For example: $ env LD_PRELOAD=$(nix-build -A pkgs.flockit)/lib/libflockit.so FLOCKIT_FILE_PREFIX=test rsync SRC DEST Besides the library a handy executable is provided which can simplify the above to: $ $(nix-build -A pkgs.flockit)/bin/flockit test rsync SRC DEST Also see the following blog post: https://www.swiftstack.com/blog/2012/08/15/old-school-monkeypatching/
Motivation for this change
flockit is a LD_PRELOAD shim to add file locking to programs that don't do it (I'm looking at you, rsync!)
I use it to backup graphite databases using rsync.
See this blog post for the motivation and an example.
Things done
Please check what applies. Note that these are not hard requirements but merely serve as information for reviewers.
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)