# Pocnix: a proof-of-concept Nix CLI

**URL:** https://discourse.nixos.org/t/pocnix-a-proof-of-concept-nix-cli/1672
**Category:** Development
**Created:** [December 12, 2018, 10:56pm UTC](https://discourse.nixos.org/t/pocnix-a-proof-of-concept-nix-cli/1672 "2018-12-12T22:56:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![bobvanderlinden](https://discourse.nixos.org/user_avatar/discourse.nixos.org/bobvanderlinden/32/59_2.png) [@bobvanderlinden](https://discourse.nixos.org/u/bobvanderlinden)
#### Post date: [December 12, 2018, 10:56pm UTC](https://discourse.nixos.org/t/pocnix-a-proof-of-concept-nix-cli/1672/1 "2018-12-12T22:56:21Z")

</div>

Since there was [a dicussion about the usage of all the CLI tools here on Discourse](https://discourse.nixos.org/t/question-regarding-configuration-nix/1619), I figured it would be cool to have a rough CLI tool that incorporated some of those ideas:

> **[GitHub - bobvanderlinden/pocnix: A proof-of-concept cli for Nix](https://github.com/bobvanderlinden/pocnix)**
>
> A proof-of-concept cli for Nix. Contribute to bobvanderlinden/pocnix development by creating an account on GitHub.

It is a tool that supports the following commands:

```auto
pocnix local install hello
pocnix user install hello
sudo pocnix system install hello

```

It uses a `pkgs.json` file to define which packages should be installed in an environment. This file needs to be referenced from `default.nix`, `home.nix` and/or `configuration.nix`.

To help set up a correct environment, you can use the following commands to set up the Nix files correctly:

```auto
pocnix local init
pocnix user init
pocnix system init

```

It will create Nix files if they do not yet exist and otherwise give an example how these files should look like.

It is _very_ rough. Made it this evening. The intention is not to create a good CLI alternative to Nix, but to spark some discussion on what the Nix CLI could be doing.

The current suite of CLI tools are quite varying in their usage and there are different workflows involved to do seemingly similar things. Sometimes editing files and switching, sometimes ad-hoc installations using `nix-env`. In addition, quite a few NixOS users have switched from using `nix-env` to using `home-manager` or similar solutions.  
Lastly, nixpkgs pinning should (imo) be a default for most usages of Nix, but this is often still a bit of a hassle. nix-channel is convenient, but its usage goes against the philosophy of Nix (reproducability).

The user interface is especially important when showing off Nix to (potential) new users. It is hard to sell, as its usage is far from convenient compared to language-specific package managers with which most people are quite familiar. Those tools nowadays all have pinning by default. Installing packages is easy, while still easy to share with others over version control.

Anyway, let me know what’s on your mind in this regard!

---

<div class="post-metadata">

### Author: ![Mic92](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mic92/32/5265_2.png) [@Mic92](https://discourse.nixos.org/u/Mic92)
#### Post date: [December 12, 2018, 11:33pm UTC](https://discourse.nixos.org/t/pocnix-a-proof-of-concept-nix-cli/1672/2 "2018-12-12T23:33:03Z")

</div>

I also want to throw in [nix-flakes.md · GitHub](https://gist.github.com/edolstra/40da6e3a4d4ee8fd019395365e0772e7) which addresses some stuff mentioned here.

---

<div class="post-metadata">

### Author: ![7c6f434c](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/7/8e7dd6/32.png) [@7c6f434c](https://discourse.nixos.org/u/7c6f434c)
#### Post date: [December 13, 2018, 6:44am UTC](https://discourse.nixos.org/t/pocnix-a-proof-of-concept-nix-cli/1672/3 "2018-12-13T06:44:43Z")

</div>

I can share just observed experience. When I tried told one colleague to just use Nix in a Linux VM already to install stuff with complicated dependencies, this is what I ended up writing to make general Nix usage acceptable for him:

> <https://gist.github.com/7c6f434c/9dfe7478189344761818eacca0a453fd>

(N=1 experiment, of course)

Note that: 1) removal and installation are both by attribute-name; 2) installing something does not necessarily update the other packages; that’s intended.

---

<div class="post-metadata">

### Author: ![Mic92](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mic92/32/5265_2.png) [@Mic92](https://discourse.nixos.org/u/Mic92)
#### Post date: [December 13, 2018, 12:03pm UTC](https://discourse.nixos.org/t/pocnix-a-proof-of-concept-nix-cli/1672/4 "2018-12-13T12:03:23Z")

</div>

This threads reminds a bit of AUR helpers: [AUR helpers - ArchWiki](https://wiki.archlinux.org/index.php/AUR_helpers)

---

<div class="post-metadata">

### Author: ![bobvanderlinden](https://discourse.nixos.org/user_avatar/discourse.nixos.org/bobvanderlinden/32/59_2.png) [@bobvanderlinden](https://discourse.nixos.org/u/bobvanderlinden)
#### Post date: [December 23, 2018, 12:48pm UTC](https://discourse.nixos.org/t/pocnix-a-proof-of-concept-nix-cli/1672/5 "2018-12-23T12:48:46Z")

</div>

Thanks a lot for that gist! It seems that one was quite hidden, because I have not found any issue or PR with further discussions referring to that gist. It contains a lot of thoughts that are very relevant. @edolstra would it be a good idea to create an issue/RFC for that gist?

---

<div class="post-metadata">

### Author: ![bobvanderlinden](https://discourse.nixos.org/user_avatar/discourse.nixos.org/bobvanderlinden/32/59_2.png) [@bobvanderlinden](https://discourse.nixos.org/u/bobvanderlinden)
#### Post date: [December 23, 2018, 1:00pm UTC](https://discourse.nixos.org/t/pocnix-a-proof-of-concept-nix-cli/1672/6 "2018-12-23T13:00:02Z")

</div>

That’s also a very interesting approach: taking the output of nix-build, building a environment from those outputs and replacing the profile. The script is very straightforward and easy to determine what it is doing. It’s nice that all packages are basically ‘locked’ automatically. It seems very intuitive to do this in a home directory and installing packages ad-hoc. It does need a different approach when the environment needs to be reproducible (for project-specific packages).

Still though I think `nix-do` does exactly what most people would think a package manager would do. This should definitively be part of any nix-env UX discussions.
