diff --git a/flake.nix b/flake.nix index 27e3a63e..37bc7590 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,11 @@ inherit (nixpkgs.lib) nixosSystem; inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage; + checkArgs = { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + inherit self; + }; + flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" ]; flakeDirectories = [ "overlays" "modules" "home" "packages" ]; packageDirectory = "packages"; @@ -55,6 +60,11 @@ ]; }; }; + + checks.x86_64-linux = { + hyprland = import ./tests/hyprland.nix checkArgs; + neovim = import ./tests/neovim.nix checkArgs; + }; } // (builtins.listToAttrs (builtins.map diff --git a/tests/hyprland.nix b/tests/hyprland.nix new file mode 100644 index 00000000..64f0795f --- /dev/null +++ b/tests/hyprland.nix @@ -0,0 +1,15 @@ +# TODO: Write test to ensure that Hyprland starts with basic config +(import ./lib.nix) { + name = "hyprland"; + + nodes.machine = { self, pkgs, ... }: { + imports = with self.nixosModules; [ + hyprland + ]; + }; + + testScript = /* python */ '' + output = machine.succeed("echo 'Hello world'") + assert "Hello world" in output + ''; +} diff --git a/tests/lib.nix b/tests/lib.nix new file mode 100644 index 00000000..93748faa --- /dev/null +++ b/tests/lib.nix @@ -0,0 +1,13 @@ +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; + }; + imports = [ test ]; +}).config.result diff --git a/tests/neovim.nix b/tests/neovim.nix new file mode 100644 index 00000000..ed0d0aa4 --- /dev/null +++ b/tests/neovim.nix @@ -0,0 +1,15 @@ +# TODO: Ensure that neovim config works without errors on startup +(import ./lib.nix) { + name = "neovim"; + + nodes.machine = { self, pkgs, ... }: { + imports = with self.nixosModules; [ + neovim + ]; + }; + + testScript = /* python */ '' + output = machine.succeed("echo 'Hello world'") + assert "Hello world" in output + ''; +}