-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathlib.nix
27 lines (23 loc) · 974 Bytes
/
lib.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
{ lib } :
{
# Create a stdenv with CPU optimizations
makeOptStdenv = stdenv: arch: extraCflags: if arch == null then stdenv else
stdenv.override {
name = stdenv.name + "-${arch}";
# Make sure respective CPU features are set
hostPlatform = stdenv.hostPlatform //
lib.mapAttrs (p: a: a arch) lib.systems.architectures.predicates;
# Add additional compiler flags
extraAttrs = {
mkDerivation = args: (stdenv.mkDerivation args).overrideAttrs (old: {
env.NIX_CFLAGS_COMPILE = toString (old.env.NIX_CFLAGS_COMPILE or "")
+ " -march=${arch} -mtune=${arch} " + extraCflags;
});
};
};
# generic packages-by-name function:
# Collect all packages from "dir/*/packages.nix" and apply callPackage {}
pkgs-by-name = callPackage: dir:
lib.mapAttrs (pkg: _: callPackage (dir + "/${pkg}/package.nix") {})
(lib.filterAttrs (_: type: type == "directory") (builtins.readDir dir));
}