-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
75 lines (68 loc) · 2.42 KB
/
flake.nix
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
63
64
65
66
67
68
69
70
71
72
73
74
75
{
description = "Versatile tools for advanced networking scenarios in NixOS.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
with flake-utils.lib;
with nixpkgs.lib;
with builtins;
let
defaultSystem = "x86_64-linux";
# Adapted from nixos-cn/flakes
mergeSets = foldl (a: b: (a // b)) { };
listFiles = dir: map (n: dir + "/${n}") (attrNames (readDir dir));
listNixFilesRecursive = dir:
flatten (mapAttrsToList (name: type:
let path = dir + "/${name}";
in if type == "directory" then
if pathExists (dir + "/${name}/default.nix") then
path
else
listNixFilesRecursive path
else if hasSuffix ".nix" name then
path
else
[ ]) (readDir dir));
filterBySystem = system: pkgs:
filterAttrsRecursive (_: p:
# If there is a platform indication
!(isDerivation p) || (if hasAttrByPath [ "meta" "platforms" ] p then
elem system p.meta.platforms
else
system == defaultSystem)) pkgs;
getPackages = f: dir:
listToAttrs (map (name: {
inherit name;
value = f (dir + "/${name}");
}) (attrNames (readDir dir)));
# Make regular package sets (direct callPackage)
makePackageSet = f: dirs: mergeSets (map (dir: (getPackages f dir)) dirs);
aggregatePkgSets = f: dir:
mergeSets (map (name: f (dir + "/${name}")) (attrNames (readDir dir)));
pkgSet = nixpkgs:
(makePackageSet (n: nixpkgs.callPackage n { }) [
./pkgs/data
./pkgs/tools
])
// (aggregatePkgSets (n: import n { inherit nixpkgs; }) ./pkgs/drivers);
in (eachDefaultSystem (system:
let
pkgs = (import nixpkgs {
inherit system;
config.allowUnfree = true;
});
in rec {
packages = filterBySystem system (pkgSet pkgs);
checks = packages;
})) // {
publicKey =
"lexuge.cachix.org-1:RRFg8AxcexeBd33smnmcayMLU6r2wbVKbZHWtg2dKnY=";
overlay = final: prev: { netkit = recurseIntoAttrs (pkgSet prev); };
nixosModule = { ... }: {
nixpkgs.overlays = [ self.overlay ];
imports = listNixFilesRecursive ./modules;
};
};
}