feat: use numtide/devshell to improve devshell experience#1973
feat: use numtide/devshell to improve devshell experience#1973phanirithvij merged 1 commit intongi-nix:mainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
2b3824f to
a2e1937
Compare
5d9f35e to
1714fd3
Compare
|
TODO
We need to decide on
|
36c0f41 to
57f62dd
Compare
3ba6af4 to
f0e15fd
Compare
|
We can review some prs in the office hours today if you are up to it. |
|
Key points from reviewing this in the office hours:
review.patch
diff --git a/maintainers/shells/default.nix b/maintainers/shells/default.nix
index 03d6eeb4..8dfe3dbb 100644
--- a/maintainers/shells/default.nix
+++ b/maintainers/shells/default.nix
@@ -1,17 +1,18 @@
{
lib,
pkgs,
- devshell,
- nixdoc-to-github,
+ sources,
+
+ callPackage,
# toplevel attributes
- ngipkgs,
formatter,
...
}:
let
- devshellArgs = lib.makeExtensible (final: {
+ devshell = import sources.devshell { nixpkgs = pkgs; };
+ shellEnv = lib.makeExtensible (final: {
generalCategory = "[general commands]";
mkAliases =
@@ -35,13 +36,6 @@ let
(value.help or value.cmd);
}) aliases;
- mapCommands =
- category: packages:
- builtins.map (p: {
- inherit category;
- package = p;
- }) packages;
-
# from numtide/devshell, copyright Numtide, MIT licensed
# Returns a list of all the input derivation ... for a derivation.
inputsOf =
@@ -68,6 +62,13 @@ let
$(type -p menu &>/dev/null && menu)
'';
+ mapCommands =
+ category: packages:
+ builtins.map (p: {
+ inherit category;
+ package = p;
+ }) packages;
+
commands =
(final.mapCommands "formatter" final.formatters)
++ final.defaultCmds
@@ -81,13 +82,12 @@ let
packagesFrom = [ ]; # inputsFrom equivalent, are hidden in the menu
- # End devshell.mkShell args
-
- _devshell = devshell.mkShell (
+ finalPackage = devshell.mkShell (
lib.filterAttrs (
name: value:
# filter only the valid args for devshell.mkShell
builtins.elem name [
+ "shellHook"
"name"
"motd"
"commands"
@@ -97,25 +97,6 @@ let
) final
);
- finalPackage =
- if (final.shellHook != "") then
- # allow shellHook overriding by embedding into another shell
- # FIXME(phanirithvij): possible to fix this in numtide/devshell, a shellHook argument to mkShell
- pkgs.mkShellNoCC {
- inherit (final) name;
- shellHook = ''
- source ${final._devshell.hook}/nix-support/setup-hook
- ${final.shellHook}
- '';
- packages = [ final._devshell ];
- }
- else
- # use the minimal numtide shell if shellHook override is not required
- final._devshell;
-
- # default empty shellHook, implies no override
- shellHook = "";
-
# Include all formatter packages. Format with:
# $ treefmt
# $ nix fmt
@@ -140,9 +121,15 @@ let
lib.fileset.fileFilter (file: file.hasExt "nix") ./commands
)
);
- callPackage' = lib.callPackageWith (pkgs // { inherit nixdoc-to-github ngipkgs; });
in
- final.mapCommands "commands" (builtins.map (path: callPackage' path { }) files);
+ final.mapCommands "commands" (map (path: callPackage path { }) files);
});
+
+ shell.finalPackage = pkgs.mkShell {
+ packages = [ shellEnv.finalPackage ];
+ shellHook = ''
+ menu
+ '';
+ };
in
-devshellArgs
+shell |
3bf8e4c to
9dd16cc
Compare
6027099 to
44add75
Compare
There is
This can be documented, cannot be fixed by us.
made the flake shell the same as the shells/default.nix, not extending it anymore with the pre-commit checks hooks and packages.
I wasn't able to reproduce this in two other machines. I think it is something we can investigate and fix. But even with this setup |
35577dc to
84dc63a
Compare
4453bb0 to
fc20dc0
Compare
Just for clarity, @phanirithvij and I were able to debug this yesterday and it turned out it was caused by my |
fc20dc0 to
e648357
Compare
e648357 to
7f3e60e
Compare
|
I'll try to refactor this to use the module system later, but I think it is good enough, we can extend the shell too. |
adb260f to
b1bcc9e
Compare
00a82a6 to
93dcdbc
Compare
eljamm
left a comment
There was a problem hiding this comment.
Looks good to me and is working as intended.
moved commands into a ./commands subdirectory with categories as parent directories Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
2927d19 to
6d9ebe7
Compare
Uh oh!
There was an error while loading. Please reload this page.