-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create default.nix during niv init #95
Comments
Why not just have options to |
I'll be honest, requiring extra options is less than ideal. Instead have |
I gave this some thoughts over the past few days and came up with this (feedback welcome):
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
in pkgs.hello should be simple enough that people might actually use it, and still it showcases how to use niv. |
I agree that having a simple enough example to build off of is a good idea. I would extend this idea by also generating a |
So I think there are two big use cases for
Importing dependencies and using them in |
Why not have both? Keep the existing behavior of
|
I end up setting up every repo I use Recently, I've also taken to adding "sources" as an overlay so I can do So it seems to me that # nix/default.nix
{ sources ? import ./sources.nix, system ? builtins.currentSystem }:
let
srcs = self: super: { inherit sources; };
overlays = [ srcs ];
config = { };
in import sources.nixpkgs { inherit overlays config system; } is essentially my starter boilerplate in # default.nix (at repo root)
let pkgs = import ./nix {};
in pkgs.hello # shell.nix (at repo root)
let pkgs = import ./nix {};
in pkgs.stdenv.mkShell {
buildInputs = [ pkgs.hello ];
} How well do you think that pattern would work? One thing I'd be concerned about is adding a bunch of extra utility to the edit: updated proposed default.nix to account for system. |
👍 , I think that's close to the perfect { sources ? ...
, system ? builtins.currentSystem
}:
...
in sources.nixpkgs { inherit overlays config system; } I think we should just go for it, maybe hiding it behind a flag (e.g. |
I find injecting the I want something different from |
(One small rant: importing |
@michaelpj the nix flakes branch actually does a lot of that for you, they replace 80% of what niv does (sorry nmattia), creates a standard entrypoint for repositories, handles |
You're absolutely right, my apologies; I didn't actually know I should include system as I've only seen it done once in someone's config online. Is there a wiki page for "how to import nixpkgs properly" or is it a sort of cult knowledge that's acquired by making mistakes over time?
Fortunately, even if Although, since niv includes nixpkgs by default in its init, that actually suggests to me that it's even more important that niv's init also come with a way to fully correctly import nixpkgs. Otherwise it's far too easy to just make the mistake of writing the naive |
I know about flakes :) my feeling is rather that
I got it the latter way 😅
Is it? I like that |
This was copied from: nmattia/niv#95 (comment)
It seems to be easier to pin nixpkgs directly in `shell.nix`/`default.nix`. It's functionality also overlaps with `nix-wrangle` and, more importantly, `nix flakes`. From `zimbatm` in `niv` issue #95: nmattia/niv#95 (comment) > the nix flakes branch actually does a lot > of that for you, they replace 80% of > what niv does (sorry nmattia), creates > a standard entrypoint for repositories, > handles system and a few other things. You > can test it by setting nix.package = > pkgs.nixFlakes; in NixOS.
Hey guys, would love your feedback on #272 |
The
niv init
command used to create a few files (default.nix
,shell.nix
, etc) which some people didn't like. Some people now complain that they want it back. I think the best solution here is to haveniv init
create a single extra file,default.nix
, whichimport nix/sources.nix
pkgs.hello
) package,inNixShell
The text was updated successfully, but these errors were encountered: