How to access source files when building an application from a nix flake?

I’ve been attempting to port my rust application into a nix flake and I’ve gotten it to successfully compile following this template. However, when I attempt to install files from the source directory it says that the file could not be found. The same command works in nixpkgs and the nur. What could be causing this?

{ inputs, ... }: {
  imports = [
    inputs.rust-flake.flakeModules.default
    inputs.rust-flake.flakeModules.nixpkgs
    inputs.process-compose-flake.flakeModule
    inputs.cargo-doc-live.flakeModule
  ];
  perSystem = { config, self', pkgs, lib, ... }: {
    rust-project.crates."waytrogen".crane.args = {
      nativeBuildInputs = with pkgs; [
        pkg-config
        glib
        wrapGAppsHook4
        sqlite
        bash
      ];

      buildInputs = with pkgs; [
        glib
        gtk4
        ffmpeg
        sqlite
        openssl
        gsettings-desktop-schemas
      ];
      env = { OPENSSL_NO_VENDOR = 1; };

      postBuild = ''
    install -Dm644 org.Waytrogen.Waytrogen.gschema.xml -t $out/share/gsettings-schemas/$name/glib-2.0/schemas
    glib-compile-schemas $out/share/gsettings-schemas/$name/glib-2.0/schemas
      '';
    };
    packages.default = self'.packages.waytrogen;
  };
}

Sorry for being not on-topic according the rust-flake which you attempt to use. I don’t see where your source is referenced, but this is maybe because it don’t know this flake. Most of these projects exist to solve certain problems; I don’t know which problem it attempts to solve, but I personally would stick at first to use what nixpkgs documents and this is Nixpkgs Reference Manual. A more advanced setup is using naersk and fenix, which at least for me works great. Feel free to ask.

I wouldn’t recommend fenix, it produces broken RPATHs. I stick to rustPlatform from nixpkgs as linked above. And if you’re asking for help with an error, share the error, don’t paraphrase.

OK, it would be nice if you share your experience with fenix. I use it for years without of trouble. Looking forward to hearing from you :slight_smile:

Noted I’ll tinker around with a simpler template that the NixOS maintainers provide.

I thought that building and devShells were provided by crane but guess it’s a feature of nixpkgs. Good to know. I’ll tinker around with a simpler flake template tomorrow. Thank you for the reply.