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: ad18c540ff2b
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0874ee8f0553
Choose a head ref
  • 7 commits
  • 5 files changed
  • 2 contributors

Commits on Nov 13, 2018

  1. Add pkgs.nixosTest

    roberth committed Nov 13, 2018
    Copy the full SHA
    cdca66d View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    933c95c View commit details
  3. tests: Don't use pkgs.extend. OfBorg will reject it.

    The good news is that it worked as expected.
    roberth committed Nov 13, 2018
    Copy the full SHA
    5d594d7 View commit details
  4. pkgs.nixosTest: format

    roberth committed Nov 13, 2018
    Copy the full SHA
    d82e152 View commit details
  5. Copy the full SHA
    3783f2d View commit details
  6. Copy the full SHA
    5a8bddf View commit details

Commits on Nov 14, 2018

  1. Merge pull request #47684 from roberth/nixpkgs-nixosTest

    Add pkgs.nixosTest
    matthewbauer authored Nov 14, 2018
    Copy the full SHA
    0874ee8 View commit details
Showing with 112 additions and 5 deletions.
  1. +12 −2 nixos/lib/build-vms.nix
  2. +10 −3 nixos/lib/testing.nix
  3. +2 −0 pkgs/test/default.nix
  4. +33 −0 pkgs/test/nixos-functions/default.nix
  5. +55 −0 pkgs/top-level/all-packages.nix
14 changes: 12 additions & 2 deletions nixos/lib/build-vms.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{ system, pkgs, minimal ? false, config ? {} }:
{ system
, # Use a minimal kernel?
minimal ? false
, # Ignored
config ? null
# Nixpkgs, for qemu, lib and more
, pkgs
, # NixOS configuration to add to the VMs
extraConfigurations ? []
}:

with pkgs.lib;
with import ../lib/qemu-flags.nix { inherit pkgs; };
@@ -28,7 +37,8 @@ rec {
../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs
{ key = "no-manual"; documentation.nixos.enable = false; }
{ key = "qemu"; system.build.qemu = qemu; }
] ++ optional minimal ../modules/testing/minimal-kernel.nix;
] ++ optional minimal ../modules/testing/minimal-kernel.nix
++ extraConfigurations;
extraArgs = { inherit nodes; };
};

13 changes: 10 additions & 3 deletions nixos/lib/testing.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{ system, pkgs, minimal ? false, config ? {} }:

with import ./build-vms.nix { inherit system pkgs minimal config; };
{ system
, pkgs
# Use a minimal kernel?
, minimal ? false
# Ignored
, config ? null
# Modules to add to each VM
, extraConfigurations ? [] }:

with import ./build-vms.nix { inherit system pkgs minimal extraConfigurations; };
with pkgs;

let
2 changes: 2 additions & 0 deletions pkgs/test/default.nix
Original file line number Diff line number Diff line change
@@ -30,5 +30,7 @@ with pkgs;

cross = callPackage ./cross {};

nixos-functions = callPackage ./nixos-functions {};

patch-shebangs = callPackage ./patch-shebangs {};
}
33 changes: 33 additions & 0 deletions pkgs/test/nixos-functions/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
This file is a test that makes sure that the `pkgs.nixos` and
`pkgs.nixosTest` functions work. It's far from a perfect test suite,
but better than not checking them at all on hydra.
To run this test:
nixpkgs$ nix-build -A tests.nixos-functions
*/
{ pkgs, lib, stdenv, ... }:

lib.optionalAttrs stdenv.hostPlatform.isLinux (
pkgs.recurseIntoAttrs {

nixos-test = (pkgs.nixos {
boot.loader.grub.enable = false;
fileSystems."/".device = "/dev/null";
}).toplevel;

nixosTest-test = pkgs.nixosTest ({ lib, pkgs, ... }: {
name = "nixosTest-test";
machine = { pkgs, ... }: {
environment.systemPackages = [ pkgs.hello ];
};
testScript = ''
$machine->succeed("hello");
'';
});

}
)
55 changes: 55 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
@@ -22219,6 +22219,61 @@ with pkgs;
);
}).config.system.build;


/*
* Run a NixOS VM network test using this evaluation of Nixpkgs.
*
* It is mostly equivalent to `import ./make-test.nix` from the
* NixOS manual[1], except that your `pkgs` will be used instead of
* letting NixOS invoke Nixpkgs again. If a test machine needs to
* set NixOS options under `nixpkgs`, it must set only the
* `nixpkgs.pkgs` option. For the details, see the Nixpkgs
* `pkgs.nixos` documentation.
*
* Parameter:
* A NixOS VM test network, or path to it. Example:
*
* { lib, ... }:
* { name = "my-test";
* nodes = {
* machine-1 = someNixOSConfiguration;
* machine-2 = ...;
* }
* }
*
* Result:
* A derivation that runs the VM test.
*
* [1]: For writing NixOS tests, see
* https://nixos.org/nixos/manual/index.html#sec-nixos-tests
*/
nixosTest =
let
/* The nixos/lib/testing.nix module, preapplied with arguments that
* make sense for this evaluation of Nixpkgs.
*/
nixosTesting =
(import ../../nixos/lib/testing.nix {
inherit (pkgs.stdenv.hostPlatform) system;
inherit pkgs;
extraConfigurations = [(
{ lib, ... }: {
config.nixpkgs.pkgs = lib.mkDefault pkgs;
}
)];
});
in
test:
let
loadedTest = if builtins.typeOf test == "path"
then import test
else test;
calledTest = if pkgs.lib.isFunction loadedTest
then callPackage loadedTest {}
else loadedTest;
in
nixosTesting.makeTest calledTest;

nixui = callPackage ../tools/package-management/nixui { node_webkit = nwjs_0_12; };

nixdoc = callPackage ../tools/nix/nixdoc {};