nix-config/tests/lib.nix
Donovan Glover 59f557a3e5
feat: Pass nix-config as self to avoid infinite recursion
This change makes it possible to use this nix-config in all the
different ways imaginable (containers, bare metal, tests, and as a
separate flake input) *without* running into infinite recursion
issues with self.

It does this by using a trick similar to JavaScript in which
`var self = this;`, thus enabling the usage of "this" (or self, in
Nix's case) where it wouldn't otherwise be possible.

Note that this *only* works if the input for this repository is named
nix-config. This makes it impractical to combine with multiple
configurations that employ the same strategy.
2024-04-05 10:20:06 -04:00

15 lines
307 B
Nix

test: { pkgs, self }:
let
inherit (pkgs) lib;
nixos-lib = import (pkgs.path + "/nixos/lib") { };
in
(nixos-lib.runTest {
hostPkgs = pkgs;
defaults.documentation.enable = lib.mkDefault false;
node.specialArgs = {
inherit self;
nix-config = self;
};
imports = [ test ];
}).config.result