bootstrap: use env vars to set custom channel urls

This commit is contained in:
Tobias Happ 2022-10-27 12:33:17 +02:00
parent bb8ac7fe1f
commit b01a2a8a57
2 changed files with 15 additions and 5 deletions

View file

@ -137,7 +137,9 @@ To re-trigger the installation, you can use
If you want to change the nix-on-droid channel to your custom one,
you can do that either with `nix-channel` after the installation,
or by using `--argstr nixOnDroidChannelURL <URL>`.
or by setting the environment variable `NIX_ON_DROID_CHANNEL_URL`.
Other environment variables are `NIXPKGS_CHANNEL_URL` an
`NIX_ON_DROID_FLAKE_URL`.
**Note**: The `proot` binary is not built on the android device
(NDK is required for building it, and it's not available on mobile platforms).

View file

@ -14,6 +14,14 @@ let
pkgs = import nixpkgs { inherit system; };
urlOptionValue = url: envVar:
let
envValue = builtins.getEnv envVar;
in
pkgs.lib.mkIf
(envValue != "" || url != null)
(if url == null then envValue else url);
modules = import ../modules {
inherit pkgs;
@ -29,15 +37,15 @@ let
# Fix invoking bash after initial build.
user.shell = "${initialPackageInfo.bash}/bin/bash";
build = with pkgs.lib; {
build = {
inherit arch;
channel = {
nixpkgs = mkIf (nixpkgsChannelURL != null) nixpkgsChannelURL;
nix-on-droid = mkIf (nixOnDroidChannelURL != null) nixOnDroidChannelURL;
nixpkgs = urlOptionValue nixpkgsChannelURL "NIXPKGS_CHANNEL_URL";
nix-on-droid = urlOptionValue nixOnDroidChannelURL "NIX_ON_DROID_CHANNEL_URL";
};
flake.nix-on-droid = mkIf (nixOnDroidFlakeURL != null) nixOnDroidFlakeURL;
flake.nix-on-droid = urlOptionValue nixOnDroidFlakeURL "NIX_ON_DROID_FLAKE_URL";
};
};
};