From 9fc4cb2ae970f860bc309cbaf40957f53a36d423 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <eelco.dolstra@logicblox.com>
Date: Tue, 20 Sep 2016 15:10:51 +0200
Subject: [PATCH] nix-shell: Restore CPU affinity

Otherwise the shell and its children will be bound to one CPU core...
---
 src/nix-build/nix-build.cc | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index 248474d53..a31f7c96c 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -1,18 +1,20 @@
 #include <cstring>
+#include <fstream>
+#include <iostream>
 #include <regex>
-#include "util.hh"
-#include <unistd.h>
-#include "shared.hh"
 #include <sstream>
 #include <vector>
-#include <iostream>
-#include <fstream>
+
+#include <unistd.h>
+
 #include "store-api.hh"
 #include "globals.hh"
 #include "derivations.hh"
+#include "affinity.hh"
+#include "util.hh"
+#include "shared.hh"
 
 using namespace nix;
-using std::stringstream;
 
 extern char ** environ;
 
@@ -400,6 +402,8 @@ int main(int argc, char ** argv)
                 for (const auto & env : drv.env)
                     setenv(env.first.c_str(), env.second.c_str(), 1);
 
+                restoreAffinity();
+
                 // Run a shell using the derivation's environment.  For
                 // convenience, source $stdenv/setup to setup additional
                 // environment variables and shell functions.  Also don't lose
-- 
GitLab