Using niv to version home-manager zsh plugins?

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:

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

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

    packages = with pkgs; [

  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?

@mjlbach you can use outPath

For instance my niv has ohmytmux

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

nix-repl> :p sources.ohmytmux.outPath        

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

nix-repl> :p sources.ohmytmux.outPath + "/"

Or use antiquotation. E.g.:

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

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

I can’t find it anywhere.

Good question.

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}"                            

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

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.