-
-
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
I tried this and am facing this issue when building beryllium on nixos. Any idea how to solve it? Am using nixpkgs unstable if it helps
@JohnRTitor @drishal @jmir1 @Arian04 any clue?
ld.lld: error: cannot open crtbeginS.o: No such file or directory
ld.lld: error: unable to find library -lgcc
ld.lld: error: unable to find library -lgcc
ld.lld: error: cannot open crtendS.o: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@nishithkhanna In my case I forgot to install all dependencies: https://wiki.lineageos.org/devices/FP4/build/#install-the-build-packages, source: https://www.reddit.com/r/LineageOS/comments/x0jaij/comment/im8f85t/
For reference you also asked this question:
I tried this and am facing this issue when building beryllium on nixos. Any idea how to solve it? Am using nixpkgs unstable if it helps
@JohnRTitor @drishal @jmir1 @Arian04 any clue?
ld.lld: error: cannot open crtbeginS.o: No such file or directory ld.lld: error: unable to find library -lgcc ld.lld: error: unable to find library -lgcc ld.lld: error: cannot open crtendS.o: No such file or directory clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am facing the same issue when trying to build guacamole on nixos. Did you find a fix for it?
sorry for the late response. I've made a handful of changes to the file since the last edit. Some of which are to add glibc_multi to multiPkgs and set multiArch = true for buildFHSEnv. Again I made a decent amount of changes, so I'm not sure these are the ones that fix that, but it's worth a try. I'll probably upload all my changes sometime soon-ish, so if those don't work, you could try my exact setup.
Thanks for making this script! One thing to note though,
Can be changed to $SHELL I think, which would utilise user's default shell.