mirror of
https://github.com/donovanglover/nix-config.git
synced 2024-11-22 00:03:55 +01:00
flake.nix: Dynamically import tests
Makes it possible to add new test files to the tests directory and have everything instantly working.
This commit is contained in:
parent
cc0213be48
commit
30e0239cf7
28
flake.nix
28
flake.nix
@ -27,15 +27,8 @@
|
|||||||
inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage;
|
inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage;
|
||||||
inherit (builtins) attrNames listToAttrs map replaceStrings readDir;
|
inherit (builtins) attrNames listToAttrs map replaceStrings readDir;
|
||||||
|
|
||||||
checkArgs = {
|
flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" "checks" ];
|
||||||
inherit self;
|
flakeDirectories = [ "overlays" "modules" "home" "packages" "tests" ];
|
||||||
|
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
|
||||||
};
|
|
||||||
|
|
||||||
flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" ];
|
|
||||||
flakeDirectories = [ "overlays" "modules" "home" "packages" ];
|
|
||||||
packageDirectory = "packages";
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
formatter.x86_64-linux = nixpkgs-fmt;
|
formatter.x86_64-linux = nixpkgs-fmt;
|
||||||
@ -47,11 +40,6 @@
|
|||||||
modules = [ ./. ];
|
modules = [ ./. ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
checks.x86_64-linux = {
|
|
||||||
hyprland = import ./tests/hyprland.nix checkArgs;
|
|
||||||
neovim = import ./tests/neovim.nix checkArgs;
|
|
||||||
};
|
|
||||||
} //
|
} //
|
||||||
(listToAttrs
|
(listToAttrs
|
||||||
(map
|
(map
|
||||||
@ -66,14 +54,20 @@
|
|||||||
(file: {
|
(file: {
|
||||||
name = replaceStrings [ ".nix" ] [ "" ] file;
|
name = replaceStrings [ ".nix" ] [ "" ] file;
|
||||||
value =
|
value =
|
||||||
if directory == packageDirectory
|
if directory == "packages"
|
||||||
then callPackage ./${directory}/${file} { }
|
then callPackage ./${directory}/${file} { }
|
||||||
else import ./${directory}/${file};
|
else
|
||||||
|
if directory == "tests"
|
||||||
|
then import ./${directory}/${file} {
|
||||||
|
inherit self;
|
||||||
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
}
|
||||||
|
else import ./${directory}/${file};
|
||||||
})
|
})
|
||||||
(attrNames (readDir ./${directory}))));
|
(attrNames (readDir ./${directory}))));
|
||||||
|
|
||||||
attributeSet =
|
attributeSet =
|
||||||
if directory == packageDirectory
|
if directory == "packages" || directory == "tests"
|
||||||
then { x86_64-linux = attributeValue; }
|
then { x86_64-linux = attributeValue; }
|
||||||
else attributeValue;
|
else attributeValue;
|
||||||
in
|
in
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
let
|
let
|
||||||
inherit (builtins) attrValues;
|
inherit (builtins) attrValues;
|
||||||
in
|
in
|
||||||
(import ./lib.nix) {
|
(import ../lib.nix) {
|
||||||
name = "hyprland";
|
name = "hyprland";
|
||||||
|
|
||||||
nodes.machine = { nix-config, ... }: {
|
nodes.machine = { nix-config, ... }: {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
let
|
let
|
||||||
inherit (builtins) attrValues;
|
inherit (builtins) attrValues;
|
||||||
in
|
in
|
||||||
(import ./lib.nix) {
|
(import ../lib.nix) {
|
||||||
name = "neovim";
|
name = "neovim";
|
||||||
|
|
||||||
nodes.machine = { nix-config, ... }: {
|
nodes.machine = { nix-config, ... }: {
|
||||||
|
Loading…
Reference in New Issue
Block a user