blob: 1732554aefb38e6e8f37de730f0e030688af9ec3 (
plain)
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
|
{ pkgs, ... }:
# https://stackoverflow.com/questions/42136197/how-to-override-compile-flags-for-a-single-package-in-nixos
# https://nixos.wiki/wiki/Snippets
let
overrideWithFlag = pkg: flag:
pkg.overrideAttrs (attrs: {
NIX_CFLAGS_COMPILE = (attrs.NIX_CFLAGS_COMPILE or "") + "${flag}";
});
overrideWithFlags = pkg: flags: pkgs.lib.foldl' (pkg: flag: overrideWithFlag pkg flag) pkg flags;
in
{
overrideWithFlags = overrideWithFlags;
optimizeForThisHost = pkg:
overrideWithFlags pkg [ "-O3" "-march=native" "-fPIC" ];
withDebugSymbols = pkg:
overrideWithFlags pkg [ "-DDEBUG" ];
importDirs = path: with builtins;
map (n: import (path + ("/" + n)))
(filter (n: match ".*\\.nix" n != null ||
pathExists (path + ("/" + n + "/default.nix")))
(attrNames (readDir path)));
}
|