From 9be782798f5a853d28d3822716c8b74d518338c2 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 23 Nov 2024 10:29:58 +0100 Subject: tests(flake): Hook up to the flake's check and package attributes --- flake.nix | 4 +--- flake/default.nix | 36 +++++++++++++++++++++++++----------- flake/packages/default.nix | 3 +++ tests/README.md | 3 +++ 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index 399e0577..4e97cddf 100644 --- a/flake.nix +++ b/flake.nix @@ -307,13 +307,13 @@ self pkgs pkgsStable + nixLib myPkgs system sysLib nixpkgs_as_input nixpkgs_open_prs # modules - home-manager nixVim nixos-generators @@ -325,12 +325,10 @@ lanzaboote nix-index-database # external dependencies - treefmt-nix user_js templates # my binaries - shell_library river_init_lesser ; diff --git a/flake/default.nix b/flake/default.nix index f158478b..222b18ac 100644 --- a/flake/default.nix +++ b/flake/default.nix @@ -3,6 +3,7 @@ self, pkgs, pkgsStable, + nixLib, myPkgs, system, sysLib, @@ -38,12 +39,10 @@ nixpkgs_as_input nixpkgs_open_prs # my things - shell_library sysLib templates # modules - home-manager nixVim nixos-generators @@ -55,22 +54,37 @@ lanzaboote nix-index-database # bins - river_init_lesser # external - user_js ; }; + + tests = import ../tests { + inherit pkgs nixpkgs_as_input myPkgs; + inherit (pkgs) lib; + extraModules = { + termfilechooser = "${nixpkgs_open_prs.nixpkgs-tfc}/nixos/modules/config/xdg/portals/termfilechooser.nix"; + + agenix = agenix.nixosModules.default; + disko = disko.nixosModules.default; + serverphone = serverphone.nixosModules.default; + inherit (home-manager.nixosModules) home-manager; + inherit (impermanence.nixosModules) impermanence; + inherit (lanzaboote.nixosModules) lanzaboote; + }; + }; in { inherit nixosConfigurations; - checks."${system}" = { - inherit - (self.packages."${system}") - nvim - ; - formatting = treefmtEval.config.build.check self; - }; + checks."${system}" = + nixLib.maybeMerge { + inherit + (self.packages."${system}") + nvim + ; + formatting = treefmtEval.config.build.check self; + } + tests "flake checks"; # legacyPackages."${system}" = pkgs; diff --git a/flake/packages/default.nix b/flake/packages/default.nix index 5b07b6f3..a8fc2d64 100644 --- a/flake/packages/default.nix +++ b/flake/packages/default.nix @@ -13,6 +13,8 @@ inherit (pkgs) lib; output = import ../../bootstrap {inherit pkgs sysLib;}; + run_test_description = pkgs.callPackage ../../tests/infrastructure/run.nix {}; + nvim = builtins.mapAttrs ( name: value: let @@ -88,6 +90,7 @@ in # format = "iso"; # }; nvim = nvim.tiamat; + inherit run_test_description; } // output // output_neovim diff --git a/tests/README.md b/tests/README.md index fe93dc96..c7e1bb93 100644 --- a/tests/README.md +++ b/tests/README.md @@ -58,6 +58,9 @@ where `COMMAND` is one of the commands listed in [Commands](#### Commands) The `ARGS` are the verbatim content from the space after the `COMMAND` to the end of line character. +You can run the description file, similarly as in the tests via the `run_test_description` +package exported by the flake. + #### Commands ##### `Type` Send the `ARGS` to the application. This interprets `ARGS` as specified -- cgit 1.4.1