mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
modules/nixpkgs: construct an instance of nixpkgs.source
This commit is contained in:
parent
8dc8fa38b0
commit
912841c1a7
3 changed files with 81 additions and 37 deletions
15
tests/nixpkgs-mock.nix
Normal file
15
tests/nixpkgs-mock.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
# This mock nixpkgs can be used as `nixpkgs.source` in nixpkgs-module-test
|
||||
# if we want/need to avoid importing & instantiating a real nixpkgs
|
||||
{
|
||||
config ? { },
|
||||
...
|
||||
}:
|
||||
let
|
||||
pkgs = {
|
||||
_type = "pkgs";
|
||||
__splicedPackages = pkgs;
|
||||
inherit config pkgs;
|
||||
mock = true;
|
||||
};
|
||||
in
|
||||
pkgs
|
|
@ -36,7 +36,51 @@ let
|
|||
in
|
||||
linkFarmFromDrvs "nixpkgs-module-test" [
|
||||
|
||||
# TODO: expect not setting `nixpkgs.pkgs` to throw
|
||||
# Test that pkgs-config is affected by `nixpkgs.config`
|
||||
(testModule "nixpkgs-config" (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
nixpkgs.config = {
|
||||
permittedInsecurePackages = [
|
||||
"foobar123"
|
||||
];
|
||||
};
|
||||
|
||||
nixpkgs.hostPlatform = {
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
};
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = pkgs.config.permittedInsecurePackages == [ "foobar123" ];
|
||||
message = ''
|
||||
Expected `pkgs.config.permittedInsecurePackages` to match [ "foobar123" ], but found:
|
||||
${lib.generators.toPretty { } pkgs.config.permittedInsecurePackages}'';
|
||||
}
|
||||
];
|
||||
}
|
||||
))
|
||||
|
||||
# Test that a nixpkgs revision can be specified using `nixpkgs.source`
|
||||
(testModule "nixpkgs-source" (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
nixpkgs.source = ./nixpkgs-mock.nix;
|
||||
|
||||
nixpkgs.hostPlatform = {
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
};
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = pkgs.mock or false;
|
||||
message = "Expected `pkgs.mock` to be true, but ${
|
||||
if pkgs ? mock then "found " + lib.generators.toPretty { } pkgs.mock else "isn't present"
|
||||
}";
|
||||
}
|
||||
];
|
||||
}
|
||||
))
|
||||
|
||||
(testModule "nixpkgs-overlays" (
|
||||
{ pkgs, ... }:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue