nixos-containers: Add support for custom nixpkgs argument
This commit is contained in:
parent
53c14c4e65
commit
ab37d7e7ea
@ -463,10 +463,15 @@ in
|
|||||||
A specification of the desired configuration of this
|
A specification of the desired configuration of this
|
||||||
container, as a NixOS module.
|
container, as a NixOS module.
|
||||||
'';
|
'';
|
||||||
type = lib.mkOptionType {
|
type = let
|
||||||
|
confPkgs = if config.pkgs == null then pkgs else config.pkgs;
|
||||||
|
in lib.mkOptionType {
|
||||||
name = "Toplevel NixOS config";
|
name = "Toplevel NixOS config";
|
||||||
merge = loc: defs: (import ../../lib/eval-config.nix {
|
merge = loc: defs: (import (confPkgs.path + "/nixos/lib/eval-config.nix") {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
pkgs = confPkgs;
|
||||||
|
baseModules = import (confPkgs.path + "/nixos/modules/module-list.nix");
|
||||||
|
inherit (confPkgs) lib;
|
||||||
modules =
|
modules =
|
||||||
let
|
let
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
@ -515,6 +520,15 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pkgs = mkOption {
|
||||||
|
type = types.nullOr types.attrs;
|
||||||
|
default = null;
|
||||||
|
example = literalExample "pkgs";
|
||||||
|
description = ''
|
||||||
|
Customise which nixpkgs to use for this container.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
ephemeral = mkOption {
|
ephemeral = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
@ -53,6 +53,7 @@ in
|
|||||||
consul = handleTest ./consul.nix {};
|
consul = handleTest ./consul.nix {};
|
||||||
cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {};
|
cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {};
|
||||||
containers-bridge = handleTest ./containers-bridge.nix {};
|
containers-bridge = handleTest ./containers-bridge.nix {};
|
||||||
|
containers-custom-pkgs.nix = handleTest ./containers-custom-pkgs.nix {};
|
||||||
containers-ephemeral = handleTest ./containers-ephemeral.nix {};
|
containers-ephemeral = handleTest ./containers-ephemeral.nix {};
|
||||||
containers-extra_veth = handleTest ./containers-extra_veth.nix {};
|
containers-extra_veth = handleTest ./containers-extra_veth.nix {};
|
||||||
containers-hosts = handleTest ./containers-hosts.nix {};
|
containers-hosts = handleTest ./containers-hosts.nix {};
|
||||||
|
42
nixos/tests/containers-custom-pkgs.nix
Normal file
42
nixos/tests/containers-custom-pkgs.nix
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# Test for NixOS' container support.
|
||||||
|
|
||||||
|
import ./make-test-python.nix ({ pkgs, lib, ...} : let
|
||||||
|
|
||||||
|
customPkgs = pkgs // {
|
||||||
|
hello = pkgs.hello.overrideAttrs(old: {
|
||||||
|
name = "custom-hello";
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
in {
|
||||||
|
name = "containers-hosts";
|
||||||
|
meta = with lib.maintainers; {
|
||||||
|
maintainers = [ adisbladis ];
|
||||||
|
};
|
||||||
|
|
||||||
|
machine =
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
virtualisation.memorySize = 256;
|
||||||
|
virtualisation.vlans = [];
|
||||||
|
|
||||||
|
containers.simple = {
|
||||||
|
autoStart = true;
|
||||||
|
pkgs = customPkgs;
|
||||||
|
config = {pkgs, config, ... }: {
|
||||||
|
environment.systemPackages = [
|
||||||
|
pkgs.hello
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
machine.wait_for_unit("default.target")
|
||||||
|
machine.succeed(
|
||||||
|
"test $(nixos-container run simple -- readlink -f /run/current-system/sw/bin/hello) = ${customPkgs.hello}/bin/hello"
|
||||||
|
)
|
||||||
|
'';
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user