diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8000e13 --- /dev/null +++ b/flake.lock @@ -0,0 +1,44 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1790046670, + "narHash": "sha256-MYiI+CzL0tuWgRPjGsKCDHqYs2T3OzMlMQWOYWG0qso=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6774f7bc253789b113a4f39285dc0fa100abeacc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-flutter": { + "locked": { + "lastModified": 1774840819, + "narHash": "sha256-V9TPFnbTQx9bDyVKuHpYi/0fC5qTgxDeHkST0RNAuTk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "27dfede99da61fd1ead9d4a2fa92bc9c242e83d2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "27dfede99da61fd1ead9d4a2fa92bc9c242e83d2", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nixpkgs-flutter": "nixpkgs-flutter" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4d3d0ad --- /dev/null +++ b/flake.nix @@ -0,0 +1,52 @@ +{ + description = "OpenStrap analytics Dart and Flutter development environment"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + # Same Flutter/Dart release as ../edge and its CI. + inputs.nixpkgs-flutter.url = + "github:NixOS/nixpkgs/27dfede99da61fd1ead9d4a2fa92bc9c242e83d2"; + + outputs = { nixpkgs, nixpkgs-flutter, ... }: + let + systems = [ "x86_64-linux" "aarch64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + in { + devShells = forAllSystems (system: + let + pkgs = import nixpkgs { inherit system; }; + flutterPkgs = import nixpkgs-flutter { + inherit system; + config.allowUnfree = true; + }; + flutter = flutterPkgs.flutterPackages.v3_41; + tools = with pkgs; [ + flutter git ripgrep jq python3 gnumake unzip which + clang cmake ninja pkg-config + ]; + fhs = pkgs.buildFHSEnv { + name = "analytics-fhs"; + targetPkgs = p: tools ++ (with p; [ + bashInteractive zlib libcxx ncurses5 gtk3 fontconfig libGL + ]); + profile = '' + export IN_ANALYTICS_FHS=1 + ''; + runScript = pkgs.writeShellScript "analytics-fhs-run" '' + if [[ $# -eq 0 ]]; then exec bash; else exec "$@"; fi + ''; + }; + in { + default = pkgs.mkShell { + packages = tools ++ [ fhs ]; + shellHook = '' + # Let the packaged Flutter wrapper select its complete SDK, + # including prebuilt engine/test artifacts. + unset FLUTTER_ROOT + if [[ -z "''${IN_ANALYTICS_FHS:-}" && $- == *i* ]]; then + exec analytics-fhs + fi + ''; + }; + }); + }; +}