From 813f9da8ab69f106055dd4a8fead7bc0a21a251b Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 5 Jan 2022 13:54:34 +0100 Subject: [PATCH] pkgs.path: Avoid copying when used via flake --- flake.nix | 2 +- pkgs/top-level/all-packages.nix | 2 +- pkgs/top-level/config.nix | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 29dffa9fa4e4..c2306768d6fe 100644 --- a/flake.nix +++ b/flake.nix @@ -62,7 +62,7 @@ }).nixos.manual.x86_64-linux; }; - legacyPackages = forAllSystems (system: import ./. { inherit system; }); + legacyPackages = forAllSystems (system: import ./. { inherit system; config.path = self.outPath; }); nixosModules = { notDetected = import ./nixos/modules/installer/scan/not-detected.nix; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 12c16ea3a5d0..3896088f7662 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -67,7 +67,7 @@ with pkgs; clangStdenvNoLibs = mkStdenvNoLibs clangStdenv; # For convenience, allow callers to get the path to Nixpkgs. - path = ../..; + path = config.path; ### Helper functions. diff --git a/pkgs/top-level/config.nix b/pkgs/top-level/config.nix index 7a5b4bdd1798..bb4f668d60f1 100644 --- a/pkgs/top-level/config.nix +++ b/pkgs/top-level/config.nix @@ -32,6 +32,20 @@ let feature = "run checkPhase by default"; }; + path = mkOption { + type = types.path; + default = ../..; + defaultText = lib.literalDocBook "a path expression"; + internal = true; + description = '' + A reference to Nixpkgs' own sources. + + This is overridable in order to avoid copying sources unnecessarily, + as a path expression that references a store path will not short-circuit + to the store path itself, but copy the store path instead. + ''; + }; + }; in {