Skip to content
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

Make NixOS available first-class in NixPkgs #32354

Closed
roberth opened this issue Dec 5, 2017 · 7 comments
Closed

Make NixOS available first-class in NixPkgs #32354

roberth opened this issue Dec 5, 2017 · 7 comments

Comments

@roberth
Copy link
Member

roberth commented Dec 5, 2017

Issue description

Building a NixOS configuration from a Nix expression is already possible, but the way the user should do it is non-obvious, hacky and error prone. (See 'Technical details')
I suggest we define a top level function in NixPkgs called nixosConfig.

As this is relevant to the overall architecture, I would like to know the opinion and advice of @edolstra and @nbp

Note that /pkgs currently only imports /nixos at

module = ../../../../nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix;

Technical details

The user is currently faced with the following choices:

  • How to import? import <nixpkgs/nixos> or import (pkgs.path + "/nixos")
  • Which file to import? /nixos or nixos/lib/eval-config.nix
    and the following opportunities for mistakes:
  • system argument
  • pkgs argument

Design

I suggest we define a function pkgs.nixosConfig that is a small wrapper around nixos/lib/eval-config.nix. Its responsibility is to

  • insert the right pkgs into the new NixOS configuration
  • override any impure inputs to eval-config.nix, like the system parameter (builtins.currentSystem)

Implementation

The following definition works for my application in an overlay, but can probably be improved.

nixosConfig = { modules, system ? super.system, baseModules ? null }:
  import (super.path + "/nixos/lib/eval-config.nix") ({
    inherit system modules;
    pkgs = self;
  } // (if baseModules == null then {} else { inherit baseModules; }));

I'll make a PR if you think this is a good idea.

@roberth
Copy link
Member Author

roberth commented Dec 6, 2017

@williammpratt, That was a little unexpected, but thank you for your feedback.

  • The creation of this issue was in good faith, to improve the quality of nixpkgs.
  • I have followed the guidelines for contributing.
  • I understand now that '@'-mentioning these community members is not desirable at this stage.

I am not just saying this to defend my actions, but to point out a minor flaw in the process here. You've pointed out the need for documentation. I will also check the RFCs (and issue tracker) to help improve the community processes' documentation and reduce this kind of friction for maintainers and future contributors.

@roberth roberth closed this as completed Dec 6, 2017
@edolstra
Copy link
Member

edolstra commented Dec 7, 2017

I have blocked williammpratt, who appears to be the latest incarnation of a user we've blocked several times before for making abusive comments in NixOS repositories.

@roberth Please don't be discouraged by williammpratt, who doesn't speak for any NixOS contributors.

@dhess
Copy link
Contributor

dhess commented Dec 7, 2017

Personally I would love to see more "special" functions like eval-config.nix exported via pkgs or lib. I end up importing them via <nixpkgs/...> quite a bit in my own configs, and that has the problem of being tied to NIX_PATH when I'm trying to move everything to a project-wide "pinned" Nixpkgs.

@roberth
Copy link
Member Author

roberth commented Dec 7, 2017

What a shame. Thank you Eelco. I will polish and document the thing and open a PR tomorrow.

@nbp
Copy link
Member

nbp commented Dec 17, 2017

@roberth Thanks for opening this issue. This is definitely a great idea!
I can foresee such expression to have multiple outputs such as a system-output / vm-output / ...

@roberth
Copy link
Member Author

roberth commented Dec 17, 2017

@nbp, I've made a pull request, #32422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@dhess @roberth @edolstra @nbp @FRidh and others