-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathflake.nix
More file actions
62 lines (59 loc) · 2.04 KB
/
flake.nix
File metadata and controls
62 lines (59 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs }:
let
forAllSystems = f: nixpkgs.lib.genAttrs nixpkgs.lib.platforms.all (system: f system);
in
{
lib = import ./lib { lib = nixpkgs.lib; };
wrapperModules = import ./modules.nix {
lib = nixpkgs.lib;
wlib = self.lib;
};
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-tree);
checks = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Load checks from checks/ directory
checkFiles = builtins.readDir ./checks;
importCheck = name: {
name = nixpkgs.lib.removeSuffix ".nix" name;
value = import (./checks + "/${name}") {
inherit pkgs;
self = self;
};
};
checksFromDir = builtins.listToAttrs (
map importCheck (
builtins.filter (name: nixpkgs.lib.hasSuffix ".nix" name) (builtins.attrNames checkFiles)
)
);
# Load checks from modules/**/check.nix
moduleFiles = builtins.readDir ./modules;
importModuleCheck =
name: type:
let
checkPath = ./modules + "/${name}/check.nix";
# Check if current system is in the module's supported platforms
isSupported = builtins.elem system self.wrapperModules.${name}.meta.platforms;
in
if type == "directory" && builtins.pathExists checkPath && isSupported then
{
name = "module-${name}";
value = import checkPath {
inherit pkgs;
self = self;
};
}
else
null;
checksFromModules = builtins.listToAttrs (
nixpkgs.lib.filter (x: x != null) (nixpkgs.lib.mapAttrsToList importModuleCheck moduleFiles)
);
in
checksFromDir // checksFromModules
);
};
}