mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
97 lines
2.9 KiB
Nix
97 lines
2.9 KiB
Nix
# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE.
|
|
|
|
{ config, lib, pkgs, customPkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.environment.files;
|
|
|
|
login = pkgs.callPackage ./login.nix { inherit config; };
|
|
|
|
loginInner = pkgs.callPackage ./login-inner.nix { inherit config customPkgs; };
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
environment.files = {
|
|
login = mkOption {
|
|
type = types.package;
|
|
readOnly = true;
|
|
internal = true;
|
|
description = "Login script.";
|
|
};
|
|
|
|
loginInner = mkOption {
|
|
type = types.package;
|
|
readOnly = true;
|
|
internal = true;
|
|
description = "Login-inner script.";
|
|
};
|
|
|
|
prootStatic = mkOption {
|
|
type = types.package;
|
|
readOnly = true;
|
|
internal = true;
|
|
description = "proot-static package.";
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = {
|
|
|
|
build.activation = {
|
|
installLogin = ''
|
|
if ! diff /bin/login ${login} > /dev/null; then
|
|
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin
|
|
$DRY_RUN_CMD cp $VERBOSE_ARG ${login} /bin/.login.tmp
|
|
$DRY_RUN_CMD chmod $VERBOSE_ARG u+w /bin/.login.tmp
|
|
$DRY_RUN_CMD mv $VERBOSE_ARG /bin/.login.tmp /bin/login
|
|
fi
|
|
'';
|
|
|
|
installLoginInner = ''
|
|
if (test -e /usr/lib/.login-inner.new && ! diff /usr/lib/.login-inner.new ${loginInner} > /dev/null) || \
|
|
(! test -e /usr/lib/.login-inner.new && ! diff /usr/lib/login-inner ${loginInner} > /dev/null); then
|
|
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /usr/lib
|
|
$DRY_RUN_CMD cp $VERBOSE_ARG ${loginInner} /usr/lib/.login-inner.tmp
|
|
$DRY_RUN_CMD chmod $VERBOSE_ARG u+w /usr/lib/.login-inner.tmp
|
|
$DRY_RUN_CMD mv $VERBOSE_ARG /usr/lib/.login-inner.tmp /usr/lib/.login-inner.new
|
|
fi
|
|
'';
|
|
|
|
installProotStatic = ''
|
|
if (test -e /bin/.proot-static.new && ! diff /bin/.proot-static.new ${cfg.prootStatic}/bin/proot-static > /dev/null) || \
|
|
(! test -e /bin/.proot-static.new && ! diff /bin/proot-static ${cfg.prootStatic}/bin/proot-static > /dev/null); then
|
|
$DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin
|
|
$DRY_RUN_CMD cp $VERBOSE_ARG ${cfg.prootStatic}/bin/proot-static /bin/.proot-static.tmp
|
|
$DRY_RUN_CMD chmod $VERBOSE_ARG u+w /bin/.proot-static.tmp
|
|
$DRY_RUN_CMD mv $VERBOSE_ARG /bin/.proot-static.tmp /bin/.proot-static.new
|
|
fi
|
|
'';
|
|
};
|
|
|
|
environment.files = {
|
|
inherit login loginInner;
|
|
|
|
prootStatic =
|
|
let
|
|
crossCompiledPaths = {
|
|
aarch64 = "/nix/store/dapbgzbpl426jrhz4a2sdl096a8l98ad-proot-termux-aarch64-unknown-linux-android-unstable-2021-11-21";
|
|
i686 = "/nix/store/6nnjhrh8pgyxjnya72irahxpkbnxai1w-proot-termux-i686-unknown-linux-android-unstable-2021-11-21";
|
|
};
|
|
in
|
|
"${crossCompiledPaths.${config.build.arch}}";
|
|
};
|
|
|
|
};
|
|
|
|
}
|