about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorVladimír Čunát <v@cunat.cz>2019-03-10 08:05:27 +0100
committerVladimír Čunát <v@cunat.cz>2019-03-10 08:05:27 +0100
commit8d502fd425ed61a53e87bbae4accc251a4bd9c4a (patch)
tree35b7527abdd21dc14e048a0ed2e58bf9c59c2758 /pkgs/build-support
parent8a08d7e7cc4a54cc3947f4cf5aa8fe2ae665513a (diff)
parentbf47162c26641af76083b0d26ceb477be6a620ff (diff)
downloadnixlib-8d502fd425ed61a53e87bbae4accc251a4bd9c4a.tar
nixlib-8d502fd425ed61a53e87bbae4accc251a4bd9c4a.tar.gz
nixlib-8d502fd425ed61a53e87bbae4accc251a4bd9c4a.tar.bz2
nixlib-8d502fd425ed61a53e87bbae4accc251a4bd9c4a.tar.lz
nixlib-8d502fd425ed61a53e87bbae4accc251a4bd9c4a.tar.xz
nixlib-8d502fd425ed61a53e87bbae4accc251a4bd9c4a.tar.zst
nixlib-8d502fd425ed61a53e87bbae4accc251a4bd9c4a.zip
Merge branch 'staging-next' into staging
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/docker/default.nix1
-rw-r--r--pkgs/build-support/docker/examples.nix6
-rw-r--r--pkgs/build-support/emacs/wrapper.nix12
-rw-r--r--pkgs/build-support/references-by-popularity/closure-graph.py53
-rw-r--r--pkgs/build-support/rust/build-rust-crate/configure-crate.nix2
5 files changed, 63 insertions, 11 deletions
diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix
index 011ff3685093..8d47f1570138 100644
--- a/pkgs/build-support/docker/default.nix
+++ b/pkgs/build-support/docker/default.nix
@@ -77,6 +77,7 @@ rec {
 
     cp ${./tarsum.go} tarsum.go
     export GOPATH=$(pwd)
+    export GOCACHE="$TMPDIR/go-cache"
     mkdir -p src/github.com/docker/docker/pkg
     ln -sT ${docker.src}/components/engine/pkg/tarsum src/github.com/docker/docker/pkg/tarsum
     go build
diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix
index d78e35c56625..8a1b35f02d99 100644
--- a/pkgs/build-support/docker/examples.nix
+++ b/pkgs/build-support/docker/examples.nix
@@ -87,9 +87,9 @@ rec {
   # 4. example of pulling an image. could be used as a base for other images
   nixFromDockerHub = pullImage {
     imageName = "nixos/nix";
-    imageDigest = "sha256:20d9485b25ecfd89204e843a962c1bd70e9cc6858d65d7f5fadc340246e2116b";
-    sha256 = "0mqjy3zq2v6rrhizgb9nvhczl87lcfphq9601wcprdika2jz7qh8";
-    finalImageTag = "1.11";
+    imageDigest = "sha256:85299d86263a3059cf19f419f9d286cc9f06d3c13146a8ebbb21b3437f598357";
+    sha256 = "0vnp3mhpk4ny3xa3cgngqsargnmvfgld54d5sn4b5av6yqzzp67z";
+    finalImageTag = "2.2.1";
   };
 
   # 5. example of multiple contents, emacs and vi happily coexisting
diff --git a/pkgs/build-support/emacs/wrapper.nix b/pkgs/build-support/emacs/wrapper.nix
index e161daffbd37..dfdd5b60851d 100644
--- a/pkgs/build-support/emacs/wrapper.nix
+++ b/pkgs/build-support/emacs/wrapper.nix
@@ -121,21 +121,25 @@ stdenv.mkDerivation {
 
      siteStart="$out/share/emacs/site-lisp/site-start.el"
      siteStartByteCompiled="$siteStart"c
+     subdirs="$out/share/emacs/site-lisp/subdirs.el"
+     subdirsByteCompiled="$subdirs"c
 
-     # A dependency may have brought the original siteStart, delete it and
-     # create our own
+     # A dependency may have brought the original siteStart or subdirs, delete
+     # it and create our own
      # Begin the new site-start.el by loading the original, which sets some
      # NixOS-specific paths. Paths are searched in the reverse of the order
      # they are specified in, so user and system profile paths are searched last.
-     rm -f $siteStart $siteStartByteCompiled
+     rm -f $siteStart $siteStartByteCompiled $subdirs $subdirsByteCompiled
      cat >"$siteStart" <<EOF
 (load-file "$emacs/share/emacs/site-lisp/site-start.el")
 (add-to-list 'load-path "$out/share/emacs/site-lisp")
 (add-to-list 'exec-path "$out/bin")
 EOF
+      # Link subdirs.el from the emacs distribution
+      ln -s $emacs/share/emacs/site-lisp/subdirs.el -T $subdirs
 
      # Byte-compiling improves start-up time only slightly, but costs nothing.
-     $emacs/bin/emacs --batch -f batch-byte-compile "$siteStart"
+     $emacs/bin/emacs --batch -f batch-byte-compile "$siteStart" "$subdirs"
   '';
 
   phases = [ "installPhase" ];
diff --git a/pkgs/build-support/references-by-popularity/closure-graph.py b/pkgs/build-support/references-by-popularity/closure-graph.py
index d67a5dfcf140..579f3b041fa8 100644
--- a/pkgs/build-support/references-by-popularity/closure-graph.py
+++ b/pkgs/build-support/references-by-popularity/closure-graph.py
@@ -117,6 +117,17 @@ import unittest
 from pprint import pprint
 from collections import defaultdict
 
+
+def debug(msg, *args, **kwargs):
+    if False:
+        print(
+            "DEBUG: {}".format(
+                msg.format(*args, **kwargs)
+            ),
+            file=sys.stderr
+        )
+
+
 # Find paths in the original dataset which are never referenced by
 # any other paths
 def find_roots(closures):
@@ -327,10 +338,23 @@ class TestMakeLookup(unittest.TestCase):
 #                   /nix/store/tux: {}
 #   }
 # }
+subgraphs_cache = {}
 def make_graph_segment_from_root(root, lookup):
+    global subgraphs_cache
     children = {}
     for ref in lookup[root]:
-        children[ref] = make_graph_segment_from_root(ref, lookup)
+        # make_graph_segment_from_root is a pure function, and will
+        # always return the same result based on a given input. Thus,
+        # cache computation.
+        #
+        # Python's assignment will use a pointer, preventing memory
+        # bloat for large graphs.
+        if ref not in subgraphs_cache:
+            debug("Subgraph Cache miss on {}".format(ref))
+            subgraphs_cache[ref] = make_graph_segment_from_root(ref, lookup)
+        else:
+            debug("Subgraph Cache hit on {}".format(ref))
+        children[ref] = subgraphs_cache[ref]
     return children
 
 class TestMakeGraphSegmentFromRoot(unittest.TestCase):
@@ -381,12 +405,27 @@ class TestMakeGraphSegmentFromRoot(unittest.TestCase):
 #   /nix/store/baz: 4
 #   /nix/store/tux: 6
 # ]
+popularity_cache = {}
 def graph_popularity_contest(full_graph):
+    global popularity_cache
     popularity = defaultdict(int)
     for path, subgraph in full_graph.items():
         popularity[path] += 1
-        subcontest = graph_popularity_contest(subgraph)
+        # graph_popularity_contest is a pure function, and will
+        # always return the same result based on a given input. Thus,
+        # cache computation.
+        #
+        # Python's assignment will use a pointer, preventing memory
+        # bloat for large graphs.
+        if path not in popularity_cache:
+            debug("Popularity Cache miss on {}", path)
+            popularity_cache[path] = graph_popularity_contest(subgraph)
+        else:
+            debug("Popularity Cache hit on {}", path)
+
+        subcontest = popularity_cache[path]
         for subpath, subpopularity in subcontest.items():
+            debug("Calculating popularity for {}", subpath)
             popularity[subpath] += subpopularity + 1
 
     return popularity
@@ -474,6 +513,7 @@ def main():
     filename = sys.argv[1]
     key = sys.argv[2]
 
+    debug("Loading from {}", filename)
     with open(filename) as f:
         data = json.load(f)
 
@@ -497,14 +537,21 @@ def main():
     # ]
     graph = data[key]
 
+    debug("Finding roots from {}", key)
     roots = find_roots(graph);
+    debug("Making lookup for {}", key)
     lookup = make_lookup(graph)
 
     full_graph = {}
     for root in roots:
+        debug("Making full graph for {}", root)
         full_graph[root] = make_graph_segment_from_root(root, lookup)
 
-    ordered = order_by_popularity(graph_popularity_contest(full_graph))
+    debug("Running contest")
+    contest = graph_popularity_contest(full_graph)
+    debug("Ordering by popularity")
+    ordered = order_by_popularity(contest)
+    debug("Checking for missing paths")
     missing = []
     for path in all_paths(graph):
         if path not in ordered:
diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
index 9f499e4f5e72..b184d363d554 100644
--- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
+++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix
@@ -81,7 +81,7 @@ in ''
   export CARGO_CFG_TARGET_POINTER_WIDTH=${toString stdenv.hostPlatform.parsed.cpu.bits}
   export CARGO_CFG_TARGET_VENDOR=${stdenv.hostPlatform.parsed.vendor.name}
 
-  export CARGO_MANIFEST_DIR="."
+  export CARGO_MANIFEST_DIR=$(pwd)
   export DEBUG="${toString (!release)}"
   export OPT_LEVEL="${toString optLevel}"
   export TARGET="${stdenv.hostPlatform.config}"