fix some issues with rust template's rename
This commit is contained in:
parent
e5a1d5aa68
commit
259f6545a8
|
@ -59,11 +59,16 @@
|
||||||
runtimeInputs = [
|
runtimeInputs = [
|
||||||
pkgs.fd
|
pkgs.fd
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
|
pkgs.nixFlakes
|
||||||
|
pkgs.jq
|
||||||
];
|
];
|
||||||
text = ''
|
text = ''
|
||||||
stat nix/packages/change-my-name.nix 2>/dev/null >/dev/null || echo "Can only be done once!"
|
|
||||||
newName="$1"
|
newName="$1"
|
||||||
pushd "$(git rev-parse --show-toplevel)"
|
pushd "$(nix flake metadata --json 2>/dev/null | jq .original.path -r)"
|
||||||
|
# This is only used to prevent the literal name from appearing here, as the rename would find it!
|
||||||
|
oldName=$(echo 'change_my_name' | sed 's/_/-/g')
|
||||||
|
stat "nix/packages/$oldName.nix" 2>/dev/null >/dev/null || echo -e "\033[31mCan only be done once\033[0m"
|
||||||
|
stat "nix/packages/$oldName.nix" 2>/dev/null >/dev/null || exit 1
|
||||||
fd --type f --exec sed "s/change-my-name/$newName/g" -i '{}'
|
fd --type f --exec sed "s/change-my-name/$newName/g" -i '{}'
|
||||||
mv nix/packages/change-my-name.nix "nix/packages/$newName.nix"
|
mv nix/packages/change-my-name.nix "nix/packages/$newName.nix"
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in a new issue