diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix index dc29e45b8c8f..02de5801da25 100644 --- a/nixos/modules/virtualisation/containers.nix +++ b/nixos/modules/virtualisation/containers.nix @@ -463,15 +463,10 @@ in A specification of the desired configuration of this container, as a NixOS module. ''; - type = let - confPkgs = if config.pkgs == null then pkgs else config.pkgs; - in lib.mkOptionType { + type = lib.mkOptionType { name = "Toplevel NixOS config"; - merge = loc: defs: (import (confPkgs.path + "/nixos/lib/eval-config.nix") { + merge = loc: defs: (import ../../lib/eval-config.nix { inherit system; - pkgs = confPkgs; - baseModules = import (confPkgs.path + "/nixos/modules/module-list.nix"); - inherit (confPkgs) lib; modules = let extraConfig = { @@ -520,15 +515,6 @@ in ''; }; - pkgs = mkOption { - type = types.nullOr types.attrs; - default = null; - example = literalExample "pkgs"; - description = '' - Customise which nixpkgs to use for this container. - ''; - }; - ephemeral = mkOption { type = types.bool; default = false; diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index b4a4f450ac4d..c16fbac05041 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -51,7 +51,7 @@ in codimd = handleTest ./codimd.nix {}; consul = handleTest ./consul.nix {}; containers-bridge = handleTest ./containers-bridge.nix {}; - containers-custom-pkgs.nix = handleTest ./containers-custom-pkgs.nix {}; + containers-nixpkgs-overlays.nix = handleTest ./containers-nixpkgs-overlays.nix {}; containers-ephemeral = handleTest ./containers-ephemeral.nix {}; containers-extra_veth = handleTest ./containers-extra_veth.nix {}; containers-hosts = handleTest ./containers-hosts.nix {}; diff --git a/nixos/tests/containers-custom-pkgs.nix b/nixos/tests/containers-nixpkgs-overlays.nix similarity index 69% rename from nixos/tests/containers-custom-pkgs.nix rename to nixos/tests/containers-nixpkgs-overlays.nix index 397a4a905e6d..59c50f6ffb13 100644 --- a/nixos/tests/containers-custom-pkgs.nix +++ b/nixos/tests/containers-nixpkgs-overlays.nix @@ -1,12 +1,10 @@ -# Test for NixOS' container support. +# Test for nixpkgs overlays inside NixOS containers. import ./make-test-python.nix ({ pkgs, lib, ...} : let - customPkgs = pkgs // { - hello = pkgs.hello.overrideAttrs(old: { - name = "custom-hello"; - }); - }; + customHello = pkgs.hello.overrideAttrs(old: { + name = "custom-hello"; + }); in { name = "containers-hosts"; @@ -22,8 +20,11 @@ in { containers.simple = { autoStart = true; - pkgs = customPkgs; config = {pkgs, config, ... }: { + nixpkgs.overlays = [(self: super: { + hello = customHello; + })]; + environment.systemPackages = [ pkgs.hello ]; @@ -36,7 +37,7 @@ in { 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" + "test $(nixos-container run simple -- readlink -f /run/current-system/sw/bin/hello) = ${customHello}/bin/hello" ) ''; })