# "programs.foo.enable = true" vs "systemPackages=\[foo\]" is confusing

**URL:** https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534
**Category:** Help
**Created:** [January 17, 2020, 11:59pm UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534 "2020-01-17T23:59:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![trusktr](https://discourse.nixos.org/user_avatar/discourse.nixos.org/trusktr/32/1994_2.png) [@trusktr](https://discourse.nixos.org/u/trusktr)
#### Post date: [January 17, 2020, 11:59pm UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/1 "2020-01-17T23:59:04Z")

</div>

I find the `configuration.nix` system to be a bit confusing.

For example, how do I install zsh?

Is it

```nix
environment.systemPackages = with pkgs; [zsh];

```

or

```nix
programs.zsh.enable = true

```

?

As a new user I searched for “zsh” to see if that was available, then thought “great, I’ll just stick that in `systemPackages` and I’ll have zsh”, only to find out weeks later that I should actually write `programs.zsh.enable = true` if I want to have `nix-zsh-completions` and other system-wide zsh features.

This experience is not well-documented.

---

<div class="post-metadata">

### Author: ![dalto](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dalto/32/2176_2.png) [@dalto](https://discourse.nixos.org/u/dalto)
#### Post date: [January 18, 2020, 12:04am UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/2 "2020-01-18T00:04:28Z")

</div>

The former installs the zsh package.

The latter leverages the zsh module to install/configure the software. I am fairly new here but from my limited experience the modules usually provide configuration of system wide features when applicable. They also operate at a higher level of abstraction since they handle both configuration and package installation.

I am sure someone with more experience will be able to explain it in more detail/more accurately.

---

<div class="post-metadata">

### Author: ![trusktr](https://discourse.nixos.org/user_avatar/discourse.nixos.org/trusktr/32/1994_2.png) [@trusktr](https://discourse.nixos.org/u/trusktr)
#### Post date: [January 18, 2020, 12:32am UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/3 "2020-01-18T00:32:53Z")

</div>

Thanks, this is definitely good information to know, and it should be included in the nixos docs up front.

Do you mind adding this recommendation over at [Does my first-ever configuration.nix look alright?](https://discourse.nixos.org/t/does-my-first-ever-configuration-nix-look-alright/5372) in case I’ve installed anything there that can be installed a better way (f.e. with `programs.*.enable` instead of `systemPackages`)?

Also, how do we search for what’s available in `programs`? Using `nix search` is the first thing that I learned from the docs, but this doesn’t tell me what’s available in `programs`.

---

<div class="post-metadata">

### Author: ![lilyball](https://discourse.nixos.org/user_avatar/discourse.nixos.org/lilyball/32/939_2.png) [@lilyball](https://discourse.nixos.org/u/lilyball)
#### Post date: [January 18, 2020, 12:36am UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/4 "2020-01-18T00:36:15Z")

</div>

If you run `nixos-option programs` you will get a complete listing of all of the programs configurable in this fashion. There’s also `nixos-option services`, which has a lot more stuff in it.

---

<div class="post-metadata">

### Author: ![dalto](https://discourse.nixos.org/user_avatar/discourse.nixos.org/dalto/32/2176_2.png) [@dalto](https://discourse.nixos.org/u/dalto)
#### Post date: [January 18, 2020, 12:42am UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/5 "2020-01-18T00:42:43Z")

</div>

> [@trusktr](#):
>
> Also, how do we search for what’s available in `programs` ?

In addition to what @lilyball pointed out, I use this site quite a lot: [NixOS Search](https://nixos.org/nixos/options.html)

It allows you search easily and has links back to the nix files in github so you can see how something works directly. It is basically the same info found in `nixos-option` but in an easily consumable format.

---

<div class="post-metadata">

### Author: ![trusktr](https://discourse.nixos.org/user_avatar/discourse.nixos.org/trusktr/32/1994_2.png) [@trusktr](https://discourse.nixos.org/u/trusktr)
#### Post date: [January 18, 2020, 12:43am UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/6 "2020-01-18T00:43:44Z")

</div>

> [@lilyball](#):
>
> If you run `nixos-option programs` you will get a complete listing of all of the programs configurable in this fashion. There’s also `nixos-option services` , which has a lot more stuff in it.

Ah, great to know! This was not mentioned in the nixos manual section [6.1. Declarative Package Management](https://nixos.org/nixos/manual/index.html#sec-declarative-package-mgmt).

---

<div class="post-metadata">

### Author: ![trusktr](https://discourse.nixos.org/user_avatar/discourse.nixos.org/trusktr/32/1994_2.png) [@trusktr](https://discourse.nixos.org/u/trusktr)
#### Post date: [January 18, 2020, 12:46am UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/7 "2020-01-18T00:46:26Z")

</div>

> [@dalto](#):
>
> I use this site quite a lot: [NixOS Search](https://nixos.org/nixos/options.html)

Nice! This would be great to add to the manual up front too. I think it can be mentioned in Chapter 6 as a way to discover what available in `programs`, etc.

TODO, github issue to add it: [TODO: mention nixos-option and nixos.org/nixos/options.html in manual Chapter 6 · Issue #77959 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/issues/77959)

---

<div class="post-metadata">

### Author: ![jtojnar](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jtojnar/32/70_2.png) [@jtojnar](https://discourse.nixos.org/u/jtojnar)
#### Post date: [January 18, 2020, 1:21am UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/8 "2020-01-18T01:21:27Z")

</div>

Opened [nixos/doc: suggest checking options for declarative package mgmt by jtojnar · Pull Request #77960 · NixOS/nixpkgs · GitHub](https://github.com/NixOS/nixpkgs/pull/77960)

---

<div class="post-metadata">

### Author: ![jonringer](https://discourse.nixos.org/user_avatar/discourse.nixos.org/jonringer/32/1348_2.png) [@jonringer](https://discourse.nixos.org/u/jonringer)
#### Post date: [January 18, 2020, 1:28am UTC](https://discourse.nixos.org/t/programs-foo-enable-true-vs-systempackages-foo-is-confusing/5534/9 "2020-01-18T01:28:06Z")

</div>

If you’re on nix, don’t forget about `man configuration.nix`

It will be a good local reflection of whats on nixos-option / [NixOS Search](https://nixos.org/nixos/options.html) . If you prefer man format.

To answer your original question, generally the ‘.enable = true’ options are preferred as they will be smart about a system effects which are needed to the application/service to run correctly. For example, ‘virtualization.docker.enable = true’ will create the necessary groups, install the docker-daemon, install the docker cli, and a few other things to enable normal docker usage.
