bootstrap: refactor special args to reduce inputs

This commit is contained in:
Tobias Happ 2022-09-24 13:43:49 +02:00
parent 2ef9a7faa2
commit b10dd78e18
4 changed files with 13 additions and 18 deletions

View file

@ -1,6 +1,6 @@
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ config, lib, pkgs, customPkgs, ... }: { config, lib, pkgs, initialPackageInfo, ... }:
with lib; with lib;
@ -9,7 +9,7 @@ let
login = pkgs.callPackage ./login.nix { inherit config; }; login = pkgs.callPackage ./login.nix { inherit config; };
loginInner = pkgs.callPackage ./login-inner.nix { inherit config customPkgs; }; loginInner = pkgs.callPackage ./login-inner.nix { inherit config initialPackageInfo; };
in in
{ {

View file

@ -1,9 +1,9 @@
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE. # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ config, lib, customPkgs, writeText }: { config, lib, initialPackageInfo, writeText }:
let let
inherit (customPkgs.packageInfo) cacert nix; inherit (initialPackageInfo) cacert nix;
in in
writeText "login-inner" '' writeText "login-inner" ''

View file

@ -1,10 +1,6 @@
# Copyright (c) 2019-2020, see AUTHORS. Licensed under MIT License, see LICENSE. # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ runCommand, nixDirectory, prootTermux, bash, pkgs, config }: { runCommand, nixDirectory, prootTermux, bash, pkgs, config, initialPackageInfo }:
let
packageInfo = import "${nixDirectory}/nix-support/package-info.nix";
in
runCommand "bootstrap" { } '' runCommand "bootstrap" { } ''
mkdir --parents $out/{.l2s,bin,dev/shm,etc,nix,root,tmp,usr/{bin,lib}} mkdir --parents $out/{.l2s,bin,dev/shm,etc,nix,root,tmp,usr/{bin,lib}}
@ -13,7 +9,7 @@ runCommand "bootstrap" { } ''
cp --recursive ${nixDirectory}/var $out/nix/var cp --recursive ${nixDirectory}/var $out/nix/var
chmod --recursive u+w $out/nix chmod --recursive u+w $out/nix
ln --symbolic ${packageInfo.bash}/bin/sh $out/bin/sh ln --symbolic ${initialPackageInfo.bash}/bin/sh $out/bin/sh
install -D -m 0755 ${prootTermux}/bin/proot-static $out/bin/proot-static install -D -m 0755 ${prootTermux}/bin/proot-static $out/bin/proot-static

View file

@ -1,10 +1,10 @@
# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE. # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ arch ? "aarch64", nixOnDroidChannelURL ? null, nixpkgsChannelURL ? null }: { arch ? "aarch64", nixOnDroidChannelURL ? null, nixpkgsChannelURL ? null }:
let let
nixDirectory = callPackage ./nix-directory.nix { }; nixDirectory = callPackage ./nix-directory.nix { };
packageInfo = import "${nixDirectory}/nix-support/package-info.nix"; initialPackageInfo = import "${nixDirectory}/nix-support/package-info.nix";
nixpkgs = import lib/load-nixpkgs.nix { }; nixpkgs = import lib/load-nixpkgs.nix { };
@ -13,13 +13,13 @@ let
extraModules = [ ../modules/build/initial-build.nix ]; extraModules = [ ../modules/build/initial-build.nix ];
extraSpecialArgs = { extraSpecialArgs = {
inherit customPkgs; inherit initialPackageInfo;
pkgs = nixpkgs.lib.mkForce nixpkgs; # to override ./modules/nixpkgs/config.nix pkgs = nixpkgs.lib.mkForce nixpkgs; # to override ./modules/nixpkgs/config.nix
}; };
config = { config = {
# Fix invoking bash after initial build. # Fix invoking bash after initial build.
user.shell = "${packageInfo.bash}/bin/bash"; user.shell = "${initialPackageInfo.bash}/bin/bash";
build = { build = {
inherit arch; inherit arch;
@ -35,12 +35,11 @@ let
callPackage = nixpkgs.lib.callPackageWith ( callPackage = nixpkgs.lib.callPackageWith (
nixpkgs // customPkgs // { nixpkgs // customPkgs // {
inherit (modules) config; inherit (modules) config;
inherit callPackage; inherit callPackage nixpkgs nixDirectory initialPackageInfo;
} }
); );
customPkgs = { customPkgs = {
inherit nixDirectory packageInfo;
bootstrap = callPackage ./bootstrap.nix { }; bootstrap = callPackage ./bootstrap.nix { };
bootstrapZip = callPackage ./bootstrap-zip.nix { }; bootstrapZip = callPackage ./bootstrap-zip.nix { };
prootTermux = callPackage ./cross-compiling/proot-termux.nix { }; prootTermux = callPackage ./cross-compiling/proot-termux.nix { };