diff --git a/tests/default.nix b/tests/default.nix index a0dbe575..2b4a7861 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,8 +1,16 @@ -{ pkgs ? import { } }: +let + flakeUtils = import ../lib/flake.nix; + flake = flakeUtils.importFlakeMetadata ../flake.lock; +in +{ pkgs ? import (flakeUtils.fetchTree flake "nixos-unstable") { } }: +let + utils = import ./utils.nix { inherit pkgs; }; +in { - lib = import ./lib { inherit pkgs; }; + lib = import ./lib { inherit pkgs utils; }; modules = { - home-manager = import ./modules/home-manager { inherit pkgs; }; + home-manager = import ./modules/home-manager { inherit pkgs utils; }; + nixos = import ./modules/nixos { inherit pkgs utils; }; }; } diff --git a/tests/lib/default.nix b/tests/lib/default.nix index 89a7e7f5..25c138a7 100644 --- a/tests/lib/default.nix +++ b/tests/lib/default.nix @@ -1,6 +1,6 @@ # For the environment-specific subset, we'll be simulating the configurations # as a simple attribute set since that's what they are anyways. -{ pkgs ? import { } }: +{ pkgs ? import { }, utils ? import ../utils.nix { inherit pkgs; } }: let inherit (pkgs) lib; diff --git a/tests/utils.nix b/tests/utils.nix new file mode 100644 index 00000000..81601164 --- /dev/null +++ b/tests/utils.nix @@ -0,0 +1,20 @@ +# A set of functions to facilitate testing in the project. +{ pkgs }: + +let + nixpkgsPath = pkgs.path; + nixosLib = import "${nixpkgsPath}/nixos/lib" { }; +in +rec { + # We're not using this to test the hosts configuration (that would be + # atrocious). We're only using this for NixOS modules. + nixosTest = test: + nixosLib.runTest { + imports = [ test ]; + hostPkgs = pkgs; + specialArgs = { + foodogsquaredUtils = import ../lib/utils/nixos.nix { inherit pkgs; }; + foodogsquaredModulesPath = builtins.toString ../modules/nixos; + }; + }; +}