-
-
Save Arian04/bea169c987d46a7f51c63a68bc117472 to your computer and use it in GitHub Desktop.
# I used this shell.nix to build LineageOS 21.0 for redfin (Google Pixel 5) | |
# | |
# IMPORANT NOTE: I had to use a pure shell for my builds to work, i.e: `nix-shell --pure` rather than `nix-shell` | |
# | |
# The build instructions are here: https://wiki.lineageos.org/devices/redfin/build | |
# | |
# Warning (from forked gist, was added August 1st 2018): | |
# The hardened NixOS kernel disables 32 bit emulation, which made me run into multiple "Exec format error" errors. | |
# To fix, use the default kernel, or enable "IA32_EMULATION y" in the kernel config. | |
# | |
# Created using: | |
# https://gist.github.com/Nadrieril/d006c0d9784ba7eff0b092796d78eb2a | |
# https://nixos.wiki/wiki/Android#Building_Android_on_NixOS | |
{pkgs ? import <nixpkgs> {}}: let | |
fhs = pkgs.buildFHSUserEnv { | |
name = "android-env"; | |
targetPkgs = pkgs: | |
with pkgs; [ | |
android-tools | |
libxcrypt-legacy # libcrypt.so.1 | |
freetype # libfreetype.so.6 | |
fontconfig # java NPE: "sun.awt.FontConfiguration.head" is null | |
yaml-cpp # necessary for some kernels according to a comment on the gist | |
# Some of the packages here are probably unecessary but I don't wanna figure out which | |
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.dev | |
perl | |
pngcrush | |
procps | |
python3 | |
rsync | |
schedtool | |
SDL | |
squashfsTools | |
unzip | |
util-linux | |
xml2 | |
zip | |
# only necessary if you wanna use `runScript = "zsh";` below | |
zsh | |
]; | |
multiPkgs = pkgs: | |
with pkgs; [ | |
zlib | |
ncurses5 | |
libcxx | |
readline | |
libgcc # crtbeginS.o | |
iconv # ??? - i put this here and by the time i went back to remove unecessary packages i forgot why | |
iconv.dev # sys/types.h | |
]; | |
runScript = "zsh"; # personal preference, you could set this to bash instead if you want | |
profile = '' | |
export ALLOW_NINJA_ENV=true | |
export USE_CCACHE=1 | |
export CCACHE_EXEC=/usr/bin/ccache | |
export ANDROID_JAVA_HOME=${pkgs.jdk11.home} | |
# Building involves a phase of unzipping large files into a temporary directory | |
export TMPDIR=/tmp | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.ncurses5}/lib | |
''; | |
}; | |
in | |
pkgs.stdenv.mkDerivation { | |
name = "android-env-shell"; | |
nativeBuildInputs = [fhs]; | |
shellHook = "exec android-env"; | |
} |
Your comment just made me realize I forgot to include an important note! I tried using this shell impurely and the builds kept failing until I used the pure version. So even if $SHELL
works, I wouldn't wanna include it because the user specifically has to add their shell package to the list.
I'll add the note about using it as a pure shell though, thanks for the reminder lol
edit: in order to make this more generic, I probably should've set it to bash
when I uploaded it, but the only reason I didn't is because I didn't test it with Bash. I probably should though.
Tested with bash, does work without a hitch.
add yaml-cpp as well, some kernels might need yaml.h
add yaml-cpp as well, some kernels might need yaml.h
thanks, good to know! I just updated the gist. did it on my phone in the browser though so hopefully the formatting isnt all messed up.
tysm
Thanks for making this script! One thing to note though,
Can be changed to $SHELL I think, which would utilise user's default shell.