mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
Add updated pkgs tree
This commit is contained in:
parent
f40362898a
commit
68e5b8302a
10 changed files with 333 additions and 2 deletions
4
ci.nix
4
ci.nix
|
|
@ -6,11 +6,11 @@ with import <nixpkgs> { };
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
src = import ./src;
|
pkgs = import ./pkgs;
|
||||||
|
|
||||||
attrs = genAttrs
|
attrs = genAttrs
|
||||||
[ "aarch64" "i686" ]
|
[ "aarch64" "i686" ]
|
||||||
(arch: (src { inherit arch; }) // { recurseForDerivations = true; });
|
(arch: (pkgs { inherit arch; }) // { recurseForDerivations = true; });
|
||||||
|
|
||||||
isCacheable = p: !(p.preferLocalBuild or false);
|
isCacheable = p: !(p.preferLocalBuild or false);
|
||||||
shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false;
|
shouldRecurseForDerivations = p: isAttrs p && p.recurseForDerivations or false;
|
||||||
|
|
|
||||||
10
pkgs/bootstrap-zip.nix
Normal file
10
pkgs/bootstrap-zip.nix
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ config, runCommand, zip, bootstrap }:
|
||||||
|
|
||||||
|
runCommand "bootstrap-zip" { } ''
|
||||||
|
mkdir $out
|
||||||
|
cd ${bootstrap}
|
||||||
|
${zip}/bin/zip -q -9 -r $out/bootstrap-${config.build.arch} ./* ./.l2s
|
||||||
|
''
|
||||||
39
pkgs/bootstrap.nix
Normal file
39
pkgs/bootstrap.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ runCommand, nixDirectory, prootTermux, bash, pkgs, config }:
|
||||||
|
|
||||||
|
let
|
||||||
|
packageInfo = import "${nixDirectory}/nix-support/package-info.nix";
|
||||||
|
in
|
||||||
|
|
||||||
|
runCommand "bootstrap" { } ''
|
||||||
|
mkdir --parents $out/{.l2s,bin,etc,nix,root,tmp,usr/{bin,lib}}
|
||||||
|
|
||||||
|
cp --recursive ${nixDirectory}/store $out/nix/store
|
||||||
|
cp --recursive ${nixDirectory}/var $out/nix/var
|
||||||
|
chmod --recursive u+w $out/nix
|
||||||
|
|
||||||
|
ln --symbolic ${packageInfo.bash}/bin/sh $out/bin/sh
|
||||||
|
ln --symbolic ${packageInfo.coreutils}/bin/env $out/usr/bin/env
|
||||||
|
|
||||||
|
install -D -m 0755 ${prootTermux}/bin/proot-static $out/bin/proot-static
|
||||||
|
|
||||||
|
cp ${config.environment.files.login} $out/bin/login
|
||||||
|
cp ${config.environment.files.loginInner} $out/usr/lib/login-inner
|
||||||
|
|
||||||
|
${bash}/bin/bash ${../modules/environment/etc/setup-etc.sh} $out/etc ${config.build.activationPackage}/etc
|
||||||
|
|
||||||
|
cp --dereference --recursive $out/etc/static $out/etc/.static.tmp
|
||||||
|
rm $out/etc/static
|
||||||
|
mv $out/etc/.static.tmp $out/etc/static
|
||||||
|
|
||||||
|
find $out -executable -type f | sed s@^$out/@@ > $out/EXECUTABLES.txt
|
||||||
|
|
||||||
|
find $out -type l | while read -r LINK; do
|
||||||
|
LNK=''${LINK#$out/}
|
||||||
|
TGT=$(readlink "$LINK")
|
||||||
|
echo "$TGT←$LNK" >> $out/SYMLINKS.txt
|
||||||
|
rm "$LINK"
|
||||||
|
done
|
||||||
|
''
|
||||||
32
pkgs/cross-compiling/pkgs.nix
Normal file
32
pkgs/cross-compiling/pkgs.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ config, libjpeg, path }:
|
||||||
|
|
||||||
|
let
|
||||||
|
loadNixpkgs = import ../lib/load-nixpkgs.nix;
|
||||||
|
|
||||||
|
overlayJpegNoStatic = self: super: {
|
||||||
|
inherit libjpeg;
|
||||||
|
};
|
||||||
|
|
||||||
|
crossSystem = {
|
||||||
|
config = "${config.build.arch}-unknown-linux-android";
|
||||||
|
sdkVer = "24";
|
||||||
|
ndkVer = "18b";
|
||||||
|
useAndroidPrebuilt = true;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
cross = loadNixpkgs { inherit crossSystem; };
|
||||||
|
|
||||||
|
crossStatic = loadNixpkgs {
|
||||||
|
inherit crossSystem;
|
||||||
|
|
||||||
|
crossOverlays = [
|
||||||
|
(import "${path}/pkgs/top-level/static.nix")
|
||||||
|
overlayJpegNoStatic
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
28
pkgs/cross-compiling/proot-termux.nix
Normal file
28
pkgs/cross-compiling/proot-termux.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ callPackage, fetchFromGitHub, talloc }:
|
||||||
|
|
||||||
|
let
|
||||||
|
pkgs = callPackage ./pkgs.nix { };
|
||||||
|
in
|
||||||
|
|
||||||
|
pkgs.crossStatic.stdenv.mkDerivation {
|
||||||
|
pname = "proot-termux";
|
||||||
|
version = "unstable-2019-09-05";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
repo = "proot";
|
||||||
|
owner = "termux";
|
||||||
|
rev = "3ea655b1ae40bfa2ee612d45bf1e7ad97c4559f8";
|
||||||
|
sha256 = "05y30ifbp4sn1pzy8wlifc5d9n2lrgspqzdjix1kxjj9j9947qgd";
|
||||||
|
};
|
||||||
|
|
||||||
|
buildInputs = [ talloc ];
|
||||||
|
|
||||||
|
makeFlags = [ "-Csrc CFLAGS=-D__ANDROID__" ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
install -D -m 0755 src/proot $out/bin/proot-static
|
||||||
|
'';
|
||||||
|
}
|
||||||
73
pkgs/cross-compiling/talloc.nix
Normal file
73
pkgs/cross-compiling/talloc.nix
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ callPackage, fetchurl, python2, zlib }:
|
||||||
|
|
||||||
|
let
|
||||||
|
pkgs = callPackage ./pkgs.nix { };
|
||||||
|
in
|
||||||
|
|
||||||
|
pkgs.cross.stdenv.mkDerivation rec {
|
||||||
|
name = "talloc-2.1.14";
|
||||||
|
|
||||||
|
src = fetchurl {
|
||||||
|
url = "mirror://samba/talloc/${name}.tar.gz";
|
||||||
|
sha256 = "1kk76dyav41ip7ddbbf04yfydb4jvywzi2ps0z2vla56aqkn11di";
|
||||||
|
};
|
||||||
|
|
||||||
|
depsBuildBuild = [ python2 zlib ];
|
||||||
|
|
||||||
|
buildDeps = [ pkgs.cross.zlib ];
|
||||||
|
|
||||||
|
configurePhase = ''
|
||||||
|
substituteInPlace buildtools/bin/waf \
|
||||||
|
--replace "/usr/bin/env python" "${python2}/bin/python"
|
||||||
|
./configure --prefix=$out \
|
||||||
|
--disable-rpath \
|
||||||
|
--disable-python \
|
||||||
|
--cross-compile \
|
||||||
|
--cross-answers=cross-answers.txt
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
make
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/lib
|
||||||
|
make install
|
||||||
|
${pkgs.cross.stdenv.cc.targetPrefix}ar q $out/lib/libtalloc.a bin/default/talloc_[0-9]*.o
|
||||||
|
'';
|
||||||
|
|
||||||
|
fixupPhase = "";
|
||||||
|
|
||||||
|
prePatch = ''
|
||||||
|
cat <<EOF > cross-answers.txt
|
||||||
|
Checking uname sysname type: "Linux"
|
||||||
|
Checking uname machine type: "dontcare"
|
||||||
|
Checking uname release type: "dontcare"
|
||||||
|
Checking uname version type: "dontcare"
|
||||||
|
Checking simple C program: OK
|
||||||
|
building library support: OK
|
||||||
|
Checking for large file support: OK
|
||||||
|
Checking for -D_FILE_OFFSET_BITS=64: OK
|
||||||
|
Checking for WORDS_BIGENDIAN: OK
|
||||||
|
Checking for C99 vsnprintf: OK
|
||||||
|
Checking for HAVE_SECURE_MKSTEMP: OK
|
||||||
|
rpath library support: OK
|
||||||
|
-Wl,--version-script support: FAIL
|
||||||
|
Checking correct behavior of strtoll: OK
|
||||||
|
Checking correct behavior of strptime: OK
|
||||||
|
Checking for HAVE_IFACE_GETIFADDRS: OK
|
||||||
|
Checking for HAVE_IFACE_IFCONF: OK
|
||||||
|
Checking for HAVE_IFACE_IFREQ: OK
|
||||||
|
Checking getconf LFS_CFLAGS: OK
|
||||||
|
Checking for large file support without additional flags: OK
|
||||||
|
Checking for working strptime: OK
|
||||||
|
Checking for HAVE_SHARED_MMAP: OK
|
||||||
|
Checking for HAVE_MREMAP: OK
|
||||||
|
Checking for HAVE_INCOHERENT_MMAP: OK
|
||||||
|
Checking getconf large file support flags work: OK
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
||||||
46
pkgs/default.nix
Normal file
46
pkgs/default.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ arch, nixOnDroidChannelURL ? null, nixpkgsChannelURL ? null }:
|
||||||
|
|
||||||
|
let
|
||||||
|
loadNixpkgs = import lib/load-nixpkgs.nix;
|
||||||
|
|
||||||
|
nixpkgs = loadNixpkgs { };
|
||||||
|
|
||||||
|
config = import ../modules {
|
||||||
|
pkgs = nixpkgs;
|
||||||
|
initialBuild = true;
|
||||||
|
|
||||||
|
config = {
|
||||||
|
imports = [ ../modules/build/initial-build ];
|
||||||
|
|
||||||
|
_module.args = { inherit customPkgs; };
|
||||||
|
|
||||||
|
build = {
|
||||||
|
inherit arch;
|
||||||
|
|
||||||
|
channel = with nixpkgs.lib; {
|
||||||
|
nixpkgs = mkIf (nixpkgsChannelURL != null) nixpkgsChannelURL;
|
||||||
|
nix-on-droid = mkIf (nixOnDroidChannelURL != null) nixOnDroidChannelURL;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
callPackage = nixpkgs.lib.callPackageWith (
|
||||||
|
nixpkgs // customPkgs // { inherit callPackage config; }
|
||||||
|
);
|
||||||
|
|
||||||
|
customPkgs = rec {
|
||||||
|
bootstrap = callPackage ./bootstrap.nix { };
|
||||||
|
bootstrapZip = callPackage ./bootstrap-zip.nix { };
|
||||||
|
nixDirectory = callPackage ./nix-directory.nix { };
|
||||||
|
packageInfo = import "${nixDirectory}/nix-support/package-info.nix";
|
||||||
|
prootTermux = callPackage ./cross-compiling/proot-termux.nix { };
|
||||||
|
qemuAarch64Static = callPackage ./qemu-aarch64-static.nix { };
|
||||||
|
talloc = callPackage ./cross-compiling/talloc.nix { };
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
customPkgs
|
||||||
17
pkgs/lib/load-nixpkgs.nix
Normal file
17
pkgs/lib/load-nixpkgs.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
let
|
||||||
|
defaultNixpkgsArgs = {
|
||||||
|
config = { };
|
||||||
|
overlays = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# head of nixos-19.09 as of 2019-10-14
|
||||||
|
pinnedPkgsSrc = builtins.fetchTarball {
|
||||||
|
url = "https://github.com/NixOS/nixpkgs/archive/45a25ff41a2309099ff2e70b2f37debd5e567618.tar.gz";
|
||||||
|
sha256 = "0w37p98i47d7snhckz8a3a60v0f05b5047vsm4rczink9mk9x7r3";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
args: import pinnedPkgsSrc (args // defaultNixpkgsArgs)
|
||||||
67
pkgs/nix-directory.nix
Normal file
67
pkgs/nix-directory.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ config, lib, stdenv, proot, qemuAarch64Static }:
|
||||||
|
|
||||||
|
let
|
||||||
|
buildRootDirectory = "root-directory";
|
||||||
|
|
||||||
|
prootCommand = lib.concatStringsSep " " [
|
||||||
|
"${proot}/bin/proot"
|
||||||
|
(
|
||||||
|
if config.build.arch == "aarch64"
|
||||||
|
then "-q ${qemuAarch64Static}/bin/qemu-aarch64-static"
|
||||||
|
else "-b /dev"
|
||||||
|
)
|
||||||
|
"-r ${buildRootDirectory}"
|
||||||
|
"-w /"
|
||||||
|
];
|
||||||
|
in
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "nix-directory";
|
||||||
|
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "https://nixos.org/releases/nix/nix-2.3.1/nix-2.3.1-${config.build.arch}-linux.tar.xz";
|
||||||
|
sha256 =
|
||||||
|
if config.build.arch == "aarch64"
|
||||||
|
then "94a6a525bd0b2df82e14b96b5b0eaae86669b5d4671aacfc4db2db85325a81c1"
|
||||||
|
else "a5d3f26d4a449616bf654286f2fe29c1c1df4f029b7e29fa3ccf8494d598bfee"; # i686
|
||||||
|
};
|
||||||
|
|
||||||
|
PROOT_NO_SECCOMP = 1; # see https://github.com/proot-me/PRoot/issues/106
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
mkdir --parents ${buildRootDirectory}/nix
|
||||||
|
cp --recursive store ${buildRootDirectory}/nix/store
|
||||||
|
|
||||||
|
CACERT=$(find ${buildRootDirectory}/nix/store -path '*-nss-cacert-*/ca-bundle.crt' | sed 's,^${buildRootDirectory},,')
|
||||||
|
PKG_BASH=$(find ${buildRootDirectory}/nix/store -path '*/bin/bash' | sed 's,^${buildRootDirectory},,')
|
||||||
|
PKG_BASH=''${PKG_BASH%/bin/bash}
|
||||||
|
PKG_COREUTILS=$(find ${buildRootDirectory}/nix/store -path '*/bin/env' | sed 's,^${buildRootDirectory},,')
|
||||||
|
PKG_COREUTILS=''${PKG_COREUTILS%/bin/env}
|
||||||
|
PKG_NIX=$(find ${buildRootDirectory}/nix/store -path '*/bin/nix' | sed 's,^${buildRootDirectory},,')
|
||||||
|
PKG_NIX=''${PKG_NIX%/bin/nix}
|
||||||
|
|
||||||
|
USER=nix-on-droid ${prootCommand} "$PKG_NIX/bin/nix-store" --init
|
||||||
|
USER=nix-on-droid ${prootCommand} "$PKG_NIX/bin/nix-store" --load-db < .reginfo
|
||||||
|
|
||||||
|
cat > package-info.nix <<EOF
|
||||||
|
{
|
||||||
|
bash = "$PKG_BASH";
|
||||||
|
cacert = "$CACERT";
|
||||||
|
coreutils = "$PKG_COREUTILS";
|
||||||
|
nix = "$PKG_NIX";
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir $out
|
||||||
|
cp --recursive ${buildRootDirectory}/nix/store $out/store
|
||||||
|
cp --recursive ${buildRootDirectory}/nix/var $out/var
|
||||||
|
install -D -m 0644 package-info.nix $out/nix-support/package-info.nix
|
||||||
|
'';
|
||||||
|
|
||||||
|
fixupPhase = "true";
|
||||||
|
}
|
||||||
19
pkgs/qemu-aarch64-static.nix
Normal file
19
pkgs/qemu-aarch64-static.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Licensed under GNU Lesser General Public License v3 or later, see COPYING.
|
||||||
|
# Copyright (c) 2019 Alexander Sosedkin and other contributors, see AUTHORS.
|
||||||
|
|
||||||
|
{ stdenv }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "qemu-aarch64-static";
|
||||||
|
|
||||||
|
src = builtins.fetchurl {
|
||||||
|
url = "https://github.com/multiarch/qemu-user-static/releases/download/v4.1.0-1/qemu-aarch64-static";
|
||||||
|
sha256 = "06491ivqjz1n4c391dvl8fzgkc82ijcgg7qz1fnjh0hks12fd85s";
|
||||||
|
};
|
||||||
|
|
||||||
|
unpackPhase = "true";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
install -D -m 0755 $src $out/bin/qemu-aarch64-static
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue