From 3c50256346d10c9062d25750cf729cb7847ea562 Mon Sep 17 00:00:00 2001 From: Alexander Sosedkin Date: Sun, 19 Mar 2023 03:29:48 +0100 Subject: [PATCH] WIP: continue going /bin-less --- modules/environment/links.nix | 13 ++++++---- modules/environment/login/default.nix | 36 ++++++++++++++++++--------- tests/fakedroid.sh | 1 - 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/modules/environment/links.nix b/modules/environment/links.nix index a48ef5b..24ae9dd 100644 --- a/modules/environment/links.nix +++ b/modules/environment/links.nix @@ -6,6 +6,7 @@ with lib; let cfg = config.environment; + inherit (config.build) installationDir; in { @@ -36,11 +37,13 @@ in config = { build.activationBefore = { - #linkBinSh = '' - # $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin - # $DRY_RUN_CMD ln $VERBOSE_ARG --symbolic --force ${cfg.binSh} /bin/.sh.tmp - # $DRY_RUN_CMD mv $VERBOSE_ARG /bin/.sh.tmp /bin/sh - #''; + linkBinSh = '' + $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents ${installationDir}/bin + $DRY_RUN_CMD ln $VERBOSE_ARG --symbolic --force \ + ${cfg.binSh} ${installationDir}/bin/.sh.tmp + $DRY_RUN_CMD mv $VERBOSE_ARG \ + ${installationDir}/bin/.sh.tmp ${installationDir}/bin/sh + ''; linkUsrBinEnv = '' $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /usr/bin diff --git a/modules/environment/login/default.nix b/modules/environment/login/default.nix index 0152700..7265e19 100644 --- a/modules/environment/login/default.nix +++ b/modules/environment/login/default.nix @@ -7,8 +7,9 @@ with lib; let cfg = config.environment.files; - login = pkgs.callPackage ./login.nix { inherit config; }; + inherit (config.build) installationDir; + login = pkgs.callPackage ./login.nix { inherit config; }; loginInner = pkgs.callPackage ./login-inner.nix { inherit config initialPackageInfo; }; in @@ -50,11 +51,14 @@ in build.activation = { installLogin = '' - if ! diff /bin/login ${login} > /dev/null; then - $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin - $DRY_RUN_CMD cp $VERBOSE_ARG ${login} /bin/.login.tmp - $DRY_RUN_CMD chmod $VERBOSE_ARG u+w /bin/.login.tmp - $DRY_RUN_CMD mv $VERBOSE_ARG /bin/.login.tmp /bin/login + if ! diff ${installationDir}/bin/login ${login} > /dev/null; then + $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents ${installationDir}/bin + $DRY_RUN_CMD cp $VERBOSE_ARG ${login} \ + ${installationDir}/bin/.login.tmp + $DRY_RUN_CMD chmod $VERBOSE_ARG u+w \ + ${installationDir}/bin/.login.tmp + $DRY_RUN_CMD mv $VERBOSE_ARG \ + ${installationDir}/bin/.login.tmp ${installationDir}/bin/login fi ''; @@ -69,12 +73,20 @@ in ''; installProotStatic = '' - if (test -e /bin/.proot-static.new && ! diff /bin/.proot-static.new ${cfg.prootStatic}/bin/proot-static > /dev/null) || \ - (! test -e /bin/.proot-static.new && ! diff /bin/proot-static ${cfg.prootStatic}/bin/proot-static > /dev/null); then - $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents /bin - $DRY_RUN_CMD cp $VERBOSE_ARG ${cfg.prootStatic}/bin/proot-static /bin/.proot-static.tmp - $DRY_RUN_CMD chmod $VERBOSE_ARG u+w /bin/.proot-static.tmp - $DRY_RUN_CMD mv $VERBOSE_ARG /bin/.proot-static.tmp /bin/.proot-static.new + if (test -e ${installationDir}/bin/.proot-static.new && \ + ! diff ${installationDir}/bin/.proot-static.new \ + ${cfg.prootStatic}/bin/proot-static > /dev/null) || \ + (! test -e ${installationDir}/bin/.proot-static.new && \ + ! diff ${installationDir}/bin/proot-static \ + ${cfg.prootStatic}/bin/proot-static > /dev/null); then + $DRY_RUN_CMD mkdir $VERBOSE_ARG --parents ${installationDir}/bin + $DRY_RUN_CMD cp $VERBOSE_ARG ${cfg.prootStatic}/bin/proot-static \ + ${installationDir}/bin/.proot-static.tmp + $DRY_RUN_CMD chmod $VERBOSE_ARG u+w \ + ${installationDir}/bin/.proot-static.tmp + $DRY_RUN_CMD mv $VERBOSE_ARG \ + ${installationDir}/bin/.proot-static.tmp \ + ${installationDir}/bin/.proot-static.new fi ''; }; diff --git a/tests/fakedroid.sh b/tests/fakedroid.sh index 7796853..c4654a3 100644 --- a/tests/fakedroid.sh +++ b/tests/fakedroid.sh @@ -52,7 +52,6 @@ PROOT_ARGS=( "-q" "$QEMU" "-w" "$TARGET_HOME" "-b" "$ENV_DIR/$INSTALLATION_DIR/nix:/nix" - "-b" "$ENV_DIR/$INSTALLATION_DIR/bin:/bin" "-b" "$ENV_DIR/$INSTALLATION_DIR/etc:/etc" "-b" "$ENV_DIR/$INSTALLATION_DIR/tmp:/tmp" "-b" "$ENV_DIR/$INSTALLATION_DIR/usr:/usr"