bootstrap: flakify bootstrap zip ball generation

This commit is contained in:
Tobias Happ 2022-09-24 13:49:51 +02:00
parent b10dd78e18
commit 274bb4babd
8 changed files with 58 additions and 40 deletions

View file

@ -124,9 +124,10 @@ is probably not interesting for you, just download and use a prebuilt one.
If you really want to rebuild it, you can just use Android Studio for that. If you really want to rebuild it, you can just use Android Studio for that.
The zipball generation is probably what you are after. The zipball generation is probably what you are after.
Get an x86_64 computer with Nix. Run Get an x86_64 computer with flake-enabled Nix. Run
``` ```
nix build -f ./pkgs --argstr arch aarch64 bootstrapZip nix build .#bootstrapZip --impure
``` ```
Put the zip file from `result` on some HTTP server Put the zip file from `result` on some HTTP server

19
flake.lock generated
View file

@ -51,11 +51,28 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-for-bootstrap": {
"locked": {
"lastModified": 1656265786,
"narHash": "sha256-A9RkoGrxzsmMm0vily18p92Rasb+MbdDMaSnzmywXKw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cd90e773eae83ba7733d2377b6cdf84d45558780",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cd90e773eae83ba7733d2377b6cdf84d45558780",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs",
"nixpkgs-for-bootstrap": "nixpkgs-for-bootstrap"
} }
}, },
"utils": { "utils": {

View file

@ -3,14 +3,21 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs"; nixpkgs.url = "github:NixOS/nixpkgs";
# for bootstrap zip ball creation and proot-termux builds, we use a fixed version of nixpkgs to ease maintanence.
# head of nixos-22.05 as of 2022-06-27
# note: when updating nixpkgs-for-bootstrap, update store paths of proot-termux in modules/environment/login/default.nix
nixpkgs-for-bootstrap.url = "github:NixOS/nixpkgs/cd90e773eae83ba7733d2377b6cdf84d45558780";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
}; };
outputs = { self, nixpkgs, home-manager, flake-utils }: outputs = { self, nixpkgs, nixpkgs-for-bootstrap, home-manager, flake-utils }:
let let
overlay = nixpkgs.lib.composeManyExtensions (import ./overlays); overlay = nixpkgs.lib.composeManyExtensions (import ./overlays);
@ -47,7 +54,12 @@
nix-on-droid = app; nix-on-droid = app;
}; };
} }
// flake-utils.lib.eachDefaultSystem (system: { // flake-utils.lib.eachSystem [ "aarch64-linux" "i686-linux" "x86_64-darwin" "x86_64-linux" ] (system: {
formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt;
packages = import ./pkgs {
inherit system;
nixpkgs = nixpkgs-for-bootstrap;
};
}); });
} }

View file

@ -1,9 +1,9 @@
# 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 }: { config, nixpkgs, system }:
let {
loadNixpkgs = import ../lib/load-nixpkgs.nix; inherit system;
crossSystem = { crossSystem = {
config = "${config.build.arch}-unknown-linux-android"; config = "${config.build.arch}-unknown-linux-android";
@ -13,7 +13,4 @@ let
useLLVM = true; useLLVM = true;
isStatic = true; isStatic = true;
}; };
}
in
loadNixpkgs { inherit crossSystem; }

View file

@ -1,12 +1,12 @@
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ callPackage, tallocStatic }: { callPackage, nixpkgs, tallocStatic }:
let let
pkgsCross = callPackage ./cross-pkgs.nix { }; pkgsCross = import nixpkgs (callPackage ./cross-pkgs-args.nix { });
stdenv = pkgsCross.stdenvAdapters.makeStaticBinaries pkgsCross.stdenv; stdenv = pkgsCross.stdenvAdapters.makeStaticBinaries pkgsCross.stdenv;
in in
pkgsCross.callPackage ../proot-termux { pkgsCross.callPackage ../proot-termux {
talloc = tallocStatic; talloc = tallocStatic;
inherit stdenv; inherit stdenv;

View file

@ -1,6 +1,7 @@
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE. # Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
{ callPackage { callPackage
, nixpkgs
, fetchurl , fetchurl
, python3 , python3
, pkg-config , pkg-config
@ -8,7 +9,7 @@
}: }:
let let
pkgsCross = callPackage ./cross-pkgs.nix { }; pkgsCross = import nixpkgs (callPackage ./cross-pkgs-args.nix { });
in in
pkgsCross.stdenv.mkDerivation rec { pkgsCross.stdenv.mkDerivation rec {

View file

@ -1,22 +1,29 @@
# Copyright (c) 2019-2022, 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 }: { nixpkgs
, system
, arch ? "aarch64"
, nixOnDroidChannelURL ? null
, nixpkgsChannelURL ? null
}:
let let
nixDirectory = callPackage ./nix-directory.nix { }; nixDirectory = callPackage ./nix-directory.nix { };
initialPackageInfo = import "${nixDirectory}/nix-support/package-info.nix"; initialPackageInfo = import "${nixDirectory}/nix-support/package-info.nix";
nixpkgs = import lib/load-nixpkgs.nix { }; pkgs = import nixpkgs { inherit system; };
modules = import ../modules { modules = import ../modules {
pkgs = nixpkgs; inherit pkgs;
extraModules = [ ../modules/build/initial-build.nix ]; extraModules = [ ../modules/build/initial-build.nix ];
extraSpecialArgs = { extraSpecialArgs = {
inherit initialPackageInfo; inherit initialPackageInfo;
pkgs = nixpkgs.lib.mkForce nixpkgs; # to override ./modules/nixpkgs/config.nix pkgs = pkgs.lib.mkForce pkgs; # to override ./modules/nixpkgs/config.nix
}; };
isFlake = true;
config = { config = {
# Fix invoking bash after initial build. # Fix invoking bash after initial build.
user.shell = "${initialPackageInfo.bash}/bin/bash"; user.shell = "${initialPackageInfo.bash}/bin/bash";
@ -24,7 +31,7 @@ let
build = { build = {
inherit arch; inherit arch;
channel = with nixpkgs.lib; { channel = with pkgs.lib; {
nixpkgs = mkIf (nixpkgsChannelURL != null) nixpkgsChannelURL; nixpkgs = mkIf (nixpkgsChannelURL != null) nixpkgsChannelURL;
nix-on-droid = mkIf (nixOnDroidChannelURL != null) nixOnDroidChannelURL; nix-on-droid = mkIf (nixOnDroidChannelURL != null) nixOnDroidChannelURL;
}; };
@ -32,8 +39,8 @@ let
}; };
}; };
callPackage = nixpkgs.lib.callPackageWith ( callPackage = pkgs.lib.callPackageWith (
nixpkgs // customPkgs // { pkgs // customPkgs // {
inherit (modules) config; inherit (modules) config;
inherit callPackage nixpkgs nixDirectory initialPackageInfo; inherit callPackage nixpkgs nixDirectory initialPackageInfo;
} }

View file

@ -1,17 +0,0 @@
# Copyright (c) 2019-2022, see AUTHORS. Licensed under MIT License, see LICENSE.
let
defaultNixpkgsArgs = {
config = { };
overlays = [ ];
};
# head of nixos-22.05 as of 2022-06-27
# note: when updating nixpkgs, update store paths of proot-termux in modules/environment/login/default.nix
pinnedPkgsSrc = builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/cd90e773eae83ba7733d2377b6cdf84d45558780.tar.gz";
sha256 = "1b2wn1ncx9x4651vfcgyqrm93pd7ghnrgqjbkf6ckkpidah69m03";
};
in
args: import pinnedPkgsSrc (args // defaultNixpkgsArgs)