-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Redesign of the nix command line #779
Comments
I did a little writeup with my thoughts & proposals: In that I address the problem of search path clashes @edolstra mentioned in the General section. |
(Commenting here as @copumpkin requested) I strongly agree with @Profpatsch's points. To be fair there, there is a use for imperative package management, as articulated by @lethalman in #684. Since under @Profpatsch's plan the profile is always defined declarative, and since @lethalman's usecases boil down to pinning the exact version of a package, I think we should speak of "pinned" vs "regular" packages.
I'm reminded of git changing the default push settings. I suggest we disable this by default, and then have a setting to enable this power users can enable. In the name of orthogonality, I also propose that the setting be that the namespace is queried unless |
More broadly, I see a convergence in the way userland nix and nixos are configured and used. We've already talked about using the nixos module system both for user-mode services (e.g. on OSX), and for configuring packages. Likewise there was recently a thread to the mailing list about decoratively pinning nixpkgs for nixos in https://www.mail-archive.com/[email protected]/msg17827.html . Ultimately It would be great if root and normal users alike can define and enable service and packages in the same module system, and the same CLI tools can assist with querying and editing the config files. Converging all this will take a great deal of work, but I think a few decisions can be made now to help the process go faster. In the thread I linked, @edolstra mentioned we could use |
Is it possible to cut down the proposal to the essentials ? It's good to show the end-goal but for implementation it might be a bit daunting. How would we go on implementing all of this ? Are we going to port one command at the time and update the docs accordingly ? One thing that might feel inherent but that needs to be specified is that the |
First my strongest points:
Now some replies:
More detailed thoughts of mine, ordered according to the original proposal:
|
+1 for unique substrings of command names, -1 for alias definiton (that’s what the shell is for, and the git folks got it all wrong!)
What should be in scope by default?
I find that absolutely crucial with a “destructive” package manager like e.g.
Yet, that is not useful if one uses two versions of e.g. nixpkgs, e.g. |
@vcunat I notice that wherever you suggested a third level in the hierarchy, you did it as an |
@Profpatsch: how do you simply define aliases for sub-commands in bash?
I imagine it like this: the default
Personally, I sometimes like to see what would happen beforehand, instead of doing it and the rolling back immediately.
Even today you should be able to do this: {
packageOverrides = pkgs: {
pkgs-1509 = import /nix/var/nix/profiles/per-user/root/channels/nixos-15.09 {};
};
} Other ways are e.g. adding (And even today you can relatively simply get rid of the prefixes; the only question is what should be the default. There was a similar discussion on the mailing-list a couple days ago.) @glaebhoerl: for clarity reasons, I assume it's better to prefix by |
@vcunat Yea I think the functionality should be in REPL or in the manual. See for example the Haskell documentation, and how if you look up the source for any particular function, it points to the actual implementation. For the REPL if it could show the type signature (even though nix is untyped, it could just be manually specified, like a help page for that exact command), that would be great. |
Once some of the initial discussion settles down, I would suggest creating a new repo to host a design document. PRs would then be issued to get feedback on proposals before updating the doc. I'm really enjoying the level of discourse here, but I think it's important that we have an authoritative document so we're all on the same page, and have a more directed approach to converging on a final, actionable design. Ideally, we'd have @edolstra and a couple others that we could trust to review and give feedback on each proposal, merging in the changes if they sound good. A deadline for the design might also be a good idea, to avoid this work languishing. Thoughts? |
Yes, a very good point. Best agree on basics of the UI before implementation (perhaps except for some prototypes). |
It’s nice to see the difference between built-in and not. Otherwise you sit at a different system and wonder why the most basic commands are missing …
|
Based on my email:
I would like to suggest that any querying functionality should include the ability to show package parameters. |
Another suggestion, an inline way of overriding package parameters instead of using Oh this already has been suggested. NVM. |
That is of course only an instance of the more general case of I’m in strong favor of not depending on anything |
Derivations and Nix sees them do not reflect any configuration options, and I'd like to keep it that way. I earlier proposed that this be developed in nixpkgs. But really there are 3 layers: nix itself, modules system tools and config idioms (other parts of nixpkgs/lib perhaps), and the actual nixpkgs packages. I agree nothing in the Nix repo should depend on nixpkgs at runtime, but whether we move this and module system into nix, or put tools in nixpkgs, we are combining those 3 layers into 2. |
Disclaimer: just an implementation detail. You may want to consider docopt. There's a cpp port and some examples of how you may implement a huge multi-command app like git. Greets |
Don't forget to look at guix for inspiration. I've read some of its CLI documentation, it looks very good. Annoyingly good actually... can I haz? Here is one (out of many) really useful looking guix sub-commands: |
The code now contains BTW, working with the code is relatively hard for me as I can see just the code, almost without any explanation of intention etc., which makes it a little problematic to understand, especially as it's WIP. (When trying to understand header definitions, I often had to look into implementation and call sites to see what they're for.) |
If we're planning a multi command app like |
That was already discussed above in more detail. |
When this will be implemented, will it be done in a backwards compatible manner? So that there are scripts around in my PATH which are Another idea: Some of you might know my nixos-scripts which are basically scripts around Edit: Another thing I really like to say that the idea for aliases is really great, but we should take this a small step further: the |
|
I thought |
@copumpkin I hope @domenkozar means the same C++ API internally, and the new commands simply won't use the name-centric parts. Is there a nixos-setting for using |
I don't see why not add a switch for name-based resolution. |
I haven't read all the previous discussion so I'm not sure if this has already been brought up but I had a quick look and it didn't seem like it. With #! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash
echo hello world $ ./hello
hello world
$ But with #! /usr/bin/env nix shell
#! nix shell -i bash -p bash
echo hello world $ ./hello
/usr/bin/env: ‘nix shell’: No such file or directory
$ This is because the POSIX script invocation mechanism only allows one argument to appear on the Guile uses a 'meta switch' as a workaround for this. So if this hasn't been considered maybe something like that could also be implemented for Edit: I also found https://github.com/shlevy/long-shebang. |
Maybe it can be just:
So manually you can use |
Having a distinction between the two seems very reasonable. It might even be called |
@bobvanderlinden It exists already, nix-script |
@Anton-Latukha But that's sort of my point though, we can't use |
I'm not sure whether this is still active here, but I'd like to propose a hook interface. The idea behind that is a use-case (of course): I run custom scripts when rebuilding my system. The relevant ones are the channel-update and switch which both have a single purpose: Build the update (channel or system) and tag my configuration with a special git tag (special as in it identifies the generation by number) so I can see in my configuration repository which generation was build from what git commit. Having a hook executed for each action in the rebuild process would simplify that a lot. I think about these hook points:
And parameters should give the script the ability to see what gets rebuild, who did the rebuild, how it gets build (switch, boot, build, test, ...) and possibly more I do not think of right now. |
Don't know about those use cases, but it would be good to have a garbage collector hook to allow NixOS to remove boot menu entries for GC'ed versions. |
@vcunat @Profpatsch @edolstra Really like this new interface! Quick comment on the subject of commands that take attributes being able to work with expression though. Given that I can tell our users (Canadian HPC center) to do this to get an environment with python3 nix run nixpkgs.python3 it would be very nice if I could tell them to do this to get an environment with python3 and numpy nix run 'nixpkgs.python3.withPackages (pkgs: [pkgs.numpy])' instead of having to drop this sort of thing on them nix run '(let nixpkgs = import <nixpkgs> { }; in nixpkgs.python3.withPackages (pkgs: [pkgs.numpy]))' |
@twhitehead, you can already simplify that to the following, can't you? nix run '(import <nixpkgs> {}).python3.withPackages (p: [p.numpy])' |
@Wizek Yes, that is more compact and avoids introducing I would still really like to provide colleagues and users with a command that looks like just a small extension of the basic one and avoids exposing any more of the nix language than absolutely required. I know it may seem silly, but being able to do the basics (e.g., install/use python with a select set of packages) with as uncryptic command as possible is really important for adoption in our organization. |
On the subject of being able to do the basics like installing python with a set of packages with as nonthreatening looking command as possible (i.e., gives the impression that I understand what is going on without having to learn a whole bunch), I've been wondering if even this could be improved upon nix run 'nixpkgs.python3.withPackages (pkgs: [pkgs.numpy pkgs.matplotlib])' For example (not suggesting this is the best way to do this, but more throwing it out as an example to get the conversation started), as
to enable to following sort of commands nix run 'nixpkgs.python3.withPackages | numpy matplotlib' |
This could be done by having an option to pass regular arguments like
|
Or, if the attribute selection is to remain special syntax, then it could just be extended to also be able to take an optional space separated list on the end that is translated like so
allowing the fabulously clean and intuitive looking
|
Regardless of how the final syntax is, it would be great if all the language-specific packages had the same style of invocation. |
@hedning @CMCDragonkai with regard to options and the same style of invocation, maybe it would be possible to add command line options that do common invocation things (thus also encourage further packages to implement those invocation styles). For example, a nix run nixpkgs.python3 --with-packages 'numpy matplotlib' that, given the above, would check if nixpkgs.python3 has a withPackages attribute and then invoke it like so nixpkgs.python3.withPackages (p: with p; [ numpy matplotlib ]) Likewise, an
that would check for an nixpkgs.python3.override { x11Support = true; } This has the advantage of being fairly future proof as it provides a layer of abstraction between the user and the continuously evolving nixpkgs interfaces. Options can be added, deprecated, removed, or even just have their internal implementation details changed to continue providing the same functionality against new nixpkgs interfaces. One pain I could see is that as That is, |
I was thinking some more about this, and had another suggestion along these lines. What if individual packages could be passed command line options, so something like this
would be translated into something like this
That is, if a set of options are specified after an attribute selection, they are collected into an attribute set and passed to a Thanks! -Tyson |
There is an interesting trade off between providing a generic (more power, the ultimate being an arbitrary function transformation) and a specific interface (better error messages and such) for these things. It seems you want to be a specific as possible but no more specific. This allowing everything that needs to be done to be done while still giving the best possible error messages and such. Most of my suggestions so far have been for generic machinery. Here is one for specific machinery instead. Maybe packages could optionally provide a This might ultimately also dovetail nicely with also having a better config system. That is, one where options are declared in a modular manner, documented, and the user's config is verified against them in order to provide a top-level pkgs In terms of the command line usage, you could imagine the NixOs options/config machinery merging and verifying
|
Can we close this ticket? It feels to me like it's not terribly useful any more. If anyone has issues with the new UI, then it's probably better to open a new, specific ticket about that. |
Did everything mentioned here get addressed? If not, maybe they can be packaged into a feature wish-list wiki? |
Since It appears that |
@lrworth There's now the experimental (yes, it's been a year, but I'm still seeing this issue in search results, so I thought I'd answer for future visits) |
The problem is that the new commands are not stable yet. Using them requires use of unstable nix in addition to adding experimental flags in nix.conf. newcomers will be confused. This all just adds just additional complexity to using nix which is totally unnecessary. Personally I think this issue is still open as the new command redesign is not released yet. |
Plus 1 for reopening, but there is now also a guideline for more information at least: |
fix styling issues and links
Initial writeup by @edolstra: https://gist.github.com/edolstra/efcadfd240c2d8906348
The text was updated successfully, but these errors were encountered: