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 (builtins) attrNames listToAttrs map replaceStrings readDir;
|
||||
|
||||
checkArgs = {
|
||||
inherit self;
|
||||
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
};
|
||||
|
||||
flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" ];
|
||||
flakeDirectories = [ "overlays" "modules" "home" "packages" ];
|
||||
packageDirectory = "packages";
|
||||
flakeOutputs = [ "overlays" "nixosModules" "homeManagerModules" "packages" "checks" ];
|
||||
flakeDirectories = [ "overlays" "modules" "home" "packages" "tests" ];
|
||||
in
|
||||
{
|
||||
formatter.x86_64-linux = nixpkgs-fmt;
|
||||
@ -47,11 +40,6 @@
|
||||
modules = [ ./. ];
|
||||
};
|
||||
};
|
||||
|
||||
checks.x86_64-linux = {
|
||||
hyprland = import ./tests/hyprland.nix checkArgs;
|
||||
neovim = import ./tests/neovim.nix checkArgs;
|
||||
};
|
||||
} //
|
||||
(listToAttrs
|
||||
(map
|
||||
@ -66,14 +54,20 @@
|
||||
(file: {
|
||||
name = replaceStrings [ ".nix" ] [ "" ] file;
|
||||
value =
|
||||
if directory == packageDirectory
|
||||
if directory == "packages"
|
||||
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}))));
|
||||
|
||||
attributeSet =
|
||||
if directory == packageDirectory
|
||||
if directory == "packages" || directory == "tests"
|
||||
then { x86_64-linux = attributeValue; }
|
||||
else attributeValue;
|
||||
in
|
||||
|
@ -2,7 +2,7 @@
|
||||
let
|
||||
inherit (builtins) attrValues;
|
||||
in
|
||||
(import ./lib.nix) {
|
||||
(import ../lib.nix) {
|
||||
name = "hyprland";
|
||||
|
||||
nodes.machine = { nix-config, ... }: {
|
||||
|
@ -2,7 +2,7 @@
|
||||
let
|
||||
inherit (builtins) attrValues;
|
||||
in
|
||||
(import ./lib.nix) {
|
||||
(import ../lib.nix) {
|
||||
name = "neovim";
|
||||
|
||||
nodes.machine = { nix-config, ... }: {
|
||||
|
Loading…
Reference in New Issue
Block a user