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

devshell causing project to build? Breaks on compile failure #182

Open
damccull opened this issue Jul 19, 2024 · 0 comments
Open

devshell causing project to build? Breaks on compile failure #182

damccull opened this issue Jul 19, 2024 · 0 comments

Comments

@damccull
Copy link

damccull commented Jul 19, 2024

I'm not sure where else to ask and I can't get past this issue. I want open a nix develop devshell without building the project, but I want the project to build with nix run and nix build.

I'm using this flake.nix I based off of https://log.woodweb.ca/articles/rust-flake/:

{
  inputs = {
    nixpkgs = {
      url = "github:nixos/nixpkgs/nixos-unstable";
    };
    flake-parts.url = "github:hercules-ci/flake-parts";
    rust-overlay.url = "github:oxalica/rust-overlay";
  };
  outputs = inputs:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      systems = [ "x86_64-linux" ];
      perSystem = { config, self', pkgs, lib, system, ... }:
        let
          runtimeDeps = with pkgs; [
          ];
          buildDeps = with pkgs; [
            clang
            lld
            lldb
            pkg-config
            rustPlatform.bindgenHook
          ];
          devDeps = with pkgs; [
            cargo-msrv
            cargo-nextest
            clang
            gdb
            lld
            lldb
            surrealdb
          ];
          panamaxDeps = with pkgs; [
            panamax
          ];

          cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
          msrv = cargoToml.package.rust-version;

          rustPackage = features:
            (pkgs.makeRustPlatform {
              cargo = pkgs.rust-bin.stable.latest.minimal;
              rustc = pkgs.rust-bin.stable.latest.minimal;
            }).buildRustPackage {
              inherit (cargoToml.package) name version;
              src = ./.;
              cargoLock.lockFile = ./Cargo.lock;
              buildFeatures = features;
              buildInputs = runtimeDeps;
              nativeBuildInputs = buildDeps;
              # Uncomment if your cargo tests require networking or otherwise
              # don't play nicely with the nix build sandbox:
              # doCheck = false;
            };

          mkDevShell = rustc:
            pkgs.mkShell {
              shellHook = ''
                export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
              '';
              LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
              buildInputs = runtimeDeps;
              nativeBuildInputs = buildDeps ++ devDeps ++ [ rustc ];
            };

        in
        {
          _module.args.pkgs = import inputs.nixpkgs
            {
              inherit system;
              overlays = [ (import inputs.rust-overlay) ];
              config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
                "surrealdb"
              ];
            };

          packages.default = self'.packages.base;
          devShells.default = self'.devShells.stable;

          packages.base = (rustPackage "");
          packages.bunyan = (rustPackage "bunyan");
          packages.tokio-console = (rustPackage "tokio-console");

          devShells.nightly = (mkDevShell (pkgs.rust-bin.selectLatestNightlyWith
            (toolchain: toolchain.default.override {
              extensions = [ "rust-analyzer" ];
            })));
          devShells.stable = (mkDevShell
            (pkgs.rust-bin.stable.latest.default.override {
              extensions = [ "rust-analyzer" ];
            }));
          devShells.msrv = (mkDevShell (pkgs.rust-bin.stable.${msrv}.default.override {
            extensions = [ "rust-analyzer" ];
          }));
        };
    };
}

I can't figure out where else to look, as far as I can tell I'm not including my own package inside the devshell... is something in the overlay triggering the build on nix develop? If so, is there a way to stop it?

If not...any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant