repl-overlays / PathSetting: Support ~/ in paths #482

Closed
opened 2024-08-21 22:50:28 +00:00 by rbt · 6 comments
Owner

Currently, if I want to set a repl-overlays file in my nix.conf, I have to use the absolute path. This makes it impossible to keep the file in my dotfiles repo, because I don't have the same username/homedir on all my machines.

Describe the solution you'd like

I'd like to be able to set a repl-overlays value of ~/.config/nix/repl.nix in my ~/.config/nix/nix.conf and have it expand out my home directory. This probably shouldn't be allowed in /etc/nix/nix.conf. (It would be nice to have this for the other settings that take paths, like the credential files setting.)

Describe alternatives you've considered

Suffering, using home-manager to set the Nix configuration or my home directory declaratively (suffering), putting a symlink to my repl overlay in a consistent absolute path like /opt/nix/repl.nix or something (suffering when it inevitably breaks and every Nix command fails).

## Is your feature request related to a problem? Please describe. Currently, if I want to set a `repl-overlays` file in my `nix.conf`, I have to use the absolute path. This makes it impossible to keep the file in my dotfiles repo, because I don't have the same username/homedir on all my machines. ## Describe the solution you'd like I'd like to be able to set a `repl-overlays` value of `~/.config/nix/repl.nix` in my `~/.config/nix/nix.conf` and have it expand out my home directory. This probably shouldn't be allowed in `/etc/nix/nix.conf`. (It would be nice to have this for the other settings that take paths, like the credential files setting.) ## Describe alternatives you've considered Suffering, using `home-manager` to set the Nix configuration or my home directory declaratively (suffering), putting a symlink to my repl overlay in a consistent absolute path like `/opt/nix/repl.nix` or something (suffering when it inevitably breaks and every Nix command fails).
Author
Owner

(Hi also!! Sorry I haven't been doing much for Lix lately!)

(Hi also!! Sorry I haven't been doing much for Lix lately!)
Author
Owner

Discussed out-of-band with @jade: "yes do it, that's a ux improvement that has no negative consequences to the future".

Discussed out-of-band with @jade: "yes do it, that's a ux improvement that has no negative consequences to the future".
rbt added the
ux
E/easy
E/help wanted
labels 2024-08-22 03:10:55 +00:00
Author
Owner

Implementation strategy:

  • Add a SetSettingSettings struct with options like "relative paths allowed" and "tilde paths allowed"
  • loadConfFile allows tilde paths only in nixUserConfFiles
    • Split getConfigDirs() into getUserConfigDir() and getOtherConfigDirs(), so we know which one should be able to access tilde paths
    • Check that the user config directory starts with the detected $HOME path
    • TODO: What if there's a config file in someone else's home dir, that kinda thing? Have to write tests and such for this.
  • Config::set and AbstractConfig::applyConfig gain a SetSettingSettings parameter
  • PathSetting::parse uses SetSettingSettings to determine if relative or tilde paths should be resolved (and if so, from where)
Implementation strategy: - Add a `SetSettingSettings` struct with options like "relative paths allowed" and "tilde paths allowed" - [`loadConfFile`](https://git.lix.systems/lix-project/lix/src/commit/87fd6e00952f3597618a82a121052a9ad37b8f4a/src/libstore/globals.cc#L117) allows tilde paths only in `nixUserConfFiles` - Split `getConfigDirs()` into `getUserConfigDir()` and `getOtherConfigDirs()`, so we know which one should be able to access tilde paths - Check that the user config directory starts with the detected `$HOME` path - TODO: What if there's a config file in someone else's home dir, that kinda thing? Have to write tests and such for this. - `Config::set` and `AbstractConfig::applyConfig` gain a `SetSettingSettings` parameter - `PathSetting::parse` uses `SetSettingSettings` to determine if relative or tilde paths should be resolved (and if so, from where)
rbt changed title from `repl-overlays`: Support `~/` in paths to `repl-overlays` / `PathSetting`: Support `~/` in paths 2024-08-23 19:35:17 +00:00
Author
Owner

Starting some work here, no timeline though: https://gerrit.lix.systems/c/lix/+/1851

Starting some work here, no timeline though: https://gerrit.lix.systems/c/lix/+/1851
Author
Owner

Just waiting for reviews.

Just waiting for reviews.
Author
Owner

Closed with 02eb07cfd5 / cl/1864!!!

Closed with 02eb07cfd539c34c080cb1baf042e5e780c1fcc2 / cl/1864!!!
rbt closed this issue 2024-09-01 22:14:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#482
No description provided.