Allow to configure niv directory path#133
Allow to configure niv directory path#133uvNikita wants to merge 1 commit intonmattia:masterfrom uvNikita:niv_dir
Conversation
New NIV_DIR environment variable configures a path to a directory
where niv will manage sources.{nix,json} files.
|
@nmattia Is there anything one can contribute to this to get it merged? :) |
|
Oh wow! Apologies, first time I see this PR, must have missed the notification! Would the |
|
Personally, I'd prefer the environment variable because I can ship that within a projects |
|
The main difference I guess would be that |
|
In #172 I asked for this same feature as a CLI option instead of an environment variable. I think I'd like to do both because the user gets better documentation with I may make a PR that implements both the env var and extra command-line switch. |
|
I just realized that import sources.nix { sourcesFile = PATH ; }; |
|
I'd really to have $ tree .config/
.config/
└── nix
├── shell.nix
├── sources.json
└── sources.nix
1 directory, 3 filesWhen I use $ niv --sources-file .config/nix/sources.json update nixpkgs
Update nixpkgs
WARNING: Could not read nix/sources.nix
( nix/sources.nix: openBinaryFile: does not exist (No such file or directory) )
Done: Update nixpkgsI'm not sure what the downside of the warning is. I currently workaround with $ (cd .config && niv update nixpkgs)
Update nixpkgs
Done: Update nixpkgs |
|
@steshaw that's interesting, can you tell me more about the use case? Do you use niv globally, as opposed to per-project? |
ProjectsWith projects, I provision the [development] environment using direnv+nix+nix-direnv (though I used Lorri also for caching). In an example project export PROJECT_HOME=$PWD
nix_shell=$PROJECT_HOME/.config/nix/shell.nix
use nix "${nix_shell}"
watch_file "${nix_shell}"
PATH_add scriptsThe Being able to add export NIV_DIR=$PWD/.config/nixto my I wrote up an unpublished article about how I use XDG-style layout for projects. I still use this layout as much as possible today, though I've moved GlobalNot entirely sure what you mean by global but I have 2 candidates: global NixOS configuration and my user profile. I don't use Are you thinking that export NIV_DIR=~/Code/steshaw/shelly/nix/nixIf I also used |
Then you may want to give https://github.com/nmattia/sorri a try! It's a work in progress but we already use it at $WORK.
Ok, that makes a lot of sense. I want to spend some time cleaning up #279 this week, I might as well add support for |
|
Thanks! I'll be sure to check out https://github.com/nmattia/sorri as well 😄 |
|
Thanks for sharing your work-around @steshaw! Addng DirEnv to the mix, this is loaded by adding Looking forward to when this PR is merge so that Niv mgmt will be more "normalized". Thanks! |
New NIV_DIR environment variable configures a path to a directory
where niv will manage sources.{nix,json} files.