Skip to content

Instantly share code, notes, and snippets.

@portothree
Forked from Nadrieril/shell.nix
Created August 4, 2022 19:04
Show Gist options
  • Save portothree/23bf518f41b59fba717b87a715dfb7d0 to your computer and use it in GitHub Desktop.
Save portothree/23bf518f41b59fba717b87a715dfb7d0 to your computer and use it in GitHub Desktop.

Revisions

  1. @Nadrieril Nadrieril revised this gist Aug 1, 2018. 1 changed file with 10 additions and 6 deletions.
    16 changes: 10 additions & 6 deletions shell.nix
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,23 @@
    # I used this shell.nix to build LineageOS 13.0 for my maguro (Samsung Galaxy Nexus GSM) phone
    # The build instructions for normal Linuxes are here: https://wiki.lineageos.org/devices/maguro/build
    # NixOS instructions are as follows:
    # For NixOS, follow those instructions but skip anything related to installing packages
    # Detailed instructions:
    # cd into an empty directory of your choice
    # copy this file there
    # in nix-shell:
    # $ repo init -u https://github.com/LineageOS/android.git -b cm-13.0
    # $ repo sync
    # $ source build/envsetup.sh
    # $ breakfast maguro
    # Get binary blobs (I followed https://forum.xda-developers.com/showpost.php?s=a6ee98b07b1b0a2f4004b902a65d9dcd&p=76981184&postcount=4)
    # $ repo sync; breakfast maguro
    # $ ccache -M 50G
    # Get proprietary blobs (see https://wiki.lineageos.org/devices/maguro/build#extract-proprietary-blobs)
    # (I actually used blobs from https://github.com/TheMuppets, following https://forum.xda-developers.com/showpost.php?s=a6ee98b07b1b0a2f4004b902a65d9dcd&p=76981184&postcount=4)
    # $ ccache -M 50G (see https://wiki.lineageos.org/devices/maguro/build#turn-on-caching-to-speed-up-build)
    # $ croot
    # $ brunch maguro
    # Voilà ! It Just Works™ (at least it did for me)
    # $ cd $OUT
    # The built ROM is named something like lineage-13.0-20180730-UNOFFICIAL-maguro.zip
    # You can flash it onto your device as usual, see e.g. https://wiki.lineageos.org/devices/maguro/install for maguro
    # Voilà ! It Just Works™ (at least it did for me)

    # Warning: 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.
    @@ -48,7 +52,7 @@ let
    lz4
    lzop
    m4
    maven
    maven # Needed for LineageOS 13.0
    nettools
    openssl
    perl
  2. @Nadrieril Nadrieril revised this gist Aug 1, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion shell.nix
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ let
    pkgs = import <nixpkgs> {};

    # Inspired from https://nixos.wiki/wiki/Android#Building_Android_on_NixOS
    # I ad to ass several packages to make it work for me
    # I had to add several packages to make it work for me
    fhs = pkgs.buildFHSUserEnv {
    name = "android-env";
    targetPkgs = pkgs: with pkgs; [
  3. @Nadrieril Nadrieril created this gist Aug 1, 2018.
    87 changes: 87 additions & 0 deletions shell.nix
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    # I used this shell.nix to build LineageOS 13.0 for my maguro (Samsung Galaxy Nexus GSM) phone
    # The build instructions for normal Linuxes are here: https://wiki.lineageos.org/devices/maguro/build
    # NixOS instructions are as follows:
    # cd into an empty directory of your choice
    # copy this file there
    # in nix-shell:
    # $ repo init -u https://github.com/LineageOS/android.git -b cm-13.0
    # $ repo sync
    # $ source build/envsetup.sh
    # $ breakfast maguro
    # Get binary blobs (I followed https://forum.xda-developers.com/showpost.php?s=a6ee98b07b1b0a2f4004b902a65d9dcd&p=76981184&postcount=4)
    # $ repo sync; breakfast maguro
    # $ ccache -M 50G
    # $ croot
    # $ brunch maguro
    # Voilà ! It Just Works™ (at least it did for me)

    # Warning: 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.



    let
    # nixpkgs-unstable does not have jdk7 anymore. I used the nixos-18.03 channel
    pkgs = import <nixpkgs> {};

    # Inspired from https://nixos.wiki/wiki/Android#Building_Android_on_NixOS
    # I ad to ass several packages to make it work for me
    fhs = pkgs.buildFHSUserEnv {
    name = "android-env";
    targetPkgs = pkgs: with pkgs; [
    androidenv.platformTools
    bc
    binutils
    bison
    ccache
    curl
    flex
    gcc
    git
    gitRepo
    gnumake
    gnupg
    gperf
    imagemagick
    jdk7
    libxml2
    lz4
    lzop
    m4
    maven
    nettools
    openssl
    perl
    pngcrush
    procps
    python2
    rsync
    schedtool
    SDL
    squashfsTools
    unzip
    utillinux
    wxGTK30
    xml2
    zip
    ];
    multiPkgs = pkgs: with pkgs; [
    zlib
    ncurses5
    libcxx
    readline
    ];
    runScript = "bash";
    profile = ''
    export USE_CCACHE=1
    export ANDROID_JAVA_HOME=${pkgs.jdk7.home}
    # Building involves a phase of unzipping large files into a temporary directory
    export TMPDIR=/tmp
    '';
    };

    in pkgs.stdenv.mkDerivation {
    name = "android-env-shell";
    nativeBuildInputs = [ fhs ];
    shellHook = "exec android-env";
    }