Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when configuring devshell in nix #222

Open
JonathanLorimer opened this issue Sep 20, 2022 · 1 comment
Open

Error when configuring devshell in nix #222

JonathanLorimer opened this issue Sep 20, 2022 · 1 comment
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@JonathanLorimer
Copy link

JonathanLorimer commented Sep 20, 2022

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"
  }
}
@JonathanLorimer JonathanLorimer added the bug Something isn't working label Sep 20, 2022
@JonathanLorimer
Copy link
Author

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.

@zimbatm zimbatm added the documentation Improvements or additions to documentation label Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants