diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..9bcab51 --- /dev/null +++ b/.envrc @@ -0,0 +1,9 @@ +use flake +flutter pub get +flutter config --enable-linux-desktop +dart pub global activate flutter_distributor +echo "**********************************************************************" +echo "* flutter build linux --release *" +echo "* flutter_distributor package --platform=linux --targets=zip *" +echo "* yq eval pubspec.lock -o=json -P > pubspec.lock.json *" +echo "**********************************************************************" diff --git a/.gitignore b/.gitignore index 3f1b889..7810d92 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # Files and directories created by pub .dart_tool/ +.direnv/ .packages build/ # If you're building an application, you may want to check-in your pubspec.lock diff --git a/devshell.nix b/devshell.nix new file mode 100644 index 0000000..8b6c39a --- /dev/null +++ b/devshell.nix @@ -0,0 +1,56 @@ +# https://manuelplavsic.ch/articles/flutter-environment-with-nix/ +{ + lib, + mkShell, + pkgs, + stdenv, + appimagekit, + clang, + cmake, + dart, + dpkg, + flutter, + git, + gnome, + gtk3, + ninja, + patchelf, + pcre2, + plocate, + pkg-config, + quickemu, + rpm, +}: +mkShell rec { + FLUTTER_ROOT = flutter; + DART_ROOT = "${flutter}/bin/cache/dart-sdk"; + buildInputs = [ + appimagekit + clang + cmake + dart + dpkg + flutter + git + gnome.zenity + gtk3 + ninja + patchelf + pcre2 + plocate + pkg-config + quickemu + rpm + ]; + # vulkan-loader and libGL shared libs are necessary for hardware decoding + LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath [ pkgs.vulkan-loader pkgs.libGL ]}"; + # Packages installed via `dart pub global activate package_name` are + # located in the `$PUB_CACHE/bin` directory. + shellHook = '' + if [ -z "$PUB_CACHE" ]; then + export PATH="$PATH":"$HOME/.pub-cache/bin" + else + export PATH="$PATH":"$PUB_CACHE/bin" + fi + ''; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e754ce7 --- /dev/null +++ b/flake.lock @@ -0,0 +1,40 @@ +{ + "nodes": { + "flake-schemas": { + "locked": { + "lastModified": 1697467827, + "narHash": "sha256-j8SR19V1SRysyJwpOBF4TLuAvAjF5t+gMiboN4gYQDU=", + "rev": "764932025c817d4e500a8d2a4d8c565563923d29", + "revCount": 29, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.2/018b3da8-4cc3-7fbb-8ff7-1588413c53e2/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/DeterminateSystems/flake-schemas/%2A.tar.gz" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1719254875, + "narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=", + "rev": "2893f56de08021cffd9b6b6dfc70fd9ccd51eb60", + "revCount": 643242, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.643242%2Brev-2893f56de08021cffd9b6b6dfc70fd9ccd51eb60/0190530b-f61b-7788-9601-b336b1caf671/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz" + } + }, + "root": { + "inputs": { + "flake-schemas": "flake-schemas", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c945e32 --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + description = "Quickemu flake"; + inputs = { + flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*.tar.gz"; + nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz"; + }; + + outputs = { + self, + flake-schemas, + nixpkgs, + }: let + forAllSystems = function: + nixpkgs.lib.genAttrs [ + "x86_64-linux" + # TODO: Enable when upstream supports these platforms + #"aarch64-linux" + #"x86_64-darwin" + #"aarch64-darwin" + ] (system: function nixpkgs.legacyPackages.${system}); + in { + # Schemas tell Nix about the structure of your flake's outputs + schemas = flake-schemas.schemas; + + overlays.default = final: prev: { + quickgui = final.callPackage ./package.nix {}; + }; + + packages = forAllSystems (pkgs: rec { + quickgui = pkgs.callPackage ./package.nix {}; + default = quickgui; + }); + + devShells = forAllSystems (pkgs: { + default = pkgs.callPackage ./devshell.nix {}; + }); + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..e61da65 --- /dev/null +++ b/package.nix @@ -0,0 +1,64 @@ +{ fetchFromGitHub +, makeDesktopItem +, copyDesktopItems +, lib +, flutter +, gnome +, quickemu +}: +let + runtimeBinDependencies = [ gnome.zenity ]; + versionMatches = + builtins.match '' + .* + version:[[:blank:]]"([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)" + .* + '' (builtins.readFile ./pubspec.yaml); +in +flutter.buildFlutterApplication rec { + pname = "quickgui"; + version = builtins.concatStringsSep "" versionMatches; + src = fetchFromGitHub { + owner = "quickemu-project"; + repo = "quickgui"; + #rev = version; + rev = "d4893b5d2cb2e7ef271e4c2d66683e30d70352e2"; + hash = "sha256-V9wSENva/5Khqzor+Umj7BooWecDqn91Bj+waDMMPyY="; + }; + pubspecLock = lib.importJSON ./pubspec.lock.json; + + gitHashes = { + window_size = "sha256-mn1UFA4Vqh3f5MqlTy9LueWr6qvCOHLujVoEQi0KMNw="; + }; + + # These things are added to LD_LIBRARY_PATH, but not PATH + runtimeDependencies = [ quickemu ]; + extraWrapProgramArgs = "--prefix PATH : ${lib.makeBinPath runtimeBinDependencies}"; + + nativeBuildInputs = [ copyDesktopItems ]; + + postFixup = '' + mkdir -p $out/share/pixmaps + cp $out/app/data/flutter_assets/assets/images/logo_pink.png $out/share/pixmaps/quickemu.png + ''; + + desktopItems = [ + (makeDesktopItem { + name = "quickgui"; + exec = "quickgui"; + icon = "quickgui"; + desktopName = "Quickgui"; + categories = [ "Development" "System" ]; + }) + ]; + + meta = with lib; { + description = "Flutter frontend for quickemu"; + homepage = "https://github.com/quickemu-project/quickgui"; + changelog = "https://github.com/quickemu-project/quickgui/releases/"; + license = licenses.mit; + maintainers = with maintainers; [ flexiondotorg heyimnova ]; + platforms = [ "x86_64-linux" ]; + mainProgram = "quickgui"; + }; +} diff --git a/pubspec.yaml b/pubspec.yaml index 0a04eec..9d3220e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ version: 1.2.8+1 environment: sdk: ">=3.2.0 <4.0.0" - flutter: "3.22.2" + flutter: "3.22.0" dependencies: flutter: