niv
niv copied to clipboard
Pros/cons of using niv via overlay vs importing sources
For instance the readme suggests:
{ sources ? import ./sources.nix }: # import the sources
with
{ overlay = _: pkgs:
{ niv = import sources.niv {}; # use the sources :)
};
};
import sources.nixpkgs # and use them again!
{ overlays = [ overlay ] ; config = {}; }
I've always written things more like:
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
my-pinned-package = import sources.my-pinned-package {};
in
pkgs.mkShell {
buildInputs = [
pkgs.hello pkgs.python3 my-pinned-package
];
}
Is there anything wrong (like not overridden) using the second way? I raise this issue because I suspect something might not be overriden in my emacs config:
{ pkgs, ... }:
let
sources = import ./nix/sources.nix;
# TODO use niv for emacs-overlay
emacs-overlay = builtins.fetchTarball "https://github.com/nix-community/emacs-overlay/archive/52b9fd468cd45f85c43f9b623ed2854971d8e1ad.tar.gz";
pkgs = import sources.nixpkgs { overlays = [ (import emacs-overlay) ]; };
nivpkg = import sources.niv {};
home-manager = import sources.home-manager { pkgs = pkgs; };
doom-emacs = import ./doomemacs.nix { sources = sources; pkgs = pkgs;};
in
{
programs = {
home-manager.enable = true;
};
home = {
packages = with pkgs; [ doom-emacs ];
};
}
Somewhat related, I think that I might be getting bit by this:
Otherwise it's far too easy to just make the mistake of writing the naive let sources = import ./nix/sources.nix; pkgs = import sources.nixpkgs {}; and then, whoops, that'll no longer work correctly on mac systems as you've pointed out. - @jared-w
https://github.com/nmattia/niv/issues/95#issuecomment-572265711
There are other pieces to it too though including haskell.nix, so I'd need to put some work into making a small reproducible example.
The gist of it is that for some reason packages with native dependencies don't show up in a haskell.nix repo. Saying it aloud though, that sounds unrelated.
That all looks correct to me. It shouldn't matter how you import sources, either through an overlay or directly. All the overlay does (in this particular example) is let you conveniently access things through pkgs
as a "namespace"
All looks correct to me too. @codygman did you figure it out? Alternatively can you share your config so that we can have a better look?
@nmattia Kinda of. I guess really what I'm wanting to answer and would have asked had I know this is how can I replace this line with a niv-managed emacs dependency.
So my desired workflow is:
- Notice I want a custom version of magit
- niv add forge/magit
- home-manager switch
I think the second approach doesn't make this possible, but then again maybe the second approach doesn't either. I asked that question to try and confirm whether the second approach I didn't understand well made my desired workflow possible.
I'm beginning to suspect that maybe I need to use flakes if I want that workflow, but I know I suspect it's a little early for that and I'll run into issues I wouldn't run into if I can massage niv into that workflow.