···9999 problems.
100100 :::
101101102102+`types.pkgs`
103103+104104+: A type for the top level Nixpkgs package set.
105105+102106### Numeric types {#sec-option-types-numeric}
103107104108`types.int`
+15-9
nixos/lib/eval-config.nix
···3838in
39394040let
4141+ inherit (lib) optional;
4242+4143 evalModulesMinimal = (import ./default.nix {
4244 inherit lib;
4345 # Implicit use of feature is noted in implementation.
···4749 pkgsModule = rec {
4850 _file = ./eval-config.nix;
4951 key = _file;
5050- config = {
5151- # Explicit `nixpkgs.system` or `nixpkgs.localSystem` should override
5252- # this. Since the latter defaults to the former, the former should
5353- # default to the argument. That way this new default could propagate all
5454- # they way through, but has the last priority behind everything else.
5555- nixpkgs.system = lib.mkIf (system != null) (lib.mkDefault system);
5656-5757- _module.args.pkgs = lib.mkIf (pkgs_ != null) (lib.mkForce pkgs_);
5858- };
5252+ config = lib.mkMerge (
5353+ (optional (system != null) {
5454+ # Explicit `nixpkgs.system` or `nixpkgs.localSystem` should override
5555+ # this. Since the latter defaults to the former, the former should
5656+ # default to the argument. That way this new default could propagate all
5757+ # they way through, but has the last priority behind everything else.
5858+ nixpkgs.system = lib.mkDefault system;
5959+ })
6060+ ++
6161+ (optional (pkgs_ != null) {
6262+ _module.args.pkgs = lib.mkForce pkgs_;
6363+ })
6464+ );
5965 };
60666167 withWarnings = x:
+51-6
nixos/lib/testing/nodes.nix
···11testModuleArgs@{ config, lib, hostPkgs, nodes, ... }:
2233let
44- inherit (lib) mkOption mkForce optional types mapAttrs mkDefault mdDoc;
55-66- system = hostPkgs.stdenv.hostPlatform.system;
44+ inherit (lib)
55+ literalExpression
66+ literalMD
77+ mapAttrs
88+ mdDoc
99+ mkDefault
1010+ mkIf
1111+ mkOption mkForce
1212+ optional
1313+ optionalAttrs
1414+ types
1515+ ;
716817 baseOS =
918 import ../eval-config.nix {
1010- inherit system;
1919+ system = null; # use modularly defined system
1120 inherit (config.node) specialArgs;
1221 modules = [ config.defaults ];
1322 baseModules = (import ../../modules/module-list.nix) ++
···1726 ({ config, ... }:
1827 {
1928 virtualisation.qemu.package = testModuleArgs.config.qemu.package;
2020-2929+ })
3030+ (optionalAttrs (!config.node.pkgsReadOnly) {
3131+ key = "nodes.nix-pkgs";
3232+ config = {
2133 # Ensure we do not use aliases. Ideally this is only set
2234 # when the test framework is used by Nixpkgs NixOS tests.
2335 nixpkgs.config.allowAliases = false;
2424- })
3636+ # TODO: switch to nixpkgs.hostPlatform and make sure containers-imperative test still evaluates.
3737+ nixpkgs.system = hostPkgs.stdenv.hostPlatform.system;
3838+ };
3939+ })
2540 testModuleArgs.config.extraBaseModules
2641 ];
2742 };
···6883 default = { };
6984 };
70858686+ node.pkgs = mkOption {
8787+ description = mdDoc ''
8888+ The Nixpkgs to use for the nodes.
8989+9090+ Setting this will make the `nixpkgs.*` options read-only, to avoid mistakenly testing with a Nixpkgs configuration that diverges from regular use.
9191+ '';
9292+ type = types.nullOr types.pkgs;
9393+ default = null;
9494+ defaultText = literalMD ''
9595+ `null`, so construct `pkgs` according to the `nixpkgs.*` options as usual.
9696+ '';
9797+ };
9898+9999+ node.pkgsReadOnly = mkOption {
100100+ description = mdDoc ''
101101+ Whether to make the `nixpkgs.*` options read-only. This is only relevant when [`node.pkgs`](#test-opt-node.pkgs) is set.
102102+103103+ Set this to `false` when any of the [`nodes`](#test-opt-nodes) needs to configure any of the `nixpkgs.*` options. This will slow down evaluation of your test a bit.
104104+ '';
105105+ type = types.bool;
106106+ default = config.node.pkgs != null;
107107+ defaultText = literalExpression ''node.pkgs != null'';
108108+ };
109109+71110 node.specialArgs = mkOption {
72111 type = types.lazyAttrsOf types.raw;
73112 default = { };
···100139 config.nodes;
101140102141 passthru.nodes = config.nodesCompat;
142142+143143+ defaults = mkIf config.node.pkgsReadOnly {
144144+ nixpkgs.pkgs = config.node.pkgs;
145145+ imports = [ ../../modules/misc/nixpkgs/read-only.nix ];
146146+ };
147147+103148 };
104149}
+3-3
nixos/modules/misc/nixpkgs.nix
···4949 merge = lib.mergeOneOption;
5050 };
51515252- pkgsType = mkOptionType {
5353- name = "nixpkgs";
5252+ pkgsType = types.pkgs // {
5353+ # This type is only used by itself, so let's elaborate the description a bit
5454+ # for the purpose of documentation.
5455 description = "An evaluation of Nixpkgs; the top level attribute set of packages";
5555- check = builtins.isAttrs;
5656 };
57575858 # Whether `pkgs` was constructed by this module - not if nixpkgs.pkgs or
+74
nixos/modules/misc/nixpkgs/read-only.nix
···11+# A replacement for the traditional nixpkgs module, such that none of the modules
22+# can add their own configuration. This ensures that the Nixpkgs configuration is
33+# exactly as the user intends.
44+# This may also be used as a performance optimization when evaluating multiple
55+# configurations at once, with a shared `pkgs`.
66+77+# This is a separate module, because merging this logic into the nixpkgs module
88+# is too burdensome, considering that it is already burdened with legacy.
99+# Moving this logic into a module does not lose any composition benefits, because
1010+# its purpose is not something that composes anyway.
1111+1212+{ lib, config, ... }:
1313+1414+let
1515+ cfg = config.nixpkgs;
1616+ inherit (lib) mkOption types;
1717+1818+in
1919+{
2020+ disabledModules = [
2121+ ../nixpkgs.nix
2222+ ];
2323+ options = {
2424+ nixpkgs = {
2525+ pkgs = mkOption {
2626+ type = lib.types.pkgs;
2727+ description = lib.mdDoc ''The pkgs module argument.'';
2828+ };
2929+ config = mkOption {
3030+ internal = true;
3131+ type = types.unique { message = "nixpkgs.config is set to read-only"; } types.anything;
3232+ description = lib.mdDoc ''
3333+ The Nixpkgs `config` that `pkgs` was initialized with.
3434+ '';
3535+ };
3636+ overlays = mkOption {
3737+ internal = true;
3838+ type = types.unique { message = "nixpkgs.overlays is set to read-only"; } types.anything;
3939+ description = lib.mdDoc ''
4040+ The Nixpkgs overlays that `pkgs` was initialized with.
4141+ '';
4242+ };
4343+ hostPlatform = mkOption {
4444+ internal = true;
4545+ readOnly = true;
4646+ description = lib.mdDoc ''
4747+ The platform of the machine that is running the NixOS configuration.
4848+ '';
4949+ };
5050+ buildPlatform = mkOption {
5151+ internal = true;
5252+ readOnly = true;
5353+ description = lib.mdDoc ''
5454+ The platform of the machine that built the NixOS configuration.
5555+ '';
5656+ };
5757+ # NOTE: do not add the legacy options such as localSystem here. Let's keep
5858+ # this module simple and let module authors upgrade their code instead.
5959+ };
6060+ };
6161+ config = {
6262+ _module.args.pkgs =
6363+ # find mistaken definitions
6464+ builtins.seq cfg.config
6565+ builtins.seq cfg.overlays
6666+ builtins.seq cfg.hostPlatform
6767+ builtins.seq cfg.buildPlatform
6868+ cfg.pkgs;
6969+ nixpkgs.config = cfg.pkgs.config;
7070+ nixpkgs.overlays = cfg.pkgs.overlays;
7171+ nixpkgs.hostPlatform = cfg.pkgs.stdenv.hostPlatform;
7272+ nixpkgs.buildPlatform = cfg.pkgs.stdenv.buildPlatform;
7373+ };
7474+}
···4646 inherit
4747 (rec {
4848 doRunTest = arg: ((import ../lib/testing-python.nix { inherit system pkgs; }).evalTest {
4949- imports = [ arg ];
4949+ imports = [ arg readOnlyPkgs ];
5050 }).config.result;
5151 findTests = tree:
5252 if tree?recurseForDerivations && tree.recurseForDerivations
···6464 runTest
6565 runTestOn
6666 ;
6767+6868+ # Using a single instance of nixpkgs makes test evaluation faster.
6969+ # To make sure we don't accidentally depend on a modified pkgs, we make the
7070+ # related options read-only. We need to test the right configuration.
7171+ #
7272+ # If your service depends on a nixpkgs setting, first try to avoid that, but
7373+ # otherwise, you can remove the readOnlyPkgs import and test your service as
7474+ # usual.
7575+ readOnlyPkgs =
7676+ # TODO: We currently accept this for nixosTests, so that the `pkgs` argument
7777+ # is consistent with `pkgs` in `pkgs.nixosTests`. Can we reinitialize
7878+ # it with `allowAliases = false`?
7979+ # warnIf pkgs.config.allowAliases "nixosTests: pkgs includes aliases."
8080+ {
8181+ _class = "nixosTest";
8282+ node.pkgs = pkgs;
8383+ };
67846885in {
6986···267284 gitdaemon = handleTest ./gitdaemon.nix {};
268285 gitea = handleTest ./gitea.nix { giteaPackage = pkgs.gitea; };
269286 github-runner = handleTest ./github-runner.nix {};
270270- gitlab = handleTest ./gitlab.nix {};
287287+ gitlab = runTest ./gitlab.nix;
271288 gitolite = handleTest ./gitolite.nix {};
272289 gitolite-fcgiwrap = handleTest ./gitolite-fcgiwrap.nix {};
273290 glusterfs = handleTest ./glusterfs.nix {};
···15151616buildPythonPackage rec {
1717 pname = "xhtml2pdf";
1818- version = "0.2.9";
1818+ version = "0.2.11";
1919 format = "setuptools";
20202121 disabled = pythonOlder "3.7";
22222323- # Tests are only available on GitHub
2423 src = fetchFromGitHub {
2524 owner = pname;
2625 repo = pname;
2727- # Currently it is not possible to fetch from version as there is a branch with the same name
2828- rev = "refs/tags/${version}";
2929- hash = "sha256-MrzAsa0AZX3+0LN/Can3QBoPBRxb0a/F2jLBd8rD5H4=";
2626+ rev = "refs/tags/v${version}";
2727+ hash = "sha256-L/HCw+O8bidtE5nDdO+cLS54m64dlJL+9Gjcye5gM+w=";
3028 };
31293230 propagatedBuildInputs = [
···5149 meta = with lib; {
5250 description = "A PDF generator using HTML and CSS";
5351 homepage = "https://github.com/xhtml2pdf/xhtml2pdf";
5252+ changelog = "https://github.com/xhtml2pdf/xhtml2pdf/releases/tag/v${version}";
5453 license = licenses.asl20;
5554 maintainers = with maintainers; [ ];
5655 };
···11+From e00a5257a6ca5fedbf68b09eee7df3502971a057 Mon Sep 17 00:00:00 2001
22+From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= <joerg@thalheim.io>
33+Date: Sat, 24 Apr 2021 10:11:40 +0200
44+Subject: [PATCH 1/2] No impure bin sh
55+66+default_shell is used to populuate default shell used to execute jobs.
77+Unless SHELL is set to a different value this would be /bin/sh.
88+Our stdenv provides sh in form of bash anyway. Having this value not
99+hard-coded has some advantages:
1010+1111+- It would ensure that on all systems it uses sh from its PATH rather
1212+ than /bin/sh, which helps as different systems might have different
1313+ shells there (bash vs. dash)
1414+- In the past I had issues with LD_PRELOAD with BEAR, where /bin/sh
1515+ used a different glibc than BEAR which came from my development shell.
1616+---
1717+ src/job.c | 2 +-
1818+ 1 file changed, 1 insertion(+), 1 deletion(-)
1919+2020+diff --git a/src/job.c b/src/job.c
2121+index ae1f18b..6b4ddb3 100644
2222+--- a/src/job.c
2323++++ b/src/job.c
2424+@@ -77,7 +77,7 @@ char * vms_strsignal (int status);
2525+2626+ #else
2727+2828+-const char *default_shell = "/bin/sh";
2929++const char *default_shell = "sh";
3030+ int batch_mode_shell = 0;
3131+3232+ #endif
3333+--
3434+2.31.1
3535+