From b8a32b60df0557bc0ba1dfd136e61c7ea1b2974a Mon Sep 17 00:00:00 2001 From: Philip Patsch Date: Fri, 31 Aug 2018 12:37:43 +0200 Subject: [PATCH] Create an out link to prevent garbage collection. It will create a garbage collection root as long as the symlink created by `--out-link` exists. --- nixpkgs/nixpkgs.bzl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nixpkgs/nixpkgs.bzl b/nixpkgs/nixpkgs.bzl index 8208e3f35..1814beede 100644 --- a/nixpkgs/nixpkgs.bzl +++ b/nixpkgs/nixpkgs.bzl @@ -57,7 +57,13 @@ def _nixpkgs_package_impl(ctx): "-A", ctx.attr.attribute_path if ctx.attr.nix_file or ctx.attr.nix_file_content else ctx.attr.attribute_path or ctx.attr.name, - "--no-out-link", + # Creating an out link prevents nix from garbage collecting the store path. + # nixpkgs uses `nix-support/` for such house-keeping files, so we mirror them + # and use `bazel-support/`, under the assumption that no nix package has + # a file named `bazel-support` in its root. + # A `bazel clean` deletes the symlink and thus nix is free to garbage collect + # the store path. + "--out-link", "bazel-support/nix-out-link" ]) # If neither repository or path are set, leave empty which will use