diff --git a/flake.nix b/flake.nix index ea6ed1c..afb0d56 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,7 @@ description = "Nexus Flutter Flake"; inputs = { + self.submodules = true; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; }; @@ -38,32 +39,11 @@ }; }; - devShells.default = - let - android = pkgs.callPackage ./nix/android.nix { }; - in - pkgs.mkShell { - packages = with pkgs; [ - go - git - jdk17 - flutter - android.platform-tools - ]; + packages.default = pkgs.callPackage ./linux/nix/package.nix { + src = self; + }; - env = rec { - LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.libclang ]; - LD_LIBRARY_PATH = "./build/native_assets/linux:${lib.makeLibraryPath [ pkgs.zlib ]}"; - CPATH = lib.makeSearchPath "include" [ pkgs.glibc.dev ]; - - ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk"; - ANDROID_SDK_ROOT = ANDROID_HOME; - JAVA_HOME = pkgs.jdk17; - - TOOLS = "${ANDROID_HOME}/build-tools/${"36.0.0"}"; - GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${TOOLS}/aapt2"; - }; - }; + devShells.default = pkgs.callPackage ./linux/nix/devshell.nix { }; }; }; } diff --git a/hook/build.dart b/hook/build.dart index 52df9c4..69ed05d 100644 --- a/hook/build.dart +++ b/hook/build.dart @@ -3,9 +3,6 @@ import "package:hooks/hooks.dart"; import "package:code_assets/code_assets.dart"; Future main(List args) => build(args, (input, output) async { - final buildDir = input.packageRoot.resolve("build/"); - if (await File(buildDir.resolve("lock").toFilePath()).exists()) return; - final codeConfig = input.config.code; final targetOS = codeConfig.targetOS; final targetArch = codeConfig.targetArchitecture; @@ -49,6 +46,7 @@ Future main(List args) => build(args, (input, output) async { throw UnsupportedError("Unsupported OS: $targetOS"); } + final buildDir = input.packageRoot.resolve("build/"); final gomuksBuildDir = input.packageRoot.resolve("gomuks/"); final libFile = buildDir.resolve("${targetArch.name}/$libFileName"); diff --git a/linux/nexus.desktop b/linux/nexus.desktop new file mode 100644 index 0000000..850ac49 --- /dev/null +++ b/linux/nexus.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Nexus +Comment=A simple and user-friendly Matrix client +Exec=nexus +Icon=nexus +Terminal=false +Type=Application +Categories=Chat;Network;InstantMessaging; \ No newline at end of file diff --git a/linux/nix/devshell.nix b/linux/nix/devshell.nix new file mode 100644 index 0000000..91ba95a --- /dev/null +++ b/linux/nix/devshell.nix @@ -0,0 +1,41 @@ +{ pkgs, lib }: +let + android = pkgs.androidenv.composeAndroidPackages { + toolsVersion = "26.1.1"; + platformToolsVersion = "36.0.1"; + buildToolsVersions = [ + "35.0.0" + "36.0.0" + ]; + cmakeVersions = [ "3.22.1" ]; + platformVersions = [ "36" ]; + abiVersions = [ + "armeabi-v7a" + "arm64-v8a" + ]; + includeNDK = true; + ndkVersions = [ "28.2.13676358" ]; + }; +in +pkgs.mkShell { + packages = with pkgs; [ + go + git + jdk17 + flutter + android.platform-tools + ]; + + env = rec { + LIBCLANG_PATH = lib.makeLibraryPath [ pkgs.libclang ]; + LD_LIBRARY_PATH = "./build/native_assets/linux:${lib.makeLibraryPath [ pkgs.zlib ]}"; + CPATH = lib.makeSearchPath "include" [ pkgs.glibc.dev ]; + + ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk"; + ANDROID_SDK_ROOT = ANDROID_HOME; + JAVA_HOME = pkgs.jdk17; + + TOOLS = "${ANDROID_HOME}/build-tools/${"36.0.0"}"; + GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${TOOLS}/aapt2"; + }; +} diff --git a/linux/nix/package.nix b/linux/nix/package.nix new file mode 100644 index 0000000..cb5f61f --- /dev/null +++ b/linux/nix/package.nix @@ -0,0 +1,39 @@ +{ + lib, + libclang, + flutter, + src, + go, +}: + +flutter.buildFlutterApplication { + pname = "nexus"; + version = "0.1.0"; + inherit src; + + preBuild = '' + packageRunCustom nexus generate source/scripts test + packageRun build_runner build + ''; + + env.LIBCLANG_PATH = lib.makeLibraryPath [ libclang ]; + + nativeBuildInputs = [ + go + ]; + + autoPubspecLock = src + "/pubspec.lock"; + + gitHashes = { + window_size = "sha256-XelNtp7tpZ91QCEcvewVphNUtgQX7xrp5QP0oFo6DgM="; + flutter_chat_ui = "sha256-4fuag7lRH5cMBFD3fUzj2K541JwXLoz8HF/4OMr3uhk="; + flutter_link_previewer = "sha256-4fuag7lRH5cMBFD3fUzj2K541JwXLoz8HF/4OMr3uhk="; + }; + + meta = { + description = "A simple and user-friendly Matrix client"; + mainProgram = "nexus"; + platforms = lib.platforms.linux; + maintainers = with lib.maintainers; [ quadradical ]; + }; +} diff --git a/nix/android.nix b/nix/android.nix deleted file mode 100644 index 842597f..0000000 --- a/nix/android.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ - androidenv, -}: -androidenv.composeAndroidPackages { - toolsVersion = "26.1.1"; - platformToolsVersion = "36.0.1"; - buildToolsVersions = [ - "35.0.0" - "36.0.0" - ]; - cmakeVersions = [ "3.22.1" ]; - platformVersions = [ "36" ]; - abiVersions = [ - "armeabi-v7a" - "arm64-v8a" - ]; - includeNDK = true; - ndkVersions = [ "28.2.13676358" ]; -} diff --git a/scripts/generate.sh b/scripts/generate.sh deleted file mode 100755 index 6076ab8..0000000 --- a/scripts/generate.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -pushd "$(dirname "$(readlink -f "$0")")"/.. > /dev/null || exit - -mkdir -p build -touch build/lock -dart scripts/generate.dart -rm build/lock - -popd > /dev/null || exit \ No newline at end of file