Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
description = "devshell";

outputs = { self }:
outputs = { self, nixpkgs }:
Comment thread
hugosenari marked this conversation as resolved.
Outdated
let
eachSystem = f:
let
Expand Down Expand Up @@ -32,13 +32,20 @@
legacyPackages = devshell;
devShell = devshell.fromTOML ./devshell.toml;
};
flakeTOML = inputs: path: eachSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}.extend self.overlay;
in {
devShell = pkgs.devshell.fromTOML path;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flakeTOML = inputs: path: eachSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}.extend self.overlay;
in {
devShell = pkgs.devshell.fromTOML path;
flakeTOML = nixpkgs: path: eachSystem (system:
let devshell = import ./. { pkgs = nixpkgs.legacyPackages.${system}; }
in {
devShell = devshell.fromTOML path;

Like this, no new instance of nixpkgs is being created. Each instance adds quite a big overhead to nix evaluation. Composition over inheritance :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the idea but it didn't work :(

When run `nix develop it says...

error: package "devshell.cli" not found

Changed PR to draft until we solve this

Should I revert?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted ☹

}
);
in
{
defaultTemplate.path = ./template;
defaultTemplate.description = "nix flake new 'github:numtide/devshell'";
# Import this overlay into your instance of nixpkgs
overlay = import ./overlay.nix;
lib = {
inherit flakeTOML;
importTOML = import ./nix/importTOML.nix;
};
}
Expand Down
16 changes: 2 additions & 14 deletions template/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,7 @@
description = "virtual environments";

inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, flake-utils, devshell, nixpkgs }:
flake-utils.lib.eachDefaultSystem (system: {
devShell =
let pkgs = import nixpkgs {
inherit system;

overlays = [ devshell.overlay ];
};
in
pkgs.devshell.mkShell {
imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
};
});
outputs = { devshell, nixpkgs, ... }@inputs:
devshell.lib.flakeTOML inputs ./devshell.toml;
Comment thread
hugosenari marked this conversation as resolved.
Outdated
}