# Using niv to version home-manager zsh plugins?

**URL:** https://discourse.nixos.org/t/using-niv-to-version-home-manager-zsh-plugins/5060
**Category:** Help
**Created:** [December 9, 2019, 1:36am UTC](https://discourse.nixos.org/t/using-niv-to-version-home-manager-zsh-plugins/5060 "2019-12-09T01:36:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mjlbach](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mjlbach/32/2063_2.png) [@mjlbach](https://discourse.nixos.org/u/mjlbach)
#### Post date: [December 9, 2019, 1:36am UTC](https://discourse.nixos.org/t/using-niv-to-version-home-manager-zsh-plugins/5060/1 "2019-12-09T01:36:09Z")

</div>

I currently have a shell configuration through home-manager which pulls specific commits from github. I’d like to automatically update these throughout my project. Currently, my config does this:

```auto
Read them by running the command 'home-manager news'.
{ config, pkgs, libs, ... }:

let sources = import ../../nix/sources.nix ;
in
{
  home = {

    packages = with pkgs; [
      zsh
      nix-zsh-completions
      bat
      exa
      fd
      fzf
      htop
      tmux
      ripgrep
      tree
      universal-ctags
      z-lua
    ];
  };

  programs.zsh = {
    enable = true;
    enableCompletion= false;
    initExtraBeforeCompInit = builtins.readFile ../../config/zsh/.zshrc ;
    plugins = [ {
      name = "powerlevel10k";
      src = pkgs.fetchFromGitHub {
        owner = sources.powerlevel10k.owner;
        repo = sources.powerlevel10k.repo;
        rev = sources.powerlevel10k.rev;
        sha256 = sources.powerlevel10k.sha256;
       };
     }
    ];
  };
}

```

I’ve heard niv is the right solution from Freenode, but I’m currently unclear how to use it in my config. The above works, but I’m not sure if there is a cleaner way which could avoid using fetchFromGithub (this seems redundant since calling the niv expression should pull the source?

---

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fzakaria/32/2643_2.png) [@fzakaria](https://discourse.nixos.org/u/fzakaria)
#### Post date: [September 2, 2020, 5:43am UTC](https://discourse.nixos.org/t/using-niv-to-version-home-manager-zsh-plugins/5060/2 "2020-09-02T05:43:12Z")

</div>

@mjlbach you can use `outPath`

For instance my niv has `ohmytmux`

```bash
nix-repl> sources = import ./nix/sources.nix

nix-repl> :p sources.ohmytmux.outPath        
"/nix/store/g4rqqm935w80vv4ybi8g6z1m4y2pxnlj-ohmytmux-src"

```

So you can probably just set `src` to that; in fact the variable automatically converts to a string. (Unclear what causes this in Nix)

```bash
nix-repl> :p sources.ohmytmux.outPath + "/"
"/nix/store/g4rqqm935w80vv4ybi8g6z1m4y2pxnlj-ohmytmux-src/"

```

---

<div class="post-metadata">

### Author: ![danieldk](https://discourse.nixos.org/user_avatar/discourse.nixos.org/danieldk/32/31405_2.png) [@danieldk](https://discourse.nixos.org/u/danieldk)
#### Post date: [September 2, 2020, 12:16pm UTC](https://discourse.nixos.org/t/using-niv-to-version-home-manager-zsh-plugins/5060/3 "2020-09-02T12:16:22Z")

</div>

> [@fzakaria](#):
>
> @mjlbach you can use `outPath`

Or use antiquotation. E.g.:

```auto
somepath = "${sources.mozilla}/package-set.nix"

```

---

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fzakaria/32/2643_2.png) [@fzakaria](https://discourse.nixos.org/u/fzakaria)
#### Post date: [September 2, 2020, 2:06pm UTC](https://discourse.nixos.org/t/using-niv-to-version-home-manager-zsh-plugins/5060/4 "2020-09-02T14:06:23Z")

</div>

What part of the nix language auto coerces attrset to a string?

I can’t find it anywhere.

---

<div class="post-metadata">

### Author: ![danieldk](https://discourse.nixos.org/user_avatar/discourse.nixos.org/danieldk/32/31405_2.png) [@danieldk](https://discourse.nixos.org/u/danieldk)
#### Post date: [September 2, 2020, 3:58pm UTC](https://discourse.nixos.org/t/using-niv-to-version-home-manager-zsh-plugins/5060/5 "2020-09-02T15:58:18Z")

</div>

> [@fzakaria](#):
>
> What part of the nix language auto coerces attrset to a string?

Good question.

> <https://github.com/NixOS/nix/blob/b721877b85bbf9f78fd2221d8eb540373ee1e889/src/libexpr/eval.cc#L1772>

```auto
nix-repl> foo = {}
nix-repl> "${foo}"
error: cannot coerce a set to a string, at (string):1:2
nix-repl> bar = { outPath = "/hello/world"; }
nix-repl> "${bar}"                            
"/hello/world"

```

I guess it would be nice if this was documented in the Nix manual.

---

<div class="post-metadata">

### Author: ![fzakaria](https://discourse.nixos.org/user_avatar/discourse.nixos.org/fzakaria/32/2643_2.png) [@fzakaria](https://discourse.nixos.org/u/fzakaria)
#### Post date: [September 2, 2020, 4:12pm UTC](https://discourse.nixos.org/t/using-niv-to-version-home-manager-zsh-plugins/5060/6 "2020-09-02T16:12:46Z")

</div>

Thanks for finding the source lines; yea it seems like a pretty useful feature for _coercing_.  
Maybe a Wiki entry or a GitHub issue to document.

I’ll see what I have time for today.
