mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
This means that the cachix substituter (or already having the package in your nix store somehow) is no longer required to build. This required reworking the deploy script. As a bonus you can now omit the second argument and it will tell you what it would have copied instead of copying anything. This is fixes one source of impurity, but for now flake builds will still require the --impure flag
112 lines
3.4 KiB
Nix
112 lines
3.4 KiB
Nix
# Copyright (c) 2019-2024, see AUTHORS. Licensed under MIT License, see LICENSE.
|
|
|
|
{ config, lib, pkgs, initialPackageInfo, targetSystem, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.environment.files;
|
|
|
|
login = pkgs.callPackage ./login.nix { inherit config; };
|
|
|
|
loginInner = pkgs.callPackage ./login-inner.nix {
|
|
inherit config initialPackageInfo targetSystem;
|
|
};
|
|
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;
|
|
# not readOnly, this needs to be overridden when building bootstrap zip
|
|
internal = true;
|
|
description = "<literal>proot-static</literal> 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;
|
|
|
|
# Ideally this would build the static proot binary, but doing that on aarch64 is HARD so instead pull it from the bootstrap tarball
|
|
prootStatic =
|
|
let
|
|
attrs = (import ./proot-attrs).${targetSystem};
|
|
prootFile = pkgs.fetchurl {
|
|
name = "proot-static-file";
|
|
inherit (attrs) url hash;
|
|
|
|
downloadToTemp = true;
|
|
executable = true;
|
|
postFetch = ''
|
|
${pkgs.unzip}/bin/unzip -u $downloadedFile bin/proot-static
|
|
echo $PWD >&2
|
|
mv bin/proot-static $out
|
|
'';
|
|
};
|
|
in
|
|
pkgs.runCommand "proot-static" { } ''
|
|
mkdir -p $out/bin
|
|
cp ${prootFile} $out/bin/proot-static
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
}
|