From 05b788f7b9beaa9014c9d794acf004e23ad571af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 15 Jan 2023 12:26:41 +0100 Subject: [PATCH] template: drop use of overlay This makes the template a lot shorter. Overlays are not only harder to read and understand (especially if multiple of them have to be combined), they also have a real performance impact as each flake would introduce its own instance of nixpkgks, which can further multiply if these flakes are than import into multiple NixOS configurations: https://zimbatm.com/notes/1000-instances-of-nixpkgs If the goal of overlays was here to make importing easier, I would rather recommend looking into https://flake.parts --- flake.nix | 1 + templates/app/flake.nix | 35 ++++++++++------------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/flake.nix b/flake.nix index 70cd0ff..333a111 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,7 @@ default = poetry2nix.cli; }; + legacyPackages = poetry2nix; apps = { poetry = flake-utils.lib.mkApp { drv = packages.poetry; }; diff --git a/templates/app/flake.nix b/templates/app/flake.nix index 08ce734..82ee94d 100644 --- a/templates/app/flake.nix +++ b/templates/app/flake.nix @@ -9,35 +9,20 @@ }; outputs = { self, nixpkgs, flake-utils, poetry2nix }: - { - # Nixpkgs overlay providing the application - overlay = nixpkgs.lib.composeManyExtensions [ - poetry2nix.overlay - (final: prev: { - # The application - myapp = prev.poetry2nix.mkPoetryApplication { - projectDir = ./.; - }; - }) - ]; - } // (flake-utils.lib.eachDefaultSystem (system: + flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [ self.overlay ]; - }; + # see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples. + inherit (poetry2nix.legacyPackages.${system}) mkPoetryApplication; + pkgs = nixpkgs.legacyPackages.${system}; in { - apps = { - myapp = pkgs.myapp; + packages = { + myapp = mkPoetryApplication { projectDir = self; }; + default = self.packages.${system}.myapp; }; - defaultApp = pkgs.myapp; - - devShell = pkgs.mkShell { - buildInputs = with pkgs; [ - (python310.withPackages (ps: with ps; [ poetry ])) - ]; + devShells.default = pkgs.mkShell { + packages = [ poetry2nix.packages.${system}.poetry ]; }; - })); + }); }