Start migration to using flake-parts

This commit is contained in:
2026-03-23 20:34:48 +01:00
parent ba56618049
commit 6cbe60c784
158 changed files with 1935 additions and 1830 deletions

View File

@@ -0,0 +1,58 @@
{writeShellApplication}:
writeShellApplication {
name = "lntocp";
runtimeInputs = [];
text = ''
#!/bin/bash
# This script accepts any number of files or directories as input.
# If the input is a symbolic link, it deletes the symlink and copies
# the original file or folder (where the symlink points to) to the location
# where the symlink was. Non-symlink files or directories are ignored.
# Function to copy original file/folder in place of the symlink
process_symlink() {
symlink="$1"
# Resolve the target (the file or directory the symlink points to)
target=$(readlink "$symlink")
# Check if the target is absolute or relative
if [[ ! "$target" =~ ^/ ]]; then
# If the target is relative, compute the full path
target="$(dirname "$symlink")/$target"
fi
# Check if the target exists
if [ -e "$target" ]; then
echo "Processing symlink: $symlink -> $target"
# Remove the symlink
rm "$symlink"
# Copy the original target to the symlink location
if [ -d "$target" ]; then
# If it's a directory, use 'cp -r'
cp -r "$target" "$symlink"
else
# Otherwise, it's a file, use 'cp'
cp "$target" "$symlink"
fi
echo "Copied $target to $symlink"
else
echo "Target $target does not exist!"
fi
}
# Loop through all arguments (files and directories passed to the script)
for item in "$@"; do
if [ -L "$item" ]; then
# If the item is a symlink, process it
process_symlink "$item"
else
echo "$item is not a symlink. Skipping."
fi
done
'';
}