Skip to content

Instantly share code, notes, and snippets.

@dwf
Created September 7, 2025 22:39
Show Gist options
  • Save dwf/fb3b94473c38e36af71e118b6b63a732 to your computer and use it in GitHub Desktop.
Save dwf/fb3b94473c38e36af71e118b6b63a732 to your computer and use it in GitHub Desktop.
Haphazardly concocted NixOS build environment for LineageOS on 21.0 for samsung/y2q
# Copyright 2025 Google LLC.
# SPDX-License-Identifier: Apache-2.0
# "nix develop" to enter. Don't put it in your main source tree or it will try and add that behemoth to the nix store.
# See also
# https://gist.github.com/Arian04/bea169c987d46a7f51c63a68bc117472
# https://gist.github.com/Nadrieril/d006c0d9784ba7eff0b092796d78eb2a
# https://nixos.wiki/wiki/Android#Building_Android_on_NixOS (out of date)
{
description = "Haphazardly concocted NixOS build environment for LineageOS on 21.0 for samsung/y2q";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.default =
(pkgs.buildFHSEnv {
name = "android-build-env";
# Likely not minimal, but paring it back will be a pain.
targetPkgs =
pkgs: with pkgs; [
android-tools
libxcrypt-legacy
freetype
fontconfig
yaml-cpp
bc
binutils
bison
ccache
curl
flex
gcc
git
git-repo
git-lfs
gnumake
gnupg
gperf
imagemagick
jdk11
elfutils
libxml2
libxslt
lz4
lzop
m4
nettools
openssl
openssl.dev
perl
pngcrush
procps
python3
rsync
schedtool
SDL
squashfsTools
unzip
util-linux
xml2
zip
zsh
];
multiPkgs =
pkgs: with pkgs; [
zlib
ncurses5
libcxx
readline
libgcc
iconv
iconv.dev
gcc.cc
];
runScript = "zsh";
multiArch = true;
profile = ''
export ALLOW_NINJA_ENV=true
export JAVA_HOME=${pkgs.openjdk11}
export PATH=$PATH:~/.bin
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
export LC_ALL=C
export ANDROID_JAVA_HOME=$JAVA_HOME
export ANDROID_HOME=$HOME/Android/Sdk
ccache -M 50G 2>/dev/null || true
'';
}).env;
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment