devshell
devshell copied to clipboard
Error when configuring devshell in nix
Describe the bug
Getting an error on the commands attr when trying to configure the devshell via nix
nix develop --show-trace
warning: Git tree '/home/jonathanl/Code/bank-wallet-backend-rs' is dirty
error: cannot coerce a set to a string
at /nix/store/4ri9hysy5z82hj602whjrswrwfxsig4n-source/flake.nix:118:11:
117| ];
118| commands = with commands;
| ^
119| [
… while evaluating the attribute 'commands' of the derivation 'nix-shell'
at /nix/store/m5jxlii8jz3mrr8fsbhb1zq310zvd10l-source/pkgs/stdenv/generic/make-derivation.nix:270:7:
269| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
270| name =
| ^
271| let
My devshell configuration:
devShells.default = pkgs.mkShell {
devshell.name = "holdings-rs-shell";
devshell.startup.pre-commit = self.checks.${system}.pre-commit-check.shellHook;
devshell.packages = with pkgs; [
# Rust build inputs
pkg-config
openssl
# LSP's
rust-analyzer
rnix-lsp
# Tools
rust-toolchain
bacon
alejandra
nix-linter
# Cargo plugins
cargo-audit
cargo-udeps
cargo-bloat
cargo-expand
# CLI tools
sqlx-cli
bunyan-rs
# Faster linkers
(
if (lib.strings.hasInfix "darwin" system)
then zld
else if (lib.strings.hasInfix "aarch64" system)
then lld
else mold
)
];
commands = with commands;
[
{
help = "Format rust and nix files";
name = "format";
package = format;
category = "hygene";
}
{
help = "Generate typescript types for the frontend";
name = "gen-types";
package = gen-types;
category = "code-generation";
}
{
help = "Generate sql query indices for sqlx offline mode";
name = "gen-sql";
package = gen-sql;
category = "code-generation";
}
{
help = "Run tests with specific logging configuration";
name = "test-logs";
package = test-logs;
category = "testing";
}
{
help = "Run clippy with specific warning flags enabled";
name = "clippy-full";
package = clippy-full;
category = "hygene";
}
];
};
Expected behavior
I would expect to be able to configure commands the same way as specified in the module example
System information
λ cat flake.lock | jq .nodes.devshell
{
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1663445644,
"narHash": "sha256-+xVlcK60x7VY1vRJbNUEAHi17ZuoQxAIH4S4iUFUGBA=",
"owner": "numtide",
"repo": "devshell",
"rev": "e3dc3e21594fe07bdb24bdf1c8657acaa4cb8f66",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
}
Resolved this, I was using pkgs.mkShell instead of pkgs.devshell.mkShell. Perhaps we should document how to configure the devshell via nix in flakes.