diff --git a/common/users/homeModules/scripts/default.nix b/common/users/homeModules/scripts/default.nix index d2c5540..ecdc17f 100644 --- a/common/users/homeModules/scripts/default.nix +++ b/common/users/homeModules/scripts/default.nix @@ -19,6 +19,7 @@ let executable = true; destination = "/bin/${name}"; text = '' + export PATH="" for i in ${lib.concatStringsSep " " env}; do export PATH="$i/bin:$PATH" done @@ -78,6 +79,13 @@ in direnv ]; }) + (mkScript { + name = "detach"; + file = ./detach.sh; + env = with pkgs; [ + coreutils + ]; + }) # impl for the cloneRepo command ]; file = { diff --git a/common/users/homeModules/scripts/detach.sh b/common/users/homeModules/scripts/detach.sh new file mode 100644 index 0000000..7277cfe --- /dev/null +++ b/common/users/homeModules/scripts/detach.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -eo pipefail + +function echoe() { + echo $@ 1>&2 +} + +function printUsage() { + echoe "Usage: ${0} FILE" + echoe "Unlink a file by copying the original file to the link path" + echoe "Shorthand for cp -P \$(readlink \$FILE) $FILE" +} + +if [[ -z $1 ]]; then + echoe "${0}: missing file" + printUsage + exit 1 +fi + +cp -P $(readlink $1) $1