From e2807ec934126514d7bb3bce9f5d6b923cc076fb Mon Sep 17 00:00:00 2001 From: sterni Date: Sun, 29 May 2022 11:06:14 +0200 Subject: fix(ops/nixos): use builtins.storePath to avoid dumping pkgs.path This is a less invasive way to achieve the same goal as cl/5681, by preventing the already existing nixpkgs store path from being dumped again at the call site. To support nixpkgsBisectPath, we simply check if pkgs.path is below builtins.storeDir and use builtins.storePath based on that. This is actually similar to the approach taken in the nixpkgs documentation system which tries to limit the amount of nixpkgs that needs to be dumped by using filterSource on specific subtrees of nixpkgs. For this to work it has to insist on pkgs.path being an ordinary Nix path, though. Change-Id: Idf892f90a5d811184568e4702a901c334d56210e Reviewed-on: https://cl.tvl.fyi/c/depot/+/5787 Autosubmit: sterni Reviewed-by: tazjin Tested-by: BuildkiteCI --- ops/nixos.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ops/nixos.nix b/ops/nixos.nix index 720e792333..309f122977 100644 --- a/ops/nixos.nix +++ b/ops/nixos.nix @@ -7,10 +7,18 @@ in rec { baseModule = { ... }: { # Ensure that pkgs == third_party.nix nixpkgs.pkgs = depot.third_party.nixpkgs; - nix.nixPath = [ - ("nixos=" + pkgs.path) - ("nixpkgs=" + pkgs.path) - ]; + nix.nixPath = + let + # Due to nixpkgsBisectPath, pkgs.path is not always in the nix store + nixpkgsStorePath = + if lib.hasPrefix builtins.storeDir (toString pkgs.path) + then builtins.storePath pkgs.path # nixpkgs is already in the store + else pkgs.path; # we need to dump nixpkgs to the store either way + in + [ + ("nixos=" + nixpkgsStorePath) + ("nixpkgs=" + nixpkgsStorePath) + ]; }; nixosFor = configuration: (depot.third_party.nixos { -- cgit 1.4.1