maximoffua / flutter.nix

A flake for flutter package out of nixpkgs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FlakeHub

Flutter SDK for Nix

This repository is made for fixing issues with flutter in nixpkgs, specifically #260278.

Getting started

This flake provides the following packages:

  • packages.${system}.flutter
  • packages.${system}.dart

and an overlay:

  • overlays.default

There is also binary cache hosted by Cachix:

https://mtech.cachix.org mtech.cachix.org-1:cPDMKB6bI2DjpXfsE8dOcYOdaas9afdRNhLA0MEfXuo=

With flakes

Add this flake as an input and either use:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flutter-nix.url = "github:maximoffua/flutter.nix/stable"; # remove `/stable` to use main branch
          # stable can be replaced with specific tag matching Flutter versions, e.g. 3.16.7
  };
 
  outputs = { self, flutter-nix }:
  let
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system;
      # add overlay from flutter-nix, which replaces dart and flutter packages
      overlays = [
        flutter-nix.overlays.default
      ];
    };
  in {
    # Use flutter-nix in your outputs or use `pkgs`,
    # which is nixpkgs for the system, with flutter.nix's overlay applied.

    packages.flutter = flutter-nix.packages.${system}.flutter;
  };
}

See #1 for more examples of usage with flakes.

With devenv and overlays

# devenv.yaml
inputs:
  nixpkgs:
    url: github:NixOS/nixpkgs/nixpkgs-unstable
  flutter-nix:
    url: github:maximoffua/flutter.nix/stable
    overlays:
      - default
# devenv.nix
{
  pkgs,
  inputs,
  ...
}: {
  languages.dart.enable = true;
  languages.dart.package = pkgs.flutter;

  enterShell = ''
    flutter --version
  '';
}

With devenv

If you have issues with overlay, just use package directly from this flake:

# devenv.yaml
inputs:
  nixpkgs:
    url: github:NixOS/nixpkgs/nixpkgs-unstable
  flutter-nix:
    url: github:maximoffua/flutter.nix/stable
# devenv.nix
{
  pkgs,
  inputs,
  ...
}: let
  system = pkgs.stdenv.system;
  flutter = inputs.flutter-nix.packages.${system}.flutter;
in {
  languages.dart.enable = true;
  languages.dart.package = flutter;

  enterShell = ''
    flutter --version
  '';
}

Update version

There is a Python script which will obtain the latest Flutter version, fetch info and update hash sums.

./update/update.py

Contributors

Big thanks:

About

A flake for flutter package out of nixpkgs.

License:The Unlicense


Languages

Language:Nix 73.7%Language:Shell 14.2%Language:Python 12.1%