diff --git a/flake.nix b/flake.nix index c4c5cc3..0e5e7c8 100644 --- a/flake.nix +++ b/flake.nix @@ -29,6 +29,22 @@ ... }: + let + src = ./.; + + # from https://discourse.nixos.org/t/is-there-a-way-to-read-a-yaml-file-and-get-back-a-set/18385/5 + importYAML = + file: + lib.importJSON ( + pkgs.runCommand "converted-yaml.json" { } ''${pkgs.yj}/bin/yj < "${file}" > "$out"'' + ); + + package = importYAML "${src}/pubspec.yaml"; + + usedFlutter = (pkgs.flutter.override { extraPkgConfigPackages = [ pkgs.libsecret ]; }); + + buildInputs = [ pkgs.sqlite ]; + in { _module.args.pkgs = import nixpkgs { inherit system; @@ -45,20 +61,35 @@ olm git clang - (flutter.override { extraPkgConfigPackages = [ pkgs.libsecret ]; }) + usedFlutter (pkgs.writeShellScriptBin "rustup" (builtins.readFile ./nix/fake-rustup.sh)) ]; env = { - LD_LIBRARY_PATH = "${ - pkgs.lib.makeLibraryPath ([ - pkgs.sqlite - ]) - }:./build/native_assets/linux"; + LD_LIBRARY_PATH = "${lib.makeLibraryPath buildInputs}:./build/native_assets/linux"; CPATH = lib.makeSearchPath "include" [ pkgs.glibc.dev ]; }; }; + + packages.default = usedFlutter.buildFlutterApplication { + inherit src buildInputs; + pname = package.name; + version = package.version; + + pubspecLock = importYAML "${src}/pubspec.lock"; + gitHashes = { + flutter_chat_ui = "sha256-4fuag7lRH5cMBFD3fUzj2K541JwXLoz8HF/4OMr3uhk="; + flutter_link_previewer = "sha256-4fuag7lRH5cMBFD3fUzj2K541JwXLoz8HF/4OMr3uhk="; + flyer_chat_text_message = "sha256-4fuag7lRH5cMBFD3fUzj2K541JwXLoz8HF/4OMr3uhk="; + window_size = "sha256-XelNtp7tpZ91QCEcvewVphNUtgQX7xrp5QP0oFo6DgM="; + }; + + patchPhase = /* sh */ '' + patchShebangs ./scripts/generate.sh + ./scripts/generate.sh # note: this doesn't quit the build on fail + ''; + }; }; }; }