Skip to content

A tool to perform renames #151

Open
Open
@roberth

Description

@roberth

Description

When renaming a file in a collection of Nix files, the relative path expressions that referenced the old location become invalid.
The Nixpkgs architecture team is working on a cleanup operation that will move a huge number of files. Being able to do so in an automated and accurate manner would be a game changer.

The code that supports this operation may also benefit rnix-lsp, although the LSP rename functionality doesn't appear to be as advanced as, say, IntelliJ's.

Considered alternatives

We might hack the paths using sed and friends, but this runs the risk of breaking some paths whose use is optional and therefore not revealed by testing the evaluation.

Additional context

This is a call for help.
I don't have the rust experience to pull this off, but I know rnix is well suited, because it can preserve syntax and it supports an lsp.

Considering the O(n²) nature of all possible file-to-file references, we'll want to perform the renames in batches. Non-Nix files may be referenced and renamed.

Example interface:

cd nixpkgs
rnix-mv --project . \
  --from pkgs/os-specific/linux/mdadm --to pkg/mdadm \
  --from pkgs/desktops/xfce/core/xfwm4 --to pkg/xfwm4

--project scans the passed directory recursively for .nix files that may reference the moved files.

Our use case is https://github.com/nixpkgs-architecture/auto-called-packages
If you're interested on working on this, reach out to us on https://matrix.to/#/#nixpkgs-architecture:nixos.org

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions