Trouble with making a flake for a meson project

Hey there. I’ve been trying to make a flake for one of my projects, but for some reason when i try running it with nix run i get a file not found error that looks something like this:

[nix-shell:~/grosh]$ nix run
error: unable to execute '/nix/store/26851x0yb8wq6fjw5llbh7ic02m9785x-grosh/bin/grosh': No such file or directory

This is how my project is laid out:

├── flake.lock
├── flake.nix
├── meson.build
└── src
    ├── meson.build
    └── shell.c

and this is my attempt at a flake.nix

{
  description = "A flake for building the grosh shell";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system}; in
      {
        packages = rec {
          Grosh = pkgs.stdenv.mkDerivation rec {
            name = "grosh";
            version = "0.0.1";
            src = ./.;
            propagatedBuildInputs = with pkgs; [
              meson
              ninja
              pkg-config
            ];
          };
          default = Grosh;
        };

        apps = rec {
          shell_app = flake-utils.lib.mkApp {
            drv = self.packages.${system}.Grosh;
            name = "grosh";
          };
          default = shell_app;
        };
      }
    );
}

mkApp expects the drv contains /bin/${name} file and the result will expose the path:

Make sure the executable function in your meson.build has install kwarg set to true and that the name matches.

Also, the stuff you listed in propagatedBuildInputs should go to nativeBuildInputs since those are build tools and need to run on build platform and there should be no need to propagate them.

1 Like

Thanks! I just had to set install to true in my meson.build