aboutsummaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix')
-rw-r--r--nix/overlays.nix14
-rw-r--r--nix/sources.nix16
-rw-r--r--nix/utils.nix29
3 files changed, 59 insertions, 0 deletions
diff --git a/nix/overlays.nix b/nix/overlays.nix
new file mode 100644
index 00000000..12e0e86d
--- /dev/null
+++ b/nix/overlays.nix
@@ -0,0 +1,14 @@
+{ config, ... }:
+{
+ overlays =
+ let
+ paths = [
+ ./overlays
+ ];
+ in with builtins;
+ concatMap (path:
+ (map (n: import (path + ("/" + n)))
+ (filter (n: match ".*\\.nix" n != null ||
+ pathExists (path + ("/" + n + "/default.nix")))
+ (attrNames (readDir path))))) paths;
+}
diff --git a/nix/sources.nix b/nix/sources.nix
new file mode 100644
index 00000000..3e90ca06
--- /dev/null
+++ b/nix/sources.nix
@@ -0,0 +1,16 @@
+{
+ nixpkgs = {
+ unstable = builtins.fetchGit {
+ url = "https://github.com/NixOS/nixpkgs.git";
+ rev = "cf7475d2061ac3ada4b226571a4a1bb91420b578";
+ };
+ stable = builtins.fetchGit {
+ url = "https://github.com/NixOS/nixpkgs.git";
+ rev = "c11f75bd73e8264bbca6f4bc969ccc39cd371196";
+ };
+ };
+ home-manager = builtins.fetchGit {
+ url = "https://github.com/nix-community/home-manager.git";
+ rev = "275d1b52126674764f0f3d15c73c2add511bd310";
+ };
+}
diff --git a/nix/utils.nix b/nix/utils.nix
new file mode 100644
index 00000000..9848a785
--- /dev/null
+++ b/nix/utils.nix
@@ -0,0 +1,29 @@
+{ pkgs, ... }:
+# https://stackoverflow.com/questions/42136197/how-to-override-compile-flags-for-a-single-package-in-nixos
+let
+ overrideWithFlags = pkg: flags:
+ pkgs.lib.overrideDerivation pkg (old:
+ let
+ newflags = pkgs.lib.foldl' (acc: x: "${acc} ${x}") "" flags;
+ oldflags = if (pkgs.lib.hasAttr "NIX_CFLAGS_COMPILE" old)
+ then "${old.NIX_CFLAGS_COMPILE}"
+ else "";
+ in
+ {
+ NIX_CFLAGS_COMPILE = "${oldflags} ${newflags}";
+ });
+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)));
+}