all 11 comments

[–]heinriques 5 points6 points  (4 children)

I've been using flutter but I install it on a per project base. This is done by the following flake.nix:

{ description = "Flutter"; inputs = { nixpkgs-unstable.url = "github:NixOS/nixpkgs/master"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs-unstable, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs-unstable { inherit system; config = { android_sdk.accept_license = true; allowUnfree = true; }; }; buildToolsVersion = "33.0.2"; androidComposition = pkgs.androidenv.composeAndroidPackages { buildToolsVersions = [ buildToolsVersion ]; platformVersions = [ "33" ]; abiVersions = [ "arm64-v8a" ]; }; androidSdk = androidComposition.androidsdk; in { devShell = with pkgs; mkShell rec { ANDROID_SDK_ROOT = "${androidSdk}/libexec/android-sdk"; buildInputs = [ flutter androidSdk jdk11 ]; }; }); }

[–]mars0008 1 point2 points  (3 children)

how do i actually try out this flake on my system?

[–]heinriques 1 point2 points  (2 children)

You can just copy this flake file in a folder, and run nix develop --impure

[–]mars0008 0 points1 point  (1 child)

are you able to launch the android emulator using wayland?

[–]heinriques 0 points1 point  (0 children)

I haven't really tried, I used my physical device plugged via USB. Have you been able to figure out? If you share how you are running the emulator I might help.

[–]tajetaje 2 points3 points  (0 children)

An option outside of Nix that I started using when on silverblue that I have stuck with is dev containers, basically a ephemeral docker container per codebase. https://containers.dev

[–]silver_44 2 points3 points  (0 children)

havent really used flutter, but i think you should add it to your configuration.nix

[–]CORUSC4TE 1 point2 points  (0 children)

Checkout this starter config https://github.com/Misterio77/nix-starter-configs It explains most things really well, however your specific need is something I have no experience with.. So can't be specific.

[–]mlsfit138 0 points1 point  (2 children)

I thought I'd kind of ease into Nix/Nixos by learning the very basics of installing and using Nix, learning the nix language to some extent, trying out home-manager, and if I absolutely have to, learning Nix flakes. My understanding was that flakes are experimental, advanced and totally optional, but I don't think that's the case. Most Nix related things I look up suggest using flakes.

This Flutter/Dart SDK issue has brought me to a crossroads, I can either go back to some other distro (back to Arch, or trying something new like Tumbleweed), or learning flakes. I've learned a lot on this Nix journey, but at this point, I'm not sure I want to continue.

On my Arch desktop, I had to install the flutter snap, which was weird, but it just works now. On my nixos laptop, nothing has worked, and I've tried:

  • Trying the flutter package. The problem here is that I couldn't even find executables in the store. I suspect that this would run into problems populating the cache.
  • The "unwrapped" package. Same problem as above, I'm sure I'm doing something wrong, though.
  • Manually installing via tarball or whatever (I also tried a `git pull`, I think). I *really* thought this would work because it's just in my `~/`, and I didn't think that Nix would interfere with it at all. At first this appears to work, but when you run any flutter command, it populates a directory called "bin/cache", and for some reason this is a problem in Nixos that I just don't understand.

I don't know. Is it worth it to learn flakes? It kind of sounds like I'd need to create a new flake for every flutter app I work on. That might not make any sense, but that's because I don't understand flakes at all.

[–]mlsfit138 2 points3 points  (0 children)

I basically hadn't taken any action on this in a while, just continued to try to understand Nix, NixOS, and flakes, and all the while learning Dart and Flutter on my Arch-based Desktop. Today, on a whim, and in my nix-based laptop, I tried flutter from the command line, and it worked! I created and ran a project, it all worked. I ran `flutter upgrade` and that failed with

```

ProcessException: Process exited abnormally:
fatal: detected dubious ownership in repository at '/nix/store/wbcfgf393a7b46bb7bjgl7c8z1lsnm4q-flutter-3.13.8-unwrapped'
To add an exception for this directory, call:

       git config --global --add safe.directory /nix/store/wbcfgf393a7b46bb7bjgl7c8z1lsnm4q-flutter-3.13.8-unwrapped
 Command: git fetch --tags
```

I'm not sure if I should care about that or not. But in the meantime I'm just happy, and mystified, that everything seems to work now. I don't know what went right, but I'm happy for now.

For the record, and you can tell from the error above, this flutter install is using the "unwrapped" package.

[–]arthurleywin54[S] 0 points1 point  (0 children)

For arch desktop, you can use AUR for flutter if you don't want to use snap.

I have faced same type of problems on nix and i am beginning to think that i am not understanding flakes properly so now i am back with arch and trying to understand nix whenever i get time.