mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 03:26:24 +00:00
Add .envrc for Nix environment setup
This commit is contained in:
parent
bf19ace3e9
commit
5f623c0594
5 changed files with 244 additions and 0 deletions
128
flake.nix
Normal file
128
flake.nix
Normal file
|
|
@ -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
|
||||
]
|
||||
);
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue