diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..0154438f --- /dev/null +++ b/.envrc @@ -0,0 +1,14 @@ +# Check if nix is available +if command -v nix &> /dev/null; then + use flake + + echo "✅ Nix development environment loaded" +else + # Nix is not available - show instructions for non-Nix users + echo "⚠️ Nix not detected. Please ensure the following are installed manually:" + echo " - Java JDK 17" + echo " - Python 3 with invoke package" + echo " - Android SDK" + echo " - FVM (Flutter Version Management)" + echo "💡 To use Nix: Install from https://nixos.org/download.html" +fi diff --git a/.gitignore b/.gitignore index 8effbf9a..3b84f8e6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ .buildlog/ .history .svn/ +.direnv coverage/* diff --git a/NOTE.md b/NOTE.md new file mode 100644 index 00000000..665c4b3c --- /dev/null +++ b/NOTE.md @@ -0,0 +1,40 @@ +## Codeänderung + +- android/app/build.gradle: compileSdkVersion/targetSdkVersion auf 36 angehoben, + weil mehrere Plugins SDK 36 voraussetzen. + +## Devbuild (out of the box) + +```sh +invoke translate +flutter build apk --debug +``` + +## Releasebuild (benötigt Signatur; interaktiv) + +Signatur erstellen; Passwörter merken!: + +```sh +keytool -genkey -v -keystore ~/inventree-release-key.jks \ + -keyalg RSA -keysize 2048 \ + -alias inventree +``` + +android/key.properties anlegen mit: + +```properties +storePassword=DEIN_STORE_PASSWORD +keyPassword=DEIN_KEY_PASSWORD +keyAlias=inventree +storeFile=/.../inventree-release-key.jks +``` + +```sh +invoke translate +fvm flutter build apk --release --no-tree-shake-icons +``` + +## Pipe + +1. nix installieren (für flake nutzung) (optional aber dann reproduzierbar) +2. flake anwenden diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..1805babf --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1767892417, + "narHash": "sha256-dhhvQY67aboBk8b0/u0XB6vwHdgbROZT3fJAjyNh5Ww=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3497aa5c9457a9d88d71fa93a4a8368816fbeeba", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..5038e85e --- /dev/null +++ b/flake.nix @@ -0,0 +1,128 @@ +{ + description = "InvenTree App Development Environment - CTBK"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + config = { + allowUnfree = true; + android_sdk.accept_license = true; + }; + }; + + androidSdk = + (pkgs.androidenv.composeAndroidPackages { + platformVersions = [ + "36" + "35" + "34" + ]; + buildToolsVersions = [ + "36.0.0" + "34.0.0" + ]; + includeEmulator = true; + includeNDK = true; + ndkVersions = [ "26.1.10909125" ]; + cmakeVersions = [ + "3.31.6" + "3.22.1" + ]; + }).androidsdk; + + # FVM wrapper for NixOS - maps fvm commands to Nix-managed Flutter + fvm-wrapper = pkgs.writeShellScriptBin "fvm" '' + case "$1" in + use) + # 'fvm use' is a no-op on NixOS since Flutter is version-managed by Nix + echo "✓ Using Flutter from Nix ($(flutter --version | head -n1))" + exit 0 + ;; + flutter) + # 'fvm flutter ...' becomes 'flutter ...' + shift + exec flutter "$@" + ;; + *) + echo "fvm wrapper: command '$1' not implemented (using Nix-managed Flutter)" >&2 + exit 1 + ;; + esac + ''; + in + { + devShells.default = pkgs.mkShell { + buildInputs = + with pkgs; + [ + # Mobile development + flutter + fvm-wrapper + jdk17 + + # Build tools + android-tools + gradle + + # Python & task runner + python3 + python3Packages.invoke + + # System dependencies for Flutter on Linux + git + curl + unzip + which + ] + ++ lib.optionals stdenv.isLinux [ + gtk3 + glib + pcre + libepoxy + libxkbcommon + dbus + at-spi2-core + file + ]; + + shellHook = '' + export ANDROID_HOME="${androidSdk}/libexec/android-sdk" + export ANDROID_SDK_ROOT="$ANDROID_HOME" + export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools/bin:$PATH" + export JAVA_HOME="${pkgs.jdk17}" + export GRADLE_OPTS="-Dorg.gradle.project.android.aapt2FromMavenOverride=$ANDROID_HOME/build-tools/34.0.0/aapt2" + + echo "🚀 InvenTree App Development Environment - CTBK" + echo "📦 Tools: Flutter, FVM, JDK17, Android SDK" + echo "📋 Run: invoke android # Build Android app" + ''; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath ( + with pkgs; + [ + gtk3 + glib + pcre + libepoxy + libxkbcommon + dbus + at-spi2-core + ] + ); + }; + } + ); +}