nixpkgs: always provide the option definitions

This allows evaluation of configurations where nixpkgs.* options are
used even when in a flake setup with unchanged default values.
This commit is contained in:
Tobias Happ 2021-12-10 22:26:02 +01:00 committed by Alexander Sosedkin
parent 7b9ba13632
commit 8972fbf3da
4 changed files with 36 additions and 11 deletions

View file

@ -18,6 +18,7 @@ let
{
_module.args.home-manager = home-manager;
_module.args.pkgs = mkDefault pkgs;
_module.args.isFlake = isFlake;
}
configModule
] ++ import ./module-list.nix { inherit pkgs isFlake; };

View file

@ -14,8 +14,9 @@
./environment/path.nix
./environment/session-init.nix
./home-manager.nix
./nixpkgs/options.nix
./time.nix
./user.nix
./version.nix
(pkgs.path + "/nixos/modules/misc/assertions.nix")
] ++ pkgs.lib.optionals (!isFlake) [ ./nixpkgs.nix ]
] ++ pkgs.lib.optionals (!isFlake) [ ./nixpkgs/config.nix ]

View file

@ -0,0 +1,24 @@
# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE.
# Inspired by
# https://github.com/rycee/home-manager/blob/master/modules/misc/nixpkgs.nix
# (Copyright (c) 2017-2019 Robert Helgesson and Home Manager contributors,
# licensed under MIT License as well)
{ config, lib, pkgs, ... }:
with lib;
{
###### implementation
config = {
_module.args.pkgs = import <nixpkgs> (
filterAttrs (n: v: v != null) config.nixpkgs
);
nixpkgs.overlays = import ../../overlays;
};
}

View file

@ -1,11 +1,11 @@
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE.
# Inspired by
# https://github.com/rycee/home-manager/blob/master/modules/misc/nixpkgs.nix
# (Copyright (c) 2017-2019 Robert Helgesson and Home Manager contributors,
# licensed under MIT License as well)
{ config, lib, pkgs, ... }:
{ config, lib, pkgs, isFlake, ... }:
with lib;
@ -53,11 +53,6 @@ let
check = builtins.isFunction;
merge = lib.mergeOneOption;
};
_pkgs = import <nixpkgs> (
filterAttrs (n: v: v != null) config.nixpkgs
);
in
{
@ -164,9 +159,13 @@ in
config = {
_module.args.pkgs = _pkgs;
nixpkgs.overlays = import ../overlays;
assertions = [
{
assertion = isFlake -> config.nixpkgs.config == null && (config.nixpkgs.overlays == null || config.nixpkgs.overlays == []);
message = "In a flake setup, the options nixpkgs.* should not be used. Instead, rely on the provided flake "
+ "outputs and pass in the necessary nixpkgs object.";
}
];
};
}