mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
add x86_64 arch
This commit is contained in:
parent
463e0f82a6
commit
d72ab2a167
17 changed files with 89 additions and 40 deletions
2
.github/workflows/cachix.yml
vendored
2
.github/workflows/cachix.yml
vendored
|
|
@ -27,5 +27,5 @@ jobs:
|
|||
--log-format bar-with-logs \
|
||||
--option keep-going true \
|
||||
--show-trace \
|
||||
build .#bootstrapZip \
|
||||
build .#bootstrapZip-aarch64 .#bootstrapZip-x86_64 \
|
||||
--impure
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ Get an x86_64 computer with flake-enabled Nix.
|
|||
Run
|
||||
|
||||
```sh
|
||||
nix build ".#bootstrapZip" --impure
|
||||
nix build ".#bootstrapZip-aarch64" --impure
|
||||
```
|
||||
|
||||
Put the zip file from `result` on some HTTP server
|
||||
|
|
@ -192,6 +192,7 @@ A minimal example could look like the following:
|
|||
outputs = { self, nixpkgs, nix-on-droid }: {
|
||||
|
||||
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
system = "aarch64-linux";
|
||||
modules = [ ./nix-on-droid.nix ];
|
||||
};
|
||||
|
||||
|
|
|
|||
32
flake.nix
32
flake.nix
|
|
@ -33,8 +33,8 @@
|
|||
|
||||
overlay = nixpkgs.lib.composeManyExtensions (import ./overlays);
|
||||
|
||||
pkgs' = import nixpkgs {
|
||||
system = "aarch64-linux";
|
||||
pkgsPerSystem = system: import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ overlay ];
|
||||
};
|
||||
|
||||
|
|
@ -75,16 +75,18 @@
|
|||
|
||||
lib.nixOnDroidConfiguration =
|
||||
{ modules ? [ ]
|
||||
, system ? "aarch64-linux"
|
||||
, extraSpecialArgs ? { }
|
||||
, pkgs ? pkgs'
|
||||
, pkgs ? pkgsPerSystem system
|
||||
, home-manager-path ? home-manager.outPath
|
||||
# deprecated:
|
||||
, config ? null
|
||||
, extraModules ? null
|
||||
, system ? null
|
||||
}:
|
||||
if pkgs.system != "aarch64-linux" then
|
||||
throw "aarch64-linux is the only currently supported system type"
|
||||
if ! (builtins.elem system [ "aarch64-linux" "x86_64-linux" ]) then
|
||||
throw
|
||||
("${system} is not supported; aarch64-linux / x86_64-linux " +
|
||||
"are the only currently supported system types")
|
||||
else
|
||||
pkgs.lib.throwIf
|
||||
(config != null || extraModules != null)
|
||||
|
|
@ -102,6 +104,8 @@
|
|||
(import ./modules {
|
||||
inherit extraSpecialArgs home-manager-path pkgs;
|
||||
config.imports = modules;
|
||||
config.build.arch =
|
||||
nixpkgs.lib.strings.removeSuffix "-linux" system;
|
||||
isFlake = true;
|
||||
});
|
||||
|
||||
|
|
@ -109,10 +113,17 @@
|
|||
|
||||
packages = forEachSystem (system:
|
||||
let
|
||||
nixOnDroidPkgs = import ./pkgs {
|
||||
inherit system;
|
||||
flattenArch = arch: derivationAttrset:
|
||||
nixpkgs.lib.attrsets.mapAttrs'
|
||||
(name: drv:
|
||||
nixpkgs.lib.attrsets.nameValuePair (name + "-" + arch) drv
|
||||
)
|
||||
derivationAttrset;
|
||||
perArchCustomPkgs = arch: flattenArch arch
|
||||
(import ./pkgs {
|
||||
inherit system arch;
|
||||
nixpkgs = nixpkgs-for-bootstrap;
|
||||
};
|
||||
}).customPkgs;
|
||||
|
||||
docs = import ./docs {
|
||||
inherit home-manager;
|
||||
|
|
@ -123,7 +134,8 @@
|
|||
{
|
||||
nix-on-droid = nixpkgs.legacyPackages.${system}.callPackage ./nix-on-droid { };
|
||||
}
|
||||
// nixOnDroidPkgs.customPkgs
|
||||
// (perArchCustomPkgs "aarch64")
|
||||
// (perArchCustomPkgs "x86_64")
|
||||
// docs
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
|
|
@ -12,8 +12,8 @@ with lib;
|
|||
|
||||
build = {
|
||||
arch = mkOption {
|
||||
type = types.enum [ "aarch64" ];
|
||||
default = "aarch64";
|
||||
type = types.enum [ "aarch64" "x86_64" ];
|
||||
default = strings.removeSuffix "-linux" builtins.currentSystem;
|
||||
internal = true;
|
||||
description = "Destination arch.";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
{ config, lib, pkgs, initialPackageInfo, ... }:
|
||||
|
||||
|
|
@ -82,7 +82,14 @@ in
|
|||
environment.files = {
|
||||
inherit login loginInner;
|
||||
|
||||
prootStatic = "/nix/store/7w09z1kw62wg7nv3q3z2p6kxf1ihk178-proot-termux-static-aarch64-unknown-linux-android-unstable-2023-11-11";
|
||||
prootStatic =
|
||||
let
|
||||
crossCompiledPaths = {
|
||||
aarch64 = "/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";
|
||||
};
|
||||
in
|
||||
"${crossCompiledPaths.${config.build.arch}}";
|
||||
};
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
{ config, lib, initialPackageInfo, writeText }:
|
||||
|
||||
|
|
@ -80,9 +80,10 @@ writeText "login-inner" ''
|
|||
${nixCmd} flake new ${config.user.home}/.config/nix-on-droid --template ${config.build.flake.nix-on-droid}
|
||||
|
||||
${lib.optionalString config.build.flake.inputOverrides ''
|
||||
echo "Overriding input urls in flake..."
|
||||
echo "Overriding input urls / arch in flake..."
|
||||
${nixCmd} run nixpkgs#gnused -- \
|
||||
-i \
|
||||
-e 's,\"aarch64-linux",\"${config.build.arch}-linux\",' \
|
||||
-e 's,\"github:NixOS/nixpkgs.*\",\"${config.build.flake.nixpkgs}\",' \
|
||||
-e 's,\"github:nix-community/nix-on-droid.*\",\"${config.build.flake.nix-on-droid}\",' \
|
||||
"${config.user.home}/.config/nix-on-droid/flake.nix"
|
||||
|
|
|
|||
|
|
@ -41,7 +41,10 @@ let
|
|||
user.shell = "${initialPackageInfo.bash}/bin/bash";
|
||||
|
||||
build = {
|
||||
inherit arch;
|
||||
arch =
|
||||
if arch != null
|
||||
then arch
|
||||
else nixpkgs.lib.strings.removeSuffix "-linux" builtins.currentSystem;
|
||||
|
||||
channel = {
|
||||
nixpkgs = urlOptionValue nixpkgsChannelURL "NIXPKGS_CHANNEL_URL";
|
||||
|
|
|
|||
|
|
@ -25,7 +25,14 @@ stdenv.mkDerivation {
|
|||
|
||||
src = builtins.fetchurl {
|
||||
url = "https://nixos.org/releases/nix/nix-2.20.5/nix-2.20.5-${config.build.arch}-linux.tar.xz";
|
||||
sha256 = "sha256:168wjfj3xsc8hq1y6cq59iipjp1g9hmj4n5wdn9c47ad9gbc9cvh";
|
||||
sha256 =
|
||||
let
|
||||
archShas = {
|
||||
aarch64 = "sha256:168wjfj3xsc8hq1y6cq59iipjp1g9hmj4n5wdn9c47ad9gbc9cvh";
|
||||
x86_64 = "sha256:0dax9n562ldj53ap6lz0cwwsfx4d8j1267g9s6lg3zs237yyzw61";
|
||||
};
|
||||
in
|
||||
archShas.${config.build.arch};
|
||||
};
|
||||
|
||||
PROOT_NO_SECCOMP = 1; # see https://github.com/proot-me/PRoot/issues/106
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ fi
|
|||
|
||||
PUBLIC_URL="$1"
|
||||
RSYNC_TARGET="$2"
|
||||
: ${ARCHES:=aarch64 x86_64}
|
||||
|
||||
# this allows to run this script from every place in this git repo
|
||||
REPO_DIR="$(git rev-parse --show-toplevel)"
|
||||
|
|
@ -54,27 +55,35 @@ log "NIX_ON_DROID_CHANNEL_URL=$NIX_ON_DROID_CHANNEL_URL"
|
|||
log "NIX_ON_DROID_FLAKE_URL=$NIX_ON_DROID_FLAKE_URL"
|
||||
|
||||
|
||||
log "building proot..."
|
||||
PROOT="$(nix build --no-link --print-out-paths ".#prootTermux")"
|
||||
|
||||
|
||||
PROOT_HASH_FILE="modules/environment/login/default.nix"
|
||||
log "patching proot path in $PROOT_HASH_FILE..."
|
||||
grep "prootStatic = \"/nix/store/" "$PROOT_HASH_FILE"
|
||||
sed -i "s|prootStatic = \"/nix/store/.*\";|prootStatic = \"$PROOT\";|" "$PROOT_HASH_FILE"
|
||||
grep "prootStatic = \"/nix/store/" "$PROOT_HASH_FILE"
|
||||
UPLOADS=()
|
||||
for arch in $ARCHES; do
|
||||
log "building $arch proot..."
|
||||
proot="$(nix build --no-link --print-out-paths ".#prootTermux-${arch}")"
|
||||
|
||||
if grep -q "$arch = \"$proot\";" "$PROOT_HASH_FILE"; then
|
||||
log "keeping $arch proot path in $PROOT_HASH_FILE"
|
||||
elif grep -q "$arch = \"/nix/store/" "$PROOT_HASH_FILE"; then
|
||||
log "patching $arch proot path in $PROOT_HASH_FILE..."
|
||||
grep "$arch = \"/nix/store/" "$PROOT_HASH_FILE"
|
||||
sed -i "s|$arch = \"/nix/store/.*\";|$arch = \"$proot\";|" "$PROOT_HASH_FILE"
|
||||
log " ->"
|
||||
grep "$arch = \"/nix/store/" "$PROOT_HASH_FILE"
|
||||
else
|
||||
log "no $arch proot hash found in $PROOT_HASH_FILE!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "building bootstrapZip..."
|
||||
BOOTSTRAP_ZIP="$(nix build --no-link --print-out-paths --impure ".#bootstrapZip")"
|
||||
log "building $arch bootstrapZip..."
|
||||
BOOTSTRAP_ZIP="$(nix build --no-link --print-out-paths --impure ".#bootstrapZip-${arch}")"
|
||||
UPLOADS+=($BOOTSTRAP_ZIP/bootstrap-$arch.zip)
|
||||
done
|
||||
|
||||
|
||||
log "creating tar ball of current HEAD..."
|
||||
git archive --prefix nix-on-droid/ --output "$SOURCE_FILE" HEAD
|
||||
UPLOADS+=($SOURCE_FILE)
|
||||
|
||||
|
||||
log "uploading artifacts..."
|
||||
rsync --progress \
|
||||
"$SOURCE_FILE" \
|
||||
"$BOOTSTRAP_ZIP/bootstrap-aarch64.zip" \
|
||||
"$RSYNC_TARGET"
|
||||
rsync --progress "${UPLOADS[@]}" "$RSYNC_TARGET"
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
outputs = { self, nixpkgs, nix-on-droid }: {
|
||||
|
||||
nixOnDroidConfigurations.default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
system = "aarch64-linux";
|
||||
modules = [ ./nix-on-droid.nix ];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
outputs = { nix-on-droid, ... }: {
|
||||
nixOnDroidConfigurations = {
|
||||
default = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
system = "<<SYSTEM>>";
|
||||
modules = [ ./nix-on-droid.nix ];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ load lib
|
|||
# set up / build / activate the configuration
|
||||
cat "$ON_DEVICE_TESTS_DIR/config-flake-h-m.cfg.nix" \
|
||||
> ~/.config/nixpkgs/nix-on-droid.nix
|
||||
_sed "s|<<FLAKE_URL>>|$FLAKE_URL|g" \
|
||||
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
|
||||
"$ON_DEVICE_TESTS_DIR/config-flake-h-m.flake.nix" \
|
||||
> ~/.config/nixpkgs/flake.nix
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
outputs = { nix-on-droid, ... }: {
|
||||
nixOnDroidConfigurations = {
|
||||
device = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
system = "<<SYSTEM>>";
|
||||
modules = [ ./nix-on-droid.nix ];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ load lib
|
|||
# set up / build / activate the configuration
|
||||
cat "$ON_DEVICE_TESTS_DIR/config-flake-hosts.cfg.nix" \
|
||||
> ~/.config/nixpkgs/nix-on-droid.nix
|
||||
_sed "s|<<FLAKE_URL>>|$FLAKE_URL|g" \
|
||||
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
|
||||
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
|
||||
> ~/.config/nixpkgs/flake.nix
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ load lib
|
|||
# set up / build / activate the configuration
|
||||
cat "$ON_DEVICE_TESTS_DIR/config-flake-hosts-localhost.cfg.nix" \
|
||||
> ~/.config/nixpkgs/nix-on-droid.nix
|
||||
_sed "s|<<FLAKE_URL>>|$FLAKE_URL|g" \
|
||||
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
|
||||
"$ON_DEVICE_TESTS_DIR/config-flake.nix" \
|
||||
> ~/.config/nixpkgs/flake.nix
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ function flake_example() {
|
|||
"$CHANNEL_DIR/modules/environment/login/nix-on-droid.nix.default" \
|
||||
> ~/.config/nixpkgs/nix-on-droid.nix
|
||||
|
||||
_sed "s|<<FLAKE_URL>>|$FLAKE_URL|g" \
|
||||
_sed -e "s|<<FLAKE_URL>>|$FLAKE_URL|g" -e "s|<<SYSTEM>>|$(detect_system)|g" \
|
||||
"$ON_DEVICE_TESTS_DIR/$flake_file_name" \
|
||||
> ~/.config/nixpkgs/flake.nix
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
outputs = { nix-on-droid, ... }: {
|
||||
nixOnDroidConfigurations = {
|
||||
device = nix-on-droid.lib.nixOnDroidConfiguration {
|
||||
system = "<<SYSTEM>>";
|
||||
modules = [ ./nix-on-droid.nix ];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -71,3 +71,8 @@ _diff() {
|
|||
storePath="$(nix-build "<nixpkgs>" --no-out-link --attr diffutils)"
|
||||
"${storePath}/bin/diff" "$@"
|
||||
}
|
||||
|
||||
detect_system() {
|
||||
nix --experimental-features nix-command \
|
||||
eval --impure --raw --expr 'builtins.currentSystem'
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue