mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 19:46:07 +01:00
modules, ...: get rid of config.build.arch
This commit is contained in:
parent
54a535b91b
commit
45fcd2da39
15 changed files with 67 additions and 54 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
`pkgs = import nixpkgs { system = "aarch64-linux"; };`
|
`pkgs = import nixpkgs { system = "aarch64-linux"; };`
|
||||||
as an argument to `nixOnDroidConfiguration`.
|
as an argument to `nixOnDroidConfiguration`.
|
||||||
If in doubt, refer to the `templates`.
|
If in doubt, refer to the `templates`.
|
||||||
|
* `config.arch` option has been dropped. Consider using `pkgs.system` instead.
|
||||||
|
|
||||||
## Release 23.11
|
## Release 23.11
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (c) 2019-2023, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ pkgs, home-manager, nmdSrc }:
|
{ pkgs, home-manager, nmdSrc }:
|
||||||
|
|
||||||
|
|
@ -18,6 +18,7 @@ let
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
home-manager-path = home-manager.outPath;
|
home-manager-path = home-manager.outPath;
|
||||||
isFlake = true;
|
isFlake = true;
|
||||||
|
targetSystem = "aarch64-linux/x86_64-linux";
|
||||||
};
|
};
|
||||||
|
|
||||||
modulesDocs = nmd.buildModulesDocs {
|
modulesDocs = nmd.buildModulesDocs {
|
||||||
|
|
|
||||||
|
|
@ -99,10 +99,9 @@
|
||||||
See the 22.11 release notes for more.
|
See the 22.11 release notes for more.
|
||||||
''
|
''
|
||||||
(import ./modules {
|
(import ./modules {
|
||||||
|
targetSystem = pkgs.system; # system to cross-compile to
|
||||||
inherit extraSpecialArgs home-manager-path pkgs;
|
inherit extraSpecialArgs home-manager-path pkgs;
|
||||||
config.imports = modules;
|
config.imports = modules;
|
||||||
config.build.arch =
|
|
||||||
nixpkgs.lib.strings.removeSuffix "-linux" pkgs.system;
|
|
||||||
isFlake = true;
|
isFlake = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -118,7 +117,8 @@
|
||||||
derivationAttrset;
|
derivationAttrset;
|
||||||
perArchCustomPkgs = arch: flattenArch arch
|
perArchCustomPkgs = arch: flattenArch arch
|
||||||
(import ./pkgs {
|
(import ./pkgs {
|
||||||
inherit system arch;
|
_nativeSystem = system; # system to cross-compile from
|
||||||
|
system = "${arch}-linux"; # system to cross-compile to
|
||||||
nixpkgs = nixpkgs-for-bootstrap;
|
nixpkgs = nixpkgs-for-bootstrap;
|
||||||
}).customPkgs;
|
}).customPkgs;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,6 @@ with lib;
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
build = {
|
build = {
|
||||||
arch = mkOption {
|
|
||||||
type = types.enum [ "aarch64" "x86_64" ];
|
|
||||||
default = strings.removeSuffix "-linux" builtins.currentSystem;
|
|
||||||
internal = true;
|
|
||||||
description = "Destination arch.";
|
|
||||||
};
|
|
||||||
|
|
||||||
initialBuild = mkOption {
|
initialBuild = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ config ? null
|
{ targetSystem ? builtins.currentSystem # system to compile for
|
||||||
|
, config ? null
|
||||||
, extraSpecialArgs ? { }
|
, extraSpecialArgs ? { }
|
||||||
, pkgs ? import <nixpkgs> { }
|
, pkgs ? import <nixpkgs> { }
|
||||||
, home-manager-path ? <home-manager>
|
, home-manager-path ? <home-manager>
|
||||||
|
|
@ -17,7 +18,9 @@ let
|
||||||
else if builtins.pathExists defaultConfigFile then defaultConfigFile
|
else if builtins.pathExists defaultConfigFile then defaultConfigFile
|
||||||
else pkgs.config.nix-on-droid or (throw "No config file found! Create one in ~/.config/nixpkgs/nix-on-droid.nix");
|
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; };
|
nodModules = import ./module-list.nix {
|
||||||
|
inherit pkgs home-manager-path isFlake targetSystem;
|
||||||
|
};
|
||||||
|
|
||||||
rawModule = evalModules {
|
rawModule = evalModules {
|
||||||
modules = [ configModule ] ++ nodModules;
|
modules = [ configModule ] ++ nodModules;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ config, lib, pkgs, initialPackageInfo, ... }:
|
{ config, lib, pkgs, initialPackageInfo, targetSystem, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
|
@ -9,7 +9,9 @@ let
|
||||||
|
|
||||||
login = pkgs.callPackage ./login.nix { inherit config; };
|
login = pkgs.callPackage ./login.nix { inherit config; };
|
||||||
|
|
||||||
loginInner = pkgs.callPackage ./login-inner.nix { inherit config initialPackageInfo; };
|
loginInner = pkgs.callPackage ./login-inner.nix {
|
||||||
|
inherit config initialPackageInfo targetSystem;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -85,11 +87,11 @@ in
|
||||||
prootStatic =
|
prootStatic =
|
||||||
let
|
let
|
||||||
crossCompiledPaths = {
|
crossCompiledPaths = {
|
||||||
aarch64 = "/nix/store/7w09z1kw62wg7nv3q3z2p6kxf1ihk178-proot-termux-static-aarch64-unknown-linux-android-unstable-2023-11-11";
|
aarch64-linux = "/nix/store/7w09z1kw62wg7nv3q3z2p6kxf1ihk178-proot-termux-static-aarch64-unknown-linux-android-unstable-2023-11-11";
|
||||||
x86_64 = "/nix/store/i6jppi627sakbgm5x2a8jjdfyv8571zc-proot-termux-static-x86_64-unknown-linux-android-unstable-2023-11-11";
|
x86_64-linux = "/nix/store/i6jppi627sakbgm5x2a8jjdfyv8571zc-proot-termux-static-x86_64-unknown-linux-android-unstable-2023-11-11";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
"${crossCompiledPaths.${config.build.arch}}";
|
"${crossCompiledPaths.${targetSystem}}";
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ config, lib, initialPackageInfo, writeText }:
|
{ config, lib, initialPackageInfo, writeText, targetSystem }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (initialPackageInfo) cacert nix;
|
inherit (initialPackageInfo) cacert nix;
|
||||||
|
|
@ -80,15 +80,20 @@ writeText "login-inner" ''
|
||||||
${nixCmd} flake new ${config.user.home}/.config/nix-on-droid --template ${config.build.flake.nix-on-droid}
|
${nixCmd} flake new ${config.user.home}/.config/nix-on-droid --template ${config.build.flake.nix-on-droid}
|
||||||
|
|
||||||
${lib.optionalString config.build.flake.inputOverrides ''
|
${lib.optionalString config.build.flake.inputOverrides ''
|
||||||
echo "Overriding input urls / arch in flake..."
|
echo "Overriding input urls in the flake..."
|
||||||
${nixCmd} run nixpkgs#gnused -- \
|
${nixCmd} run nixpkgs#gnused -- \
|
||||||
-i \
|
-i \
|
||||||
-e 's,\"aarch64-linux",\"${config.build.arch}-linux\",' \
|
|
||||||
-e 's,\"github:NixOS/nixpkgs.*\",\"${config.build.flake.nixpkgs}\",' \
|
-e 's,\"github:NixOS/nixpkgs.*\",\"${config.build.flake.nixpkgs}\",' \
|
||||||
-e 's,\"github:nix-community/nix-on-droid.*\",\"${config.build.flake.nix-on-droid}\",' \
|
-e 's,\"github:nix-community/nix-on-droid.*\",\"${config.build.flake.nix-on-droid}\",' \
|
||||||
"${config.user.home}/.config/nix-on-droid/flake.nix"
|
"${config.user.home}/.config/nix-on-droid/flake.nix"
|
||||||
''}
|
''}
|
||||||
|
|
||||||
|
echo "Overriding system value in the flake..."
|
||||||
|
${nixCmd} run nixpkgs#gnused -- \
|
||||||
|
-i \
|
||||||
|
-e 's,\"aarch64-linux",\"${targetSystem}\",' \
|
||||||
|
"${config.user.home}/.config/nix-on-droid/flake.nix"
|
||||||
|
|
||||||
echo "Installing first Nix-on-Droid generation..."
|
echo "Installing first Nix-on-Droid generation..."
|
||||||
${nixCmd} run ${config.build.flake.nix-on-droid} -- switch --flake ${config.user.home}/.config/nix-on-droid
|
${nixCmd} run ${config.build.flake.nix-on-droid} -- switch --flake ${config.user.home}/.config/nix-on-droid
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ pkgs, home-manager-path, isFlake }:
|
{ pkgs
|
||||||
|
, home-manager-path
|
||||||
|
, isFlake
|
||||||
|
, targetSystem # system to cross-compile to
|
||||||
|
}:
|
||||||
|
|
||||||
[
|
[
|
||||||
./build/activation.nix
|
./build/activation.nix
|
||||||
|
|
@ -26,7 +30,7 @@
|
||||||
{
|
{
|
||||||
_file = ./module-list.nix;
|
_file = ./module-list.nix;
|
||||||
_module.args = {
|
_module.args = {
|
||||||
inherit home-manager-path isFlake;
|
inherit home-manager-path isFlake targetSystem;
|
||||||
pkgs = pkgs.lib.mkDefault pkgs;
|
pkgs = pkgs.lib.mkDefault pkgs;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ config, runCommand, zip, bootstrap }:
|
{ lib, runCommand, zip, bootstrap, targetSystem }:
|
||||||
|
|
||||||
|
let
|
||||||
|
arch = lib.strings.removeSuffix "-linux" targetSystem;
|
||||||
|
in
|
||||||
runCommand "bootstrap-zip" { } ''
|
runCommand "bootstrap-zip" { } ''
|
||||||
mkdir $out
|
mkdir $out
|
||||||
cd ${bootstrap}
|
cd ${bootstrap}
|
||||||
${zip}/bin/zip -q -9 -r $out/bootstrap-${config.build.arch} ./* ./.l2s
|
${zip}/bin/zip -q -9 -r $out/bootstrap-${arch} ./* ./.l2s
|
||||||
''
|
''
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ config, system }:
|
{ lib, config, system, targetSystem }:
|
||||||
|
|
||||||
|
let
|
||||||
|
arch = lib.strings.removeSuffix "-linux" targetSystem;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
||||||
crossSystem = {
|
crossSystem = {
|
||||||
config = "${config.build.arch}-unknown-linux-android";
|
config = "${arch}-unknown-linux-android";
|
||||||
sdkVer = "32";
|
sdkVer = "32";
|
||||||
libc = "bionic";
|
libc = "bionic";
|
||||||
useAndroidPrebuilt = false;
|
useAndroidPrebuilt = false;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ callPackage, nixpkgs, system }:
|
{ callPackage, nixpkgs }:
|
||||||
|
|
||||||
let
|
let
|
||||||
args = callPackage ./cross-pkgs-args.nix { };
|
args = callPackage ./cross-pkgs-args.nix { };
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ nixpkgs
|
{ nixpkgs
|
||||||
, system
|
, system # system to compile for, user-facing name of targetSystem
|
||||||
, arch ? "aarch64"
|
, _nativeSystem ? null # system to cross-compile from, see flake.nix
|
||||||
, nixOnDroidChannelURL ? null
|
, nixOnDroidChannelURL ? null
|
||||||
, nixpkgsChannelURL ? null
|
, nixpkgsChannelURL ? null
|
||||||
, nixOnDroidFlakeURL ? null
|
, nixOnDroidFlakeURL ? null
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
nixDirectory = callPackage ./nix-directory.nix { };
|
nativeSystem = if _nativeSystem == null then system else _nativeSystem;
|
||||||
|
nixDirectory = callPackage ./nix-directory.nix { inherit system; };
|
||||||
initialPackageInfo = import "${nixDirectory}/nix-support/package-info.nix";
|
initialPackageInfo = import "${nixDirectory}/nix-support/package-info.nix";
|
||||||
|
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { system = nativeSystem; };
|
||||||
|
|
||||||
urlOptionValue = url: envVar:
|
urlOptionValue = url: envVar:
|
||||||
let
|
let
|
||||||
|
|
@ -24,6 +25,7 @@ let
|
||||||
|
|
||||||
modules = import ../modules {
|
modules = import ../modules {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
|
targetSystem = system;
|
||||||
|
|
||||||
isFlake = true;
|
isFlake = true;
|
||||||
|
|
||||||
|
|
@ -41,11 +43,6 @@ let
|
||||||
user.shell = "${initialPackageInfo.bash}/bin/bash";
|
user.shell = "${initialPackageInfo.bash}/bin/bash";
|
||||||
|
|
||||||
build = {
|
build = {
|
||||||
arch =
|
|
||||||
if arch != null
|
|
||||||
then arch
|
|
||||||
else nixpkgs.lib.strings.removeSuffix "-linux" builtins.currentSystem;
|
|
||||||
|
|
||||||
channel = {
|
channel = {
|
||||||
nixpkgs = urlOptionValue nixpkgsChannelURL "NIXPKGS_CHANNEL_URL";
|
nixpkgs = urlOptionValue nixpkgsChannelURL "NIXPKGS_CHANNEL_URL";
|
||||||
nix-on-droid = urlOptionValue nixOnDroidChannelURL "NIX_ON_DROID_CHANNEL_URL";
|
nix-on-droid = urlOptionValue nixOnDroidChannelURL "NIX_ON_DROID_CHANNEL_URL";
|
||||||
|
|
@ -60,6 +57,7 @@ let
|
||||||
pkgs // customPkgs // {
|
pkgs // customPkgs // {
|
||||||
inherit (modules) config;
|
inherit (modules) config;
|
||||||
inherit callPackage nixpkgs nixDirectory initialPackageInfo;
|
inherit callPackage nixpkgs nixDirectory initialPackageInfo;
|
||||||
|
targetSystem = system;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
||||||
|
|
||||||
{ config, lib, stdenv, closureInfo, prootTermux, proot, pkgsStatic }:
|
{ config, lib, stdenv, closureInfo, prootTermux, proot, pkgsStatic, system }:
|
||||||
|
|
||||||
let
|
let
|
||||||
buildRootDirectory = "root-directory";
|
buildRootDirectory = "root-directory";
|
||||||
|
|
@ -24,15 +24,15 @@ stdenv.mkDerivation {
|
||||||
name = "nix-directory";
|
name = "nix-directory";
|
||||||
|
|
||||||
src = builtins.fetchurl {
|
src = builtins.fetchurl {
|
||||||
url = "https://nixos.org/releases/nix/nix-2.20.5/nix-2.20.5-${config.build.arch}-linux.tar.xz";
|
url = "https://nixos.org/releases/nix/nix-2.20.5/nix-2.20.5-${system}.tar.xz";
|
||||||
sha256 =
|
sha256 =
|
||||||
let
|
let
|
||||||
archShas = {
|
nixShas = {
|
||||||
aarch64 = "sha256:168wjfj3xsc8hq1y6cq59iipjp1g9hmj4n5wdn9c47ad9gbc9cvh";
|
aarch64-linux = "sha256:168wjfj3xsc8hq1y6cq59iipjp1g9hmj4n5wdn9c47ad9gbc9cvh";
|
||||||
x86_64 = "sha256:0dax9n562ldj53ap6lz0cwwsfx4d8j1267g9s6lg3zs237yyzw61";
|
x86_64-linux = "sha256:0dax9n562ldj53ap6lz0cwwsfx4d8j1267g9s6lg3zs237yyzw61";
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
archShas.${config.build.arch};
|
nixShas.${system};
|
||||||
};
|
};
|
||||||
|
|
||||||
PROOT_NO_SECCOMP = 1; # see https://github.com/proot-me/PRoot/issues/106
|
PROOT_NO_SECCOMP = 1; # see https://github.com/proot-me/PRoot/issues/106
|
||||||
|
|
|
||||||
|
|
@ -61,14 +61,14 @@ for arch in $ARCHES; do
|
||||||
log "building $arch proot..."
|
log "building $arch proot..."
|
||||||
proot="$(nix build --no-link --print-out-paths ".#prootTermux-${arch}")"
|
proot="$(nix build --no-link --print-out-paths ".#prootTermux-${arch}")"
|
||||||
|
|
||||||
if grep -q "$arch = \"$proot\";" "$PROOT_HASH_FILE"; then
|
if grep -q "$arch-linux = \"$proot\";" "$PROOT_HASH_FILE"; then
|
||||||
log "keeping $arch proot path in $PROOT_HASH_FILE"
|
log "keeping $arch proot path in $PROOT_HASH_FILE"
|
||||||
elif grep -q "$arch = \"/nix/store/" "$PROOT_HASH_FILE"; then
|
elif grep -q "$arch-linux = \"/nix/store/" "$PROOT_HASH_FILE"; then
|
||||||
log "patching $arch proot path in $PROOT_HASH_FILE..."
|
log "patching $arch proot path in $PROOT_HASH_FILE..."
|
||||||
grep "$arch = \"/nix/store/" "$PROOT_HASH_FILE"
|
grep "$arch-linux = \"/nix/store/" "$PROOT_HASH_FILE"
|
||||||
sed -i "s|$arch = \"/nix/store/.*\";|$arch = \"$proot\";|" "$PROOT_HASH_FILE"
|
sed -i "s|$arch-linux = \"/nix/store/.*\";|$arch-linux = \"$proot\";|" "$PROOT_HASH_FILE"
|
||||||
log " ->"
|
log " ->"
|
||||||
grep "$arch = \"/nix/store/" "$PROOT_HASH_FILE"
|
grep "$arch-linux = \"/nix/store/" "$PROOT_HASH_FILE"
|
||||||
else
|
else
|
||||||
log "no $arch proot hash found in $PROOT_HASH_FILE!"
|
log "no $arch proot hash found in $PROOT_HASH_FILE!"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ def run(d):
|
||||||
wait_for(d, 'Setting up Nix-on-Droid with flakes...')
|
wait_for(d, 'Setting up Nix-on-Droid with flakes...')
|
||||||
|
|
||||||
wait_for(d, 'Installing flake from default template...')
|
wait_for(d, 'Installing flake from default template...')
|
||||||
wait_for(d, 'Overriding input urls / arch in flake...')
|
wait_for(d, 'Overriding system value in the flake...', timeout=600)
|
||||||
wait_for(d, 'Installing first Nix-on-Droid generation...', timeout=600)
|
wait_for(d, 'Installing first Nix-on-Droid generation...')
|
||||||
wait_for(d, 'Building activation package')
|
wait_for(d, 'Building activation package', timeout=180)
|
||||||
wait_for(d, 'Congratulations!', timeout=900)
|
wait_for(d, 'Congratulations!', timeout=900)
|
||||||
wait_for(d, 'bash-5.2$')
|
wait_for(d, 'bash-5.2$')
|
||||||
screenshot(d, 'bootstrap-ends')
|
screenshot(d, 'bootstrap-ends')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue