`mkShellArgs.packages` does not work
An application I'm writing uses an SQLite database, so I wanted to include the sqlite3 executable in the nix develop shell. I passed sqlite-interactive through mkShellArgs and the package is added to the nix store, but the PATH variable is not updated. My flake.nix looks like
{
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.haskell-flake.flakeModule ];
perSystem = { self', pkgs, ... }: {
haskellProjects.default = {
packages = { };
devShell = {
tools = hp: { };
mkShellArgs = {
packages = [ pkgs.sqlite-interactive ];
};
};
};
packages.default = self'.packages.imgr;
};
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
}
I currently use a shellHook as a work-around:
shellHook = "export PATH=$PATH:${pkgs.sqlite-interactive}/bin"
Internally mkShellArgs.* is used in Haskell's shellFor.
https://github.com/srid/haskell-flake/blob/39065472d2587af93a502423276bfb98c2c6fb09/nix/modules/project/devshell.nix#L114-L115
This is why packages is not coming through.
This is yet another reason for us to deprecate mkShellArgs entirely.
The recommended way to configure the devShell is through composition. See https://community.flake.parts/haskell-flake/devshell#composing-devshells
Ah, I didn't realise you are supposed to use mkShell yourself and import the shell generated by haskell-flake. The flake below works now. Does it look alright? I had to use mkForce to override the generated shell.
{
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [ inputs.haskell-flake.flakeModule ];
perSystem = { config, pkgs, ... }: {
haskellProjects.default = {
packages = { };
devShell = {
tools = hp: { };
};
};
devShells.default = pkgs.lib.mkForce (pkgs.mkShell {
inputsFrom = [ config.haskellProjects.default.outputs.devShell ];
shellHook = "exec zsh";
packages = [ pkgs.sqlite-interactive ];
});
packages.default = config.packages.imgr;
};
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
haskell-flake.url = "github:srid/haskell-flake";
};
}
Set autoWire = [ "packages" "apps" ]; - then you don't need mkForce (which is generally not a good idea to use).