How can i make a nix flake source recuse through submodules

I have a flake which includes a package which has submodules

its a buildRustPackage but it doesn’t seem to grab submodules. here is my flake

# flake.nix
{
  inputs = {
    fenix = {
      url = "github:nix-community/fenix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "nixpkgs/nixpkgs-unstable";
    naersk.url = "github:nmattia/naersk";

  };

  outputs = { self, fenix, flake-utils, nixpkgs, naersk,}:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system} // { inherit (fenix.packages.${system}.latest) cargo rustc rust-src; };
        inherit (pkgs) lib stdenv;

        package = with pkgs; (makeRustPlatform { inherit (pkgs) rustc cargo; }).buildRustPackage rec {
          pname = "wezterm";
          nativeBuildInputs = pkgs.wezterm.nativeBuildInputs;
          buildInputs = pkgs.wezterm.buildInputs;
          cargoSha256 = "sha256-dVf0044Q+6dMw9BitxXAt0JLO6A0A68wmhagLvHMuzA";
          src = ./.;
          version = "HEAD";
          postInstall = ''
            mkdir -p $terminfo/share/terminfo/w $out/nix-support
            tic -x -o $terminfo/share/terminfo termwiz/data/wezterm.terminfo
            echo "$terminfo" >> $out/nix-support/propagated-user-env-packages
          '';

          outputs = [ "out" "terminfo" ];

          postPatch = ''
            echo ${version} > .tag
          '';

          preFixup = lib.optionalString stdenv.isLinux ''
            for artifact in wezterm wezterm-gui wezterm-mux-server strip-ansi-escapes; do
              patchelf --set-rpath "${lib.makeLibraryPath buildInputs}" $out/bin/$artifact
            done
          '' + lib.optionalString stdenv.isDarwin ''
            mkdir -p "$out/Applications"
            OUT_APP="$out/Applications/WezTerm.app"
            cp -r assets/macos/WezTerm.app "$OUT_APP"
            rm $OUT_APP/*.dylib
            cp -r assets/shell-integration/* "$OUT_APP"
            ln -s $out/bin/{wezterm,wezterm-mux-server,wezterm-gui,strip-ansi-escapes} "$OUT_APP"
          '';

          # prevent further changes to the RPATH
          dontPatchELF = true;
        };

        #        package = (pkgs.makeRustPlatform {
        #          inherit (fenix.packages.${system}.latest) cargo rustc rust-src;
        #        }).buildRustPackage rec { };

      in
      rec {
        devShell = pkgs.mkShell {
          inherit (defaultPackage) nativeBuildInputs;
          buildInputs = with pkgs; [ rust-analyzer rustfmt ] ++ defaultPackage.buildInputs;
          RUST_SRC_PATH = "${pkgs.rust-src}/lib/rustlib/src/rust/library";


        };
        defaultPackage = package;
      });
}

This still needs to be implemented: libfetchers/git: fetch submodules by default by nrdxp · Pull Request #4922 · NixOS/nix · GitHub

It is implemented, just needs a merge, but the ability to turn it off also needs to be implemented apparently, before that will happen. Although personally, I’d rather be stuck with the default on, then the default off, but I have some time today, so maybe I can take a crack at finishing this off :upside_down_face:

1 Like

Since this is one of the top search results:

Nowadays (2.6.0), you can use nix build '.?submodules=1'

4 Likes