diff --git a/.envrc b/.envrc index d2cf334c..6d9d93e0 100644 --- a/.envrc +++ b/.envrc @@ -1,7 +1,7 @@ stty sane source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" -rbw unlocked || rbw unlock +rbw-atomic-unlock watch_file devenv.nix watch_file flake.nix diff --git a/flake/helper-packages.nix b/flake/helper-packages.nix index 5089d16e..2123e7fb 100644 --- a/flake/helper-packages.nix +++ b/flake/helper-packages.nix @@ -15,6 +15,7 @@ rbw rofi-wayland skim + util-linux wpa_supplicant ; @@ -47,22 +48,12 @@ rbw-atomic-unlock = writeShellApplication { name = "rbw-atomic-unlock"; - runtimeInputs = [rbw]; + runtimeInputs = [rbw util-linux]; text = '' - rbw_lock=/tmp/lock.rbw.lock - rbw_pid_lock="/tmp/lock.$$.tmp" - trap 'rm -f $rbw_lock $rbw_pid_lock' EXIT - if ! rbw unlocked 2>/dev/null; then - touch "$rbw_pid_lock" - if ln "$rbw_pid_lock" "$rbw_lock" 2>/dev/null; then - rbw unlock - rm -f "$rbw_lock" - else - while ! rbw unlocked 2>/dev/null; do - sleep 0.2 - done - fi - fi + rbw_lock="/tmp/rbw-unlock.lock" + exec 200>"$rbw_lock" + flock -w 15 200 + rbw unlocked || rbw unlock ''; };