2024-10-17 18:55:05 +01:00
|
|
|
{
|
2025-01-15 17:24:23 +00:00
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
linkFarmFromDrvs,
|
|
|
|
self,
|
|
|
|
stdenv,
|
2025-01-16 01:47:16 +00:00
|
|
|
runCommandLocal,
|
2025-01-15 17:24:23 +00:00
|
|
|
}:
|
|
|
|
let
|
|
|
|
|
|
|
|
defaultPkgs = pkgs;
|
|
|
|
|
2025-01-16 02:53:27 +00:00
|
|
|
# Only imports the bare minimum modules, to ensure we are not accidentally evaluating `pkgs.*`
|
2025-01-15 21:49:27 +00:00
|
|
|
evalModule =
|
2025-01-15 17:24:23 +00:00
|
|
|
name: module:
|
2025-01-16 02:53:27 +00:00
|
|
|
lib.evalModules {
|
2025-01-15 21:49:27 +00:00
|
|
|
modules = lib.toList module ++ [
|
|
|
|
{
|
2025-01-16 02:53:27 +00:00
|
|
|
_module.check = false;
|
|
|
|
flake = self;
|
2025-01-15 21:49:27 +00:00
|
|
|
test = {
|
|
|
|
inherit name;
|
|
|
|
buildNixvim = false;
|
|
|
|
runNvim = false;
|
|
|
|
runCommand = runCommandLocal;
|
|
|
|
};
|
|
|
|
}
|
2025-01-16 02:53:27 +00:00
|
|
|
../modules/misc
|
|
|
|
../modules/top-level/test.nix
|
|
|
|
../modules/top-level/nixpkgs.nix
|
2025-01-15 21:49:27 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
testModule = name: module: (evalModule name module).config.build.test;
|
2025-01-15 17:24:23 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
linkFarmFromDrvs "nixpkgs-module-test" [
|
|
|
|
|
2024-10-17 18:55:05 +01:00
|
|
|
# TODO: expect not setting `nixpkgs.pkgs` to throw
|
|
|
|
|
2025-01-15 17:24:23 +00:00
|
|
|
(testModule "nixpkgs-overlays" (
|
2024-10-17 18:55:05 +01:00
|
|
|
{ pkgs, ... }:
|
|
|
|
{
|
2025-01-15 17:24:23 +00:00
|
|
|
nixpkgs.pkgs = defaultPkgs;
|
2024-10-17 18:55:05 +01:00
|
|
|
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
foobar = "foobar";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = pkgs.foobar or null == "foobar";
|
|
|
|
message = ''
|
|
|
|
Expected `pkgs.foobar` to be "foobar"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
2025-01-15 17:24:23 +00:00
|
|
|
}
|
|
|
|
))
|
2024-10-17 18:55:05 +01:00
|
|
|
|
|
|
|
# Test that overlays from both `nixpkgs.pkgs` _and_ `nixpkgs.overlays` are applied
|
2025-01-15 17:24:23 +00:00
|
|
|
(testModule "nixpkgs-stacked-overlay" (
|
|
|
|
{ pkgs, ... }:
|
2024-10-17 18:55:05 +01:00
|
|
|
{
|
2025-01-15 17:24:23 +00:00
|
|
|
nixpkgs.pkgs = import self.inputs.nixpkgs {
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
2024-10-17 18:55:05 +01:00
|
|
|
overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
foobar = "foobar";
|
|
|
|
conflict = "a";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
nixpkgs.overlays = [
|
|
|
|
(final: prev: {
|
|
|
|
hello = "world";
|
|
|
|
conflict = "b";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
assertions = [
|
|
|
|
{
|
|
|
|
assertion = pkgs.foobar or null == "foobar";
|
|
|
|
message = ''
|
|
|
|
Expected `pkgs.foobar` to be "foobar"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = pkgs.hello or null == "world";
|
|
|
|
message = ''
|
|
|
|
Expected `pkgs.hello` to be "world"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
{
|
|
|
|
assertion = pkgs.conflict or null == "b";
|
|
|
|
message = ''
|
|
|
|
Expected `pkgs.conflict` to be "b"
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
2025-01-15 17:24:23 +00:00
|
|
|
}
|
|
|
|
))
|
|
|
|
|
|
|
|
]
|