From 6f8b4d9ebe00e7b62ce5bff1fb3a9573d976b721 Mon Sep 17 00:00:00 2001 From: Erik Arvstedt Date: Thu, 3 Feb 2022 20:46:25 +0100 Subject: [PATCH] flake: optimize nixpkgs importing `nixpkgs.legacyPackages.${system}` allows reusing a single pkgs instance that is shared among all flakes with the same `nixpkgs` input. This is relevant when a user overrides the `nixpkgs` input of our flake or exports our `nixpkgs` input to other flakes. `import nixpkgs` would create a new pkgs instance instead. --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 273216c..d27d621 100644 --- a/flake.nix +++ b/flake.nix @@ -18,8 +18,8 @@ lib = { mkNbPkgs = { system - , pkgs ? import nixpkgs { inherit system; } - , pkgsUnstable ? import nixpkgsUnstable { inherit system; } + , pkgs ? nixpkgs.legacyPackages.${system} + , pkgsUnstable ? nixpkgsUnstable.legacyPackages.${system} }: import ./pkgs { inherit pkgs pkgsUnstable; }; }; @@ -65,7 +65,7 @@ } // (flake-utils.lib.eachSystem supportedSystems (system: let - pkgs = import nixpkgs { inherit system; }; + pkgs = nixpkgs.legacyPackages.${system}; nbPkgs = self.lib.mkNbPkgs { inherit system pkgs; };