diff --git a/homes/x86_64-linux/julian@aspi/default.nix b/homes/x86_64-linux/julian@aspi/default.nix index 5b39106..eda9cea 100644 --- a/homes/x86_64-linux/julian@aspi/default.nix +++ b/homes/x86_64-linux/julian@aspi/default.nix @@ -92,9 +92,11 @@ tor-browser ## My scripts - pkgs.frajul.deploy-to-pianopi - pkgs.frajul.edit-config - pkgs.frajul.open-messaging + frajul.deploy-to-pianopi + frajul.open-messaging + frajul.edit-config + frajul.xwacomcalibrate + frajul.lntocp ] ++ lib.lists.concatMap (packages-list-file: import packages-list-file { inherit pkgs; }) [ ./fonts.nix diff --git a/homes/x86_64-linux/julian@aspi/packages.nix b/homes/x86_64-linux/julian@aspi/packages.nix index ff6503c..5bc95ab 100644 --- a/homes/x86_64-linux/julian@aspi/packages.nix +++ b/homes/x86_64-linux/julian@aspi/packages.nix @@ -153,11 +153,8 @@ with pkgs; unstable.path-of-building - ## My scripts - frajul.edit-config - frajul.xwacomcalibrate - conda + watchexec # Run command when any file in current dir changes pkg-config # Often needed to build something ] diff --git a/packages/lntocp/default.nix b/packages/lntocp/default.nix new file mode 100644 index 0000000..07aa03a --- /dev/null +++ b/packages/lntocp/default.nix @@ -0,0 +1,71 @@ +{ + # Snowfall Lib provides a customized `lib` instance with access to your flake's library + # as well as the libraries available from your flake's inputs. + lib, + # You also have access to your flake's inputs. + inputs, + + # All other arguments come from NixPkgs. You can use `pkgs` to pull packages or helpers + # programmatically or you may add the named attributes as arguments here. + pkgs, + stdenv, + ... +}: + +pkgs.writeShellApplication { + name = "lntocp"; + + runtimeInputs = with pkgs; [ ]; + + 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 + ''; +}