-
-
Notifications
You must be signed in to change notification settings - Fork 75
{nixos,home,darwin}: add edit
subcommand
#383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Should support non-flakes as well. When an installable is passed or if Also I think we should bail instead of trying nano when $EDITOR is unset. If user doesn't have EDITOR set, then it's unlikely that they have nano installed imo. |
edit
subcommand
Also we don't use conventional commits, please consider rewording to match the title. |
I intentionally left out support for a Although, I can see the usefulness of wanting to automatically direct the editor to a designated flake location or non flake location such as |
@midischwarz12 I've moved this to the 4.2.0 milestone. Once again there is no rush, but if you could address my comments as discussed on Matrix I'd like to merge this before Monday and start thinking about 4.2.0 |
I'll probably have time to get this out tomorrow as well. If not, it'll be done on Thursday for sure. |
@NotAShelf Feel free to take a look. Sorry for the long wait. |
e1152d2
to
f4c023c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, this PR is less close to a merge than I had hoped. While I hate to provide negative reviews, there is no way I can merge this as is. Unfortunately I must leave my desktop shortly, but here is a quick list of thoughts:
- The duplication of
edit
logic is unnecessary. They are so similar, there could be a generic helper that consolidates all three platform implementations and avoids the absurd +319 LoC addition. You can consider putting this in util, or in commands (not commands.rs; something likecommands::edit
) - I hope you do realise there is little to no value in editing a flake from the store directory. Not only is
-o
not supported fornix flake prefetch
, but fetching it to thee Nix store and trying to edit it there (or the symlink) defeats the entire purpose of an edit subcommand. You can't edit the store, silly. Even if-o
was supported you would be trying to edit a symlink... As I've shared with you befeore, the goal here was to edit the given flake directory (or a configuration.nix file), not a store copy of it. This should have been as easy as picking the correct variable (or its nix2 equivalent) from NH_FLAKE, NH_OS_FLAKE etc. and opening the directory with$EDITOR
. Conveniently nix appears to have anix edit
command (for whatever reason) which you can use to get rid of some of th code. I also expect correct handling for when nano fails (which is likely). Also a warning when$EDITOR
fails. - The blocking command implmentation and especially
nix flake prefetch
is an incredibly slow operation. Did you ever test this PR?
Since the goal of the edit subcommand is to provide backwards compatibility with nixos-rebuild edit
, I would encourage you to review nixos-rebuild-ng
and see how they handle the edit subcommand. Do note, however, that this PR needs a serious makeover for it to be mergable.
Unfortunate, but respectfully, I think you're a bit confused for part of this.
Yeah, I'll look into maybe reusing the existing commands again, parse the flake attribute for paths, and add again the sensible error for when EDITOR is unset. |
Ah, okay. I remember why I don't like nixos-rebuild edit now. This failed o my flake with:
I think I was thinking that this fails on flakes which generate their nixosConfigurations output from some subsequent function. So for example, if you many hosts and have some sort of function which loops through the contents to automatically generate this (which is a very common pattern), it would fail. However, I tried this on another flake which does not do this. And I am receiving the same error. So I'm not really sure why I'm getting this now. I looked at nixos-rebuild-ng and apparently they just use |
I hate to look stupid here. But I just did some light poking around with |
f0114da
to
b992185
Compare
@NotAShelf This should be what you want while being backwards compatible. Feel free to test and merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of code duplication, but you guys already talked about that.
Sanity Checking
nix fmt
to format my Nix codecargo fmt
to format my Rust codecargo clippy
and fixed any new linter warnings.logic
description.
x86_64-linux
aarch64-linux
x86_64-darwin
aarch64-darwin
Add a 👍 reaction to pull requests you find important.