Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 98063b86b19e
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 14a9365952fc
Choose a head ref
  • 3 commits
  • 1 file changed
  • 2 contributors

Commits on Oct 30, 2018

  1. Copy the full SHA
    c3a7194 View commit details

Commits on Nov 3, 2018

  1. Copy the full SHA
    666e0ab View commit details

Commits on Nov 4, 2018

  1. Merge pull request #49462 from roberth/pkgs-nixos-example

    pkgs.nixos: Add example to inline documentation
    roberth authored Nov 4, 2018
    Copy the full SHA
    14a9365 View commit details
Showing with 50 additions and 32 deletions.
  1. +50 −32 pkgs/top-level/all-packages.nix
82 changes: 50 additions & 32 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
@@ -22109,38 +22109,56 @@ with pkgs;

nixops-dns = callPackage ../tools/package-management/nixops/nixops-dns.nix { };

/*
* Evaluate a NixOS configuration using this evaluation of Nixpkgs.
*
* With this function you can write, for example, a package that
* depends on a custom virtual machine image.
*
* Parameter: A module, path or list of those that represent the
* configuration of the NixOS system to be constructed.
*
* Result: An attribute set containing packages produced by this
* evaluation of NixOS, such as toplevel, kernel and
* initialRamdisk.
* The result can be extended in the modules by defining
* extra options in system.build.
*
* Unlike in plain NixOS, the nixpkgs.config, nixpkgs.overlays and
* nixpkgs.system options will be ignored by default. Instead,
* nixpkgs.pkgs will have the default value of pkgs as it was
* constructed right after invoking the nixpkgs function (e.g. the
* value of import <nixpkgs> { overlays = [./my-overlay.nix]; }
* but not the value of (import <nixpkgs> {} // { extra = ...; }).
*
* If you do want to use the config.nixpkgs options, you are
* probably better off by calling nixos/lib/eval-config.nix
* directly, even though it is possible to set config.nixpkgs.pkgs.
*
* For more information about writing NixOS modules, see
* https://nixos.org/nixos/manual/index.html#sec-writing-modules
*
* Note that you will need to have called Nixpkgs with the system
* parameter set to the right value for your deployment target.
*/
/* Evaluate a NixOS configuration using this evaluation of Nixpkgs.

With this function you can write, for example, a package that
depends on a custom virtual machine image.

Parameter: A module, path or list of those that represent the
configuration of the NixOS system to be constructed.

Result: An attribute set containing packages produced by this
evaluation of NixOS, such as toplevel, kernel and
initialRamdisk.
The result can be extended in the modules by defining
extra attributes in system.build.

Example:

let
myOS = pkgs.nixos ({ lib, pkgs, config, ... }: {

config.services.nginx = {
enable = true;
# ...
};

# Use config.system.build to exports relevant parts of a
# configuration. The runner attribute should not be
# considered a fully general replacement for systemd
# functionality.
config.system.build.run-nginx = config.systemd.services.nginx.runner;
});
in
myOS.run-nginx

Unlike in plain NixOS, the nixpkgs.config, nixpkgs.overlays and
nixpkgs.system options will be ignored by default. Instead,
nixpkgs.pkgs will have the default value of pkgs as it was
constructed right after invoking the nixpkgs function (e.g. the
value of import <nixpkgs> { overlays = [./my-overlay.nix]; }
but not the value of (import <nixpkgs> {} // { extra = ...; }).

If you do want to use the config.nixpkgs options, you are
probably better off by calling nixos/lib/eval-config.nix
directly, even though it is possible to set config.nixpkgs.pkgs.

For more information about writing NixOS modules, see
https://nixos.org/nixos/manual/index.html#sec-writing-modules

Note that you will need to have called Nixpkgs with the system
parameter set to the right value for your deployment target.
*/
nixos = configuration:
(import (self.path + "/nixos/lib/eval-config.nix") {
inherit (pkgs.stdenv.hostPlatform) system;