target / lorri

Your project's nix-env
Apache License 2.0
992 stars 69 forks source link

src/project: put a ref to source next to gc_root #469

Closed hmenke closed 3 years ago

hmenke commented 4 years ago

Overview

Currently it is not possible to determine whether a gc_root is used or not because the path is a hash of the filename that it was created from. When the source is deleted, the gc_root will remain forever unable to be garbage collected. Once the user accumulates several projects, it is also very hard to tell which gc_root belongs to which project, because there is no bidirectional mapping.

In #16 it was suggested to add a subcommand to lorri that will automatically remove unused gc_roots, however, without a mapping from the name of the gc_root back to the location of the source this is impossible.

This commit addresses this issue in parts by creating a file with the name ref next to the gc_root which will simply contain the full path of the shell file it was originally created for. In the future this information could be used to automatically detect and garbage-collect unused gc_roots, but even without that it will enable the user to write a simple shell script which picks up each ref and checks whether the file inside exists.

Another possibility instead of using a file containing the path name would be to make ref a symlink to the shell file. When the symlink is broken, the gc_root is unused. However, that might pose a problem for users using lorri through WSL on Windows, because Windows filesystems don't support symlinks. I'm unsure whether that is a concern, but I opted for the safer option of just a plain file.

Checklist

hmenke commented 4 years ago

I had run the ci command locally and it all passed, so I have no idea why all the macOS tests are failing. Also the error message “This check failed” is not all too helpful.