Skip to content

Commit

Permalink
WIP: login-inner: get rid of gnused in flake bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
t184256 committed Jul 7, 2024
1 parent 7f1432e commit 38b17aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
33 changes: 23 additions & 10 deletions modules/environment/login/login-inner.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{ config, lib, initialPackageInfo, writeText, targetSystem }:

let
inherit (initialPackageInfo) cacert nix;
inherit (initialPackageInfo) cacert nix coreutils;

nixCmd = "${nix}/bin/nix --extra-experimental-features 'flakes nix-command'";
in
Expand Down Expand Up @@ -81,24 +81,37 @@ writeText "login-inner" ''
${lib.optionalString config.build.flake.inputOverrides ''
echo "Overriding input urls in the flake..."
${nixCmd} run nixpkgs#gnused -- \
-i \
-e 's,\"github:NixOS/nixpkgs.*\",\"${config.build.flake.nixpkgs}\",' \
-e 's,\"github:nix-community/nix-on-droid.*\",\"${config.build.flake.nix-on-droid}\",' \
"${config.user.home}/.config/nix-on-droid/flake.nix"
while IFS="" read -r p || [[ -n "$p" ]]
do
if [[ $p =~ (.*)github:NixOS/nixpkgs.*\"\; ]]; then
printf "''${BASH_REMATCH[1]}${config.build.flake.nixpkgs}\";\n" "$p"
elif [[ $p =~ (.*)github:nix-community/nix-on-droid.*\"\; ]]; then
printf "''${BASH_REMATCH[1]}${config.build.flake.nix-on-droid}\";\n" "$p"
else
printf '%s\n' "$p"
fi
done <<<$(< "${config.user.home}/.config/nix-on-droid/flake.nix") \
> "${config.user.home}/.config/nix-on-droid/flake.nix"
''}
echo "Overriding system value in the flake..."
${nixCmd} run nixpkgs#gnused -- \
-i \
-e 's,\"aarch64-linux",\"${targetSystem}\",' \
"${config.user.home}/.config/nix-on-droid/flake.nix"
while IFS="" read -r p || [[ -n "$p" ]]
do
if [[ $p =~ (.*)\"aarch64-linux\"(.*) ]]; then
printf "''${BASH_REMATCH[1]}\"${targetSystem}\"''${BASH_REMATCH[2]}\n" "$p"
else
printf '%s\n' "$p"
fi
done <<<$(< "${config.user.home}/.config/nix-on-droid/flake.nix") \
> "${config.user.home}/.config/nix-on-droid/flake.nix"
echo "Installing first Nix-on-Droid generation..."
${nixCmd} run ${config.build.flake.nix-on-droid} -- switch --flake ${config.user.home}/.config/nix-on-droid
. "${config.user.home}/.nix-profile/etc/profile.d/nix-on-droid-session-init.sh"
rm -f "${config.user.home}/.config/nix-on-droid/flake.nix.tmp"
fi
echo
Expand Down
4 changes: 2 additions & 2 deletions tests/emulator/bootstrap_flakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def run(d):
wait_for(d, 'Setting up Nix-on-Droid with flakes...')

wait_for(d, 'Installing flake from default template...')
wait_for(d, 'Overriding system value in the flake...', timeout=600)
wait_for(d, 'Installing first Nix-on-Droid generation...')
wait_for(d, 'Overriding system value in the flake...')
wait_for(d, 'Installing first Nix-on-Droid generation...', timeout=180)
wait_for(d, 'Building activation package', timeout=180)
wait_for(d, 'Congratulations!', timeout=900)
wait_for(d, 'bash-5.2$')
Expand Down

0 comments on commit 38b17aa

Please sign in to comment.