119 lines
4.5 KiB
Nix
119 lines
4.5 KiB
Nix
{
|
|
description = "A very basic flake";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
android-nixpkgs.url = "github:tadfisher/android-nixpkgs";
|
|
android-nixpkgs.inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
flake-utils,
|
|
android-nixpkgs
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (system: let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
config = {
|
|
android_sdk.accept_license = true;
|
|
allowUnfree = true;
|
|
};
|
|
};
|
|
texlive-env = (pkgs.texlive.combine {
|
|
inherit (pkgs.texlive) scheme-basic
|
|
xetex
|
|
float xcolor varwidth fancyvrb multirow hanging adjustbox stackengine
|
|
enumitem alphalph ulem xkeyval collectbox etoolbox wasysym sectsty
|
|
tocloft newunicodechar caption etoc psnfss metafont helvetic courier
|
|
wasy wasy-type1
|
|
;
|
|
});
|
|
androidSdk = android-nixpkgs.sdk.${system} (sdkPkgs: with sdkPkgs; [
|
|
build-tools-30-0-3
|
|
build-tools-33-0-0
|
|
cmdline-tools-latest
|
|
platform-tools
|
|
platforms-android-33
|
|
]);
|
|
in rec {
|
|
formatter = pkgs.alejandra;
|
|
devShells.default =
|
|
pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
androidSdk
|
|
glibc
|
|
doxygen
|
|
graphviz
|
|
texlive-env
|
|
];
|
|
# override the aapt2 that gradle uses with the nix-shipped version
|
|
GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/share/android-sdk/build-tools/33.0.0/aapt2";
|
|
};
|
|
packages = rec {
|
|
invtracker-deps = pkgs.stdenv.mkDerivation {
|
|
name = "invtracker-deps";
|
|
src = self;
|
|
nativeBuildInputs = with pkgs; [gradle openjdk_headless perl];
|
|
buildPhase = ''
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
# Fetch the maven deps
|
|
gradle --no-daemon --info -Dorg.gradle.java.home=${pkgs.openjdk_headless} --write-verification-metadata sha256
|
|
'';
|
|
installPhase = ''
|
|
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(aar\|jar\|pom\|module\)$' \
|
|
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/maven/$x/$3/$4/$5" #e' \
|
|
| sh
|
|
'';
|
|
outputHashAlgo = "sha256";
|
|
outputHashMode = "recursive";
|
|
outputHash = "sha256-Rxd9z/HQpIBVixzgbj7tq0/WfqGLytPmN1vpNFN6BgI=";
|
|
};
|
|
invtracker-server = pkgs.stdenv.mkDerivation {
|
|
pname = "invtracker-server";
|
|
version = self.lastModifiedDate;
|
|
src = self;
|
|
nativeBuildInputs = with pkgs; [gradle openjdk_headless];
|
|
buildPhase = ''
|
|
sed -i 's#gradlePluginPortal..#maven { url "${invtracker-deps}/maven" }#' settings.gradle
|
|
sed -i 's#google..#maven { url "${invtracker-deps}/maven" }#' settings.gradle
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
gradle --offline --no-daemon --info -Dorg.gradle.java.home=${pkgs.openjdk_headless} server:installDist
|
|
'';
|
|
installPhase = ''
|
|
cp -rv server/build/install/server $out/
|
|
'';
|
|
};
|
|
invtracker-client =
|
|
pkgs.stdenv.mkDerivation rec {
|
|
pname = "invtracker-client";
|
|
version = self.lastModifiedDate;
|
|
src = self;
|
|
nativeBuildInputs = with pkgs; [gradle openjdk_headless androidSdk ];
|
|
buildPhase = ''
|
|
sed -i 's#gradlePluginPortal..#maven { url "${invtracker-deps}/maven" }#' settings.gradle
|
|
sed -i 's#google..#maven { url "${invtracker-deps}/maven" }#' settings.gradle
|
|
|
|
export GRADLE_USER_HOME=$(mktemp -d)
|
|
gradle --offline --no-daemon --info -Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/share/android-sdk/build-tools/33.0.0/aapt2 -Dorg.gradle.java.home=${pkgs.openjdk_headless} app:packageDebug
|
|
'';
|
|
installPhase = ''
|
|
mkdir $out
|
|
cp app/build/outputs/apk/debug/debug.apk $out/app.apk
|
|
mkdir $out/nix-support
|
|
echo "file binary-dist $out/app.apk" > $out/nix-support/hydra-build-products
|
|
echo "$pname-$version" > $out/nix-support/hydra-release-name
|
|
'';
|
|
};
|
|
invtracker-docs = pkgs.callPackage ./doc.nix { inherit self texlive-env; };
|
|
};
|
|
|
|
hydraJobs =
|
|
if system == "x86_64-linux"
|
|
then devShells // packages
|
|
else {};
|
|
});
|
|
}
|