From be058ad58dd0e43c46138a073e94ca3c313401be Mon Sep 17 00:00:00 2001
From: Pacman99 <pachum99@gmail.com>
Date: Wed, 5 May 2021 13:09:28 -0700
Subject: [PATCH] shell: add packages from overlays to devshell following same
 logic as exporting packages, but don't filter out inputs

---
 flake.nix                  |  3 +++
 pkgs-lib/shell/default.nix | 16 +++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/flake.nix b/flake.nix
index 5fd79366b..40e54fd2c 100644
--- a/flake.nix
+++ b/flake.nix
@@ -70,6 +70,9 @@
             lib = nixpkgs.lib // lib;
           };
         };
+
+        devShell = lib.pkgs-lib.shell { inherit pkgs; };
+
         packages = {
           mkFlakeDoc = pkgs.writeText "mkFlakeOptions.md"
             (
diff --git a/pkgs-lib/shell/default.nix b/pkgs-lib/shell/default.nix
index ffd3fc40e..9ca39affe 100644
--- a/pkgs-lib/shell/default.nix
+++ b/pkgs-lib/shell/default.nix
@@ -17,10 +17,7 @@ let
     })
   ];
 
-  pkgs' = import pkgs.path {
-    inherit (pkgs) system;
-    inherit overlays;
-  };
+  pkgs' = pkgs.appendOverlays overlays;
 
   flk = pkgs'.callPackage ./flk.nix { };
 
@@ -28,6 +25,15 @@ let
     inherit (pkgs') system;
     modules = [ ];
   }).config.system.build;
+
+  # Add all packages from overlays to shell
+  # Follow same logic as exporting packages except don't filter out inputs
+  allOverlays = lib.exporter.overlaysFromChannelsExporter {
+    # function requires system-spaced and channel-spaced package set
+    pkgs.${pkgs'.system}.channel = pkgs';
+  };
+  customPackages = lib.builder.packagesFromOverlaysBuilderConstructor allOverlays { pkgs = pkgs'; };
+
 in
 pkgs'.devshell.mkShell {
   imports = [ (pkgs'.devshell.importTOML ./devshell.toml) ];
@@ -37,7 +43,7 @@ pkgs'.devshell.mkShell {
     nixos-generate-config
     nixos-enter
     pkgs'.nixos-rebuild
-  ];
+  ] ++ (builtins.attrValues customPackages);
 
   git.hooks = {
     pre-commit.text = lib.fileContents ./pre-commit.sh;