NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.09k stars 14.07k forks source link

New `nixos` executable #54188

Open danbst opened 5 years ago

danbst commented 5 years ago

Issue description

nixos-rebuild interface looks a bit archaic. Maybe we can have a better Nixos frontend CLI?

Just brain dump, but...

Technical details

Basic features:

Subcommands

First I'll describe existing nixos-rebuild switches, that should go into new command:

Then, existing commands should be intergrated. All of those should work on non-NixOS:

Some external projects should be merged in:

And probably some new stuff added:

Anything missed?

leo60228 commented 5 years ago

nixos options --edit might be too complicated. However, we could possibly attempt to port the options table from https://nixos.org to have a value column.

davidak commented 5 years ago

Sounds good!

nixos config --edit could open config in default $EDITOR and later open browser with interactive editor.

commit to Git by default on each rebuild, warns on used .nix files outside of git repo

So should /etc/nixos/ be a git repo? Could be an option for users that don't care.

I have my config in /root/nixos-config and symlink config to /etc/nixos/configuration.nix.

I want to commit after a rebuild was sucessfull. Often i need multiple tries.

An option to not commit would be enough for me.

hedning commented 5 years ago

autocomplete

Use the same self documenting help format as nix and it would be pretty trivial to add support in nix-{zsh,bash}-completions. Completions fornix are already automatically generated from the help (was really nice not having to do anything about the nix-2.2 release :).

avnik commented 5 years ago

Looks good idea for me.

Probably it should be implemented in rust or c++ (I presonally prefer rust here over c++), I asked in IRC about other stuff, and rust was a common language suggestion.

danbst commented 5 years ago

Related issue: https://github.com/NixOS/nixpkgs/issues/51198

I think nixos-lib (or equivalently nixos lib) should contain all NixOS activation scripts, rewritten in C++/Rust/Go/whatever.

infinisil commented 5 years ago

nixos-rebuild just got an edit command :) https://github.com/NixOS/nixpkgs/pull/56241

oxij commented 5 years ago

I think I mentioned this before somewhere but SLNOS doesn't use nixos-rebuild (because there's no /etc/nixos equivalent in SLNOS) and does a lot of this with a simple bash script, e.g.:

$ slnos build --on machine --for other-machine other-machine.nix $ slnos build --on machine --for other-machine

(both do the same thing) will build other-machine.nix (this will be its configuration.nix, but you can specify several files at the same time and it will then generate a temporary nix file with imports a-la NixOps) on machine, nix-copy over to other-machine. switch, boot, test, and etc are selected interactively after the fact, or with

$ slnos build --on machine --for this-machine this-machine.nix temporary-networking-changes.nix --and-then test

(I do this one all the time.)

I don't see why nixos can't do the same.

matthew-piziak commented 5 years ago

Another thing I'd like to see supported is -L/--print-build-logs for nixos-rebuild, which already exists for nix build.

stale[bot] commented 4 years ago

Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on irc.freenode.net.
davidak commented 4 years ago

this is still needed to make NixOS more userfriendly

a next step could be a usable prototype as wrapper in python or whatever you like

matthew-piziak commented 4 years ago

Since my last comment I have discovered nix-top, which I use to see what a build is currently struggling with.

xaverdh commented 4 years ago

This is not just about usability by the way, there is a lot of duplication in the nixos-* tooling. They all accept roughly the same nix options, which get passed through to nix calls. And actually they do get out of sync with both nix itself and each other from time to time..

liff commented 3 years ago

Looks like nixos-rebuild build-vm[-with-bootloader] is missing a subcommand.

matthiasbeyer commented 3 years ago

commit to Git by default on each rebuild

This is an antipattern and I really hope there will be an option to disable this!

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

liff commented 2 years ago

Not stale, I hope?

misuzu commented 2 years ago

How about nixos gc -d for nix-collect-garbage -d && /nix/var/nix/profiles/system/bin/switch-to-configuration boot?

nixos-discourse commented 1 year ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nixpkgs-cli-working-group/30517/5

water-sucks commented 11 months ago

I've made a precursor to this that's still in very early stages, just to see where it can go. The repo is here, I'd like to see how far this can be taken.