From 38b17aa9d5389db4914b967dfd059d949b839afb Mon Sep 17 00:00:00 2001 From: Alexander Sosedkin Date: Sun, 7 Jul 2024 23:42:33 +0200 Subject: [PATCH] WIP: login-inner: get rid of gnused in flake bootstrap --- modules/environment/login/login-inner.nix | 33 ++++++++++++++++------- tests/emulator/bootstrap_flakes.py | 4 +-- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/modules/environment/login/login-inner.nix b/modules/environment/login/login-inner.nix index 81d12a9b..bcc83fd6 100644 --- a/modules/environment/login/login-inner.nix +++ b/modules/environment/login/login-inner.nix @@ -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 @@ -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 diff --git a/tests/emulator/bootstrap_flakes.py b/tests/emulator/bootstrap_flakes.py index 8131d86f..ae944f47 100644 --- a/tests/emulator/bootstrap_flakes.py +++ b/tests/emulator/bootstrap_flakes.py @@ -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$')