How can you create a Flutter app using Nix(pkgs)?

I was previously directed to take a look at how FluffyChat is built in nixpkgs, but that doesn’t seem to work:

There is flutter.mkFlutterApp, but I tried it with an empty project created with flutter create and I got an error not only on nix build, but also on nix develop.

I wrote this Nixpkgs package as default.nix:

{ lib, flutter }:
flutter.mkFlutterApp {
  version = "0.0.0";
  pname = "test-flutter-app";
  src = ./.;
  meta = { };
}

…and this as flake.nix:

{
  outputs = { nixpkgs, self, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system: {
      packages.default = nixpkgs.legacyPackages.${system}.callPackage ./. { };
    });
}

But I still get this error:

Oops; flutter has exited unexpectedly: "ProcessException: Failed to find "cmake" in the search path.

How can this be? FluffyChat uses CMake too, but doesn’t specify it as a build input.

3 Likes

Maybe the original author of “FluffyChat”, or someone otherwise knowledgeable enough, could add a wiki entry on how to build Flutter apps (for Linux).

I would very much appreciate this as well, because currently there only seem to be tips on how to write a shell.nix file for running Flutter apps on Linux in debug mode, although I assume many would like to package their apps after debugging them.

1 Like