Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.

{ pkgs, home-manager, nmdSrc }:
{ pkgs, crossPkgs ? pkgs, home-manager, nmdSrc }:

let
nmd = import nmdSrc { inherit pkgs; };
Expand All @@ -15,7 +15,7 @@ let
};

modules = import ../modules/module-list.nix {
inherit pkgs;
inherit pkgs crossPkgs;
home-manager-path = home-manager.outPath;
isFlake = true;
targetSystem = "aarch64-linux/x86_64-linux";
Expand Down
14 changes: 7 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
nixpkgs.url = "github:NixOS/nixpkgs";

# for bootstrap zip ball creation and proot-termux builds, we use a fixed version of nixpkgs to ease maintanence.
# head of nixos-24.05 as of 2024-07-06
# note: when updating nixpkgs-for-bootstrap, update store paths of proot-termux in modules/environment/login/default.nix
nixpkgs-for-bootstrap.url = "github:NixOS/nixpkgs/49ee0e94463abada1de470c9c07bfc12b36dcf40";
# head of nixos-25.11 as of 2026-02-16
nixpkgs-for-bootstrap.url = "github:NixOS/nixpkgs/fa56d7d6de78f5a7f997b0ea2bc6efd5868ad9e8";

home-manager = {
url = "github:nix-community/home-manager";
Expand Down Expand Up @@ -78,6 +77,7 @@
, config ? null
, extraModules ? null
, system ? null # pkgs.stdenv.hostPlatform.system is used to detect user's arch
, bootstrapSystem ? pkgs.stdenv.hostPlatform.system
}:
if ! (builtins.elem pkgs.stdenv.hostPlatform.system [ "aarch64-linux" "x86_64-linux" ]) then
throw
Expand All @@ -104,6 +104,7 @@
inherit extraSpecialArgs home-manager-path pkgs;
config.imports = modules;
isFlake = true;
crossPkgs = import nixpkgs-for-bootstrap { crossSystem = pkgs.stdenv.hostPlatform.system; localSystem = bootstrapSystem; };
});

overlays.default = overlay;
Expand All @@ -118,9 +119,14 @@
derivationAttrset;
perArchCustomPkgs = arch: flattenArch arch
(import ./pkgs {
_nativeSystem = system; # system to cross-compile from
system = "${arch}-linux"; # system to cross-compile to
nixpkgs = nixpkgs-for-bootstrap;
pkgs = import nixpkgs-for-bootstrap { inherit system; };
crossPkgs = import nixpkgs-for-bootstrap {
crossSystem = "${arch}-linux";
localSystem = system;
};
targetPkgs = import nixpkgs-for-bootstrap {
system = "${arch}-linux";
};
}).customPkgs;

docs = import ./docs {
Expand Down
3 changes: 2 additions & 1 deletion modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
, pkgs ? import <nixpkgs> { }
, home-manager-path ? <home-manager>
, isFlake ? false
, crossPkgs
}:

with pkgs.lib;
Expand All @@ -19,7 +20,7 @@ let
else pkgs.config.nix-on-droid or (throw "No config file found! Create one in ~/.config/nixpkgs/nix-on-droid.nix");

nodModules = import ./module-list.nix {
inherit pkgs home-manager-path isFlake targetSystem;
inherit pkgs home-manager-path isFlake targetSystem crossPkgs;
};

rawModule = evalModules {
Expand Down
17 changes: 6 additions & 11 deletions modules/environment/login/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.

{ config, lib, pkgs, initialPackageInfo, targetSystem, ... }:
{ config, lib, pkgs, initialPackageInfo, targetSystem, crossPkgs, ... }:

with lib;

Expand All @@ -12,6 +12,10 @@ let
loginInner = pkgs.callPackage ./login-inner.nix {
inherit config initialPackageInfo targetSystem;
};

tallocStatic = crossPkgs.pkgsStatic.pkgsLLVM.callPackage ../../../pkgs/talloc { };

prootStatic = crossPkgs.pkgsStatic.pkgsLLVM.callPackage ../../../pkgs/proot-termux { talloc = tallocStatic; };
in

{
Expand Down Expand Up @@ -82,16 +86,7 @@ in
};

environment.files = {
inherit login loginInner;

prootStatic =
let
crossCompiledPaths = {
aarch64-linux = "/nix/store/7qd99m1w65x2vgqg453nd70y60sm3kay-proot-termux-static-aarch64-unknown-linux-android-unstable-2024-05-04";
x86_64-linux = "/nix/store/pakj3svvw84rhkzdc6211yhc2cgvc21f-proot-termux-static-x86_64-unknown-linux-android-unstable-2024-05-04";
};
in
"${crossCompiledPaths.${targetSystem}}";
inherit login loginInner prootStatic;
};

};
Expand Down
3 changes: 3 additions & 0 deletions modules/environment/login/login-inner.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ writeText "login-inner" ''
# To prevent gc warnings of nix, see https://github.com/NixOS/nix/issues/3237
export GC_NPROCS=1

echo "Setting up Nix store..."
${nix}/bin/nix-store --init

echo "Setting default user profile..."
${nix}/bin/nix-env --switch-profile /nix/var/nix/profiles/per-user/$USER/profile

Expand Down
3 changes: 2 additions & 1 deletion modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, home-manager-path
, isFlake
, targetSystem # system to cross-compile to
, crossPkgs
}:

[
Expand Down Expand Up @@ -31,7 +32,7 @@
{
_file = ./module-list.nix;
_module.args = {
inherit home-manager-path isFlake targetSystem;
inherit home-manager-path isFlake targetSystem crossPkgs;
pkgs = pkgs.lib.mkDefault pkgs;
};
}
Expand Down
6 changes: 3 additions & 3 deletions pkgs/bootstrap.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.

{ runCommand, nixDirectory, prootTermux, bash, pkgs, config, initialPackageInfo }:
{ runCommand, closureInfo, prootTermux, bash, config, initialPackageInfo }:

runCommand "bootstrap" { } ''
mkdir --parents $out/{.l2s,bin,dev/shm,etc,root,tmp,usr/{bin,lib}}
mkdir --parents $out/nix/var/nix/{profiles,gcroots}/per-user/nix-on-droid

cp --recursive ${nixDirectory}/store $out/nix/store
cp --recursive ${nixDirectory}/var $out/nix/var
mkdir --parents $out/nix/store
cp --recursive $(cat ${closureInfo}/store-paths) $out/nix/store
chmod --recursive u+w $out/nix

ln --symbolic ${initialPackageInfo.bash}/bin/sh $out/bin/sh
Expand Down
15 changes: 0 additions & 15 deletions pkgs/cross-compiling/compiler-rt.patch

This file was deleted.

19 changes: 0 additions & 19 deletions pkgs/cross-compiling/cross-pkgs-args.nix

This file was deleted.

18 changes: 0 additions & 18 deletions pkgs/cross-compiling/cross-pkgs.nix

This file was deleted.

13 changes: 0 additions & 13 deletions pkgs/cross-compiling/libunwind.patch

This file was deleted.

13 changes: 0 additions & 13 deletions pkgs/cross-compiling/proot-termux.nix

This file was deleted.

28 changes: 15 additions & 13 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.

{ nixpkgs
, system # system to compile for, user-facing name of targetSystem
, _nativeSystem ? null # system to cross-compile from, see flake.nix
{ pkgs
, crossPkgs
, targetPkgs
, nixOnDroidChannelURL ? null
, nixpkgsChannelURL ? null
, nixOnDroidFlakeURL ? null
}:

let
nativeSystem = if _nativeSystem == null then system else _nativeSystem;
nixDirectory = callPackage ./nix-directory.nix { inherit system; };
initialPackageInfo = import "${nixDirectory}/nix-support/package-info.nix";
targetSystem = crossPkgs.stdenv.hostPlatform.system;

pkgs = import nixpkgs { system = nativeSystem; };
# Use prebuilt bootstrap packages from nixpkgs cache
closureInfo = pkgs.closureInfo {
rootPaths = with targetPkgs; [ bash cacert nix ];
};
initialPackageInfo = {
inherit (targetPkgs) bash nix;
cacert = "${targetPkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
};

urlOptionValue = url: envVar:
let
Expand All @@ -24,8 +29,7 @@ let
(if url == null then envValue else url);

modules = import ../modules {
inherit pkgs;
targetSystem = system;
inherit pkgs crossPkgs targetSystem;

isFlake = true;

Expand Down Expand Up @@ -56,16 +60,14 @@ let
callPackage = pkgs.lib.callPackageWith (
pkgs // customPkgs // {
inherit (modules) config;
inherit callPackage nixpkgs nixDirectory initialPackageInfo;
targetSystem = system;
inherit callPackage closureInfo initialPackageInfo targetSystem;
}
);

customPkgs = {
bootstrap = callPackage ./bootstrap.nix { };
bootstrapZip = callPackage ./bootstrap-zip.nix { };
prootTermux = callPackage ./cross-compiling/proot-termux.nix { };
tallocStatic = callPackage ./cross-compiling/talloc-static.nix { };
prootTermux = modules.config.environment.files.prootStatic;
};
in

Expand Down
Loading
Loading