babariviere / flutter-nix-hello-world

Demonstration on how to use flutter with Nix
52 stars 10 forks source link

Basic commands to get started? #11

Closed 123batman closed 7 months ago

123batman commented 1 year ago

Can you please add the basic commands to get this running to the README as "Getting started"? :pray:

It would be super nice to just clone the repo, run a command and have the app running in an emulator or at least have it build something without having to dig through Nix or flutter documentation.

Nix makes it very confusing with nix, nix-env, nix-shell, nix develop, nix shell etc. etc. So it would be nice to know what commands you use to get flutter-nix-hello-world running. I am getting all sorts of errors no matter which commands I try.

E.g: error: flake 'git+file:///home/...redacted.../flutter/flutter-nix-hello-world' does not provide attribute 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'

Something like this would be incredibly helpful:

Install Nix with:

curl https://nixos.org/nix/install | sh

make sure nix is at least at version: nix (Nix) 2.9.1

nix --version

do I have to add a dífferent channel / go to the unstable channel? etc

do I have to enable flakes or anything else?

and then just the basic commands such as:

nix shell --extra-experimental-features nix-command --extra-experimental-features flakes ? flutter doctor ? flutter build apk ? flutter run ? and then the location where I can find the output?

This way I would know if it works as expected. But I have no idea how to even start using it and trouble shooting is super difficult without knowing whether I am even trying the correct commands or not in the first place. If I run into errors after following the commands you use, I am more than happy to do my homework and jump into the corresponding documentation :)

deftdawg commented 1 year ago

I'm trying to figure out how to make this work on nixOS, I think I can get it to download some deps into /nix/store when I run the following command, but they don't unpack...

nix --extra-experimental-features flakes --extra-experimental-features nix-command develop

i.e.

-r--r--r-- 1 root root 1.1G Dec 31  1969 /nix/store/nm69lmgcw5mh0fvk3gbnyw5634znb80x-android-ndk-r22-linux-x86_64.zip

Did you ever figure out the steps to make this go?

babariviere commented 1 year ago

Hello, you can indeed use nix develop or nix-shell to get all the tools to use flutter.

Then you can simply run commands like flutter build apk or flutter run, and it should work like you would expect it to be.

It would be super nice to just clone the repo, run a command and have the app running in an emulator or at least have it build something without having to dig through Nix or flutter documentation.

If you have nix flake:

nix develop
flutter run

If not:

nix-shell .
flutter run

Nix makes it very confusing with nix, nix-env, nix-shell, nix develop, nix shell etc. etc. So it would be nice to know what commands you use to get flutter-nix-hello-world running. I am getting all sorts of errors no matter which commands I try.

E.g: error: flake 'git+file:///home/...redacted.../flutter/flutter-nix-hello-world' does not provide attribute 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'

Hmmm, I don't know how you can get this error since these attributes are shown with nix flake show. But to answer your question, and to make it simple, use nix-shell if you don't have flake enabled otherwise nix develop.

Something like this would be incredibly helpful:

Install Nix with: curl https://nixos.org/nix/install | sh

make sure nix is at least at version: nix (Nix) 2.9.1 nix --version

do I have to add a dífferent channel / go to the unstable channel? etc #do I have to enable flakes or anything else?

and then just the basic commands such as: nix shell --extra-experimental-features nix-command --extra-experimental-features flakes ? flutter doctor ? flutter build apk ? flutter run ? and then the location where I can find the output?

This way I would know if it works as expected. But I have no idea how to even start using it and trouble shooting is super difficult without knowing whether I am even trying the correct commands or not in the first place. If I run into errors after following the commands you use, I am more than happy to do my homework and jump into the corresponding documentation :)

You are not wrong but I only wanted to make it a template for users with Nix already installed. I don't want to provide a full tutorial but I can at least provide a small getting started, probably without command for installing nix, since there is multiple way to do it (installing NixOS or just Nix or using the determiate system installer).