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

Symlinks are not resolved after a submodule is cloned #230

Closed
sekunho opened this issue Apr 1, 2022 · 8 comments · Fixed by #234
Closed

Symlinks are not resolved after a submodule is cloned #230

sekunho opened this issue Apr 1, 2022 · 8 comments · Fixed by #234

Comments

@sekunho
Copy link

sekunho commented Apr 1, 2022

Heyah. Thanks for the awesome work!

I have a cargo dependency that contains a submodule, and it doesn't seem like it gets cloned properly by (I think).

Dep's submodule: https://github.com/lambda-fairy/maud/blob/main/maud_macros/src/escape.rs
nix version: 2.5.1
flake.nix:

{
  description = "";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
    naersk.url = "github:nix-community/naersk";
  };

  outputs = { self, nixpkgs, nixos-unstable, flake-utils, naersk }:
    flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
      let pkgs = nixpkgs.legacyPackages.${system};
           naersk-lib = naersk.lib."${system}".override {
             cargo = pkgs.cargo;
             rustc = pkgs.rustc;
           };
      in
      rec {
        packages.foo = naersk-lib.buildPackage {
          pname = "foo";
          root = ./.;
        };

        defaultPackage = packages.foo;

        apps.foo = flake-utils.lib.mkApp {
          drv = packages.foo;
        };

        defaultApp = apps.foo;

        devShell = pkgs.mkShell {
          nativeBuildInputs = with pkgs; [
            pkgs.rustc
            pkgs.cargo
          ];
        };
      });
}

nix build log:

Compiling maud_macros v0.23.0 (https://github.com/lambda-fairy/maud?branch=main#e6787cd6)
error: could not compile `maud_macros` due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed
error[E0583]: file not found for module `escape`
 --> /sources/maud_macros-0.23.0-e6787cd62165a075c7f16a32f8bbacc398f52d13/src/lib.rs:9:1
  |
9 | mod escape;
  | ^^^^^^^^^^^
  |
  = help: to create the module `escape`, create file "/nix/store/shixfmbv64zzi9i0rzb9c8870ydm7cf2-crates-io/maud_macr>


error[E0425]: cannot find function `escape_to_string` in module `escape`
   --> /sources/maud_macros-0.23.0-e6787cd62165a075c7f16a32f8bbacc398f52d13/src/generate.rs:272:17
    |
272 |         escape::escape_to_string(string, &mut self.tail);
    |                 ^^^^^^^^^^^^^^^^ not found in `escape`


error: aborting due to 2 previous errors


Some errors have detailed explanations: E0425, E0583.

For more information about an error, try `rustc --explain E0425`.

[naersk] cargo returned with exit code 101, exiting

The strange part is that running cargo build directly builds it just fine. I tried looking around the issues, and it doesn't seem like any of the ones I found are exactly this problem. Any pointers are appreciated!

@Patryk27
Copy link
Contributor

Patryk27 commented Apr 1, 2022

Hi 🙂

Could you try using naersk from #167?

Something like that should work:

inputs = {
  # ...
  naersk.url = "github:nix-community/naersk?rev=bd4822e754eba04977667ab8a9e5314ae126cc1c";
};

... or:

inputs = {
  # ...
  naersk.url = "github:nix-community/naersk/bd4822e754eba04977667ab8a9e5314ae126cc1c";
};

@sekunho
Copy link
Author

sekunho commented Apr 1, 2022

Hmm.. it fails the same way.

Cargo.toml:

maud = { git = "https://github.com/lambda-fairy/maud.git", branch = "main", features = ["axum"] }

Pretty much at the latest commit for that dependency.

inputs = {
  # ...
  naersk.url = "github:nix-community/naersk?rev=bd4822e754eba04977667ab8a9e5314ae126cc1c";
};

# Output
packages.foo = naersk-lib.buildPackage {
  pname = "foo";
  root = ./.;
  gitSubmodules = true;
};

Am I using it right?

@Patryk27
Copy link
Contributor

Patryk27 commented Apr 1, 2022

Am I using it right?

Yeah, looks right; well, thanks for the report, then - I'll try investigating it 🙂

@Patryk27
Copy link
Contributor

Patryk27 commented Apr 1, 2022

Ah, the issue is that this file is a symlink, and we seem not to be resolving them (so after copying the dependency to /nix/store, the symlink remains pointing at ../../maud, which then is somewhere outside the /nix/store); should be fixable 🙂

@Patryk27 Patryk27 changed the title Cargo dependency containing a submodule fails to build Symlinks are not resolved after a submodule is cloned Apr 1, 2022
@sekunho
Copy link
Author

sekunho commented Apr 1, 2022

Ahhh okay, that makes sense. Thanks for taking the time to give this a look!

@sekunho
Copy link
Author

sekunho commented Apr 15, 2022

Ok, so it turns out submodules aren't relevant in this case. The problem is just that symlinks don't get resolved. Are there any pointers for how to start with this problem? I'd like to open a PR but I'm not too experienced with Nix.

@Patryk27
Copy link
Contributor

Hi 🙂

Unfortunately I didn't have time yet to investigate this issue more thoroughly, so I don't have any tips - I'll try taking a look some time next week and we'll see.

Btw, I loved your article on creating static binaries!

@sekunho
Copy link
Author

sekunho commented Apr 15, 2022

I see, I'll try to look into it to see if I can do anything.

Thank you 😄.

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