From 0f8ba89e49a326775c02992686492dc8e5613985 Mon Sep 17 00:00:00 2001 From: Alexander Sosedkin Date: Tue, 12 Mar 2019 21:19:06 +0700 Subject: [PATCH] Make home-manager installation a manual step --- script | 142 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 107 insertions(+), 35 deletions(-) diff --git a/script b/script index dada36a..01d8cac 100755 --- a/script +++ b/script @@ -91,11 +91,12 @@ mkdir -p bootstrap/tmp cat > bootstrap/bin/login < $INST/etc/passwd echo "nix-on-droid:x:\$(/system/bin/stat -c '%u:%g' $INST):nix-on-droid:/bin/sh" >> $INST/etc/passwd fi @@ -115,13 +116,15 @@ chmod +x bootstrap/bin/login cat > bootstrap/bin/.login-inner <' -A install -else +if [ -e "\$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ]; then + [ "\$#" -gt 0 ] || echo "Sourcing home-manager environment..." export NIX_PATH=\$HOME/.nix-defexpr/channels\${NIX_PATH:+:}\$NIX_PATH + . "\$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" fi -echo "Sourcing home-manager environment..." -. "\$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" +if [ "\$#" -eq 0 ]; then + if [ ! -e "\$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ]; then + echo "Congratulations. Now you have Nix installed, but that's kinda it." + echo "Hope you're a seasoned Nix user, because stuff is not pretty yet." + echo "If you wonder what to do next, and want to do it the hard way, start with running" + echo " nix-channel --add https://nixos.org/channels/nixos-18.09 nixpkgs" + echo " nix-channel --update" + echo "After that you can summon software from nixpkgs (e.g. gitMinimal):" + echo "* by asking for a shell that has it:" + echo " nix run nixpkgs.bashInteractive nixpkgs.gitMinimal" + echo "* or installing it into the user environment (not recommended):" + echo " nix-env -iA nixpkgs.gitMinimal" + echo "* or, the best way, declaratively with home-manager:" + echo " 0. nix-on-droid-install" + echo " 1. [get an editor and edit ~/.config/nixpkgs/home.nix]" + echo " 2. home-manager switch" + echo "or a myriad other ways." + echo "You should really consider installing at least: nix, cacert and coreutils." + echo "bashInteractive and a text editor should be high on the list too." + echo + echo "If you want the easy way, nix-on-droid-install should get all this covered." + echo + echo "TL;DR: run nix-on-droid-install and things will get better." + echo + echo "Dropping you into an extremely limited shell (that has Nix though). Happy hacking!" + export PATH="$TGT_NIX/bin:\$PATH" + exec /bin/sh + fi -if [ -z "$@" ]; then - echo "Dropping you into a shell." - echo "You can summon software from nixpkgs (e.g. gitMinimal) with:" - echo " * nix run nixpkgs.gitMinimal" - echo " * nix-env -iA nixpkgs.gitMinimal" - echo " * [edit ~/.config/nixpkgs/home.nix and run] home-manager switch" - echo "or a myriad other ways." - echo "Happy hacking!" + echo "Dropping you into a shell. Happy hacking!" exec /usr/bin/env bash else - exec /usr/bin/env "$@" + exec /usr/bin/env "\$@" fi EOF chmod +x bootstrap/bin/.login-inner + +cat > bootstrap/bin/nix-on-droid-install <' -A install + +echo "Edit ~/.config/nixpkgs/home.nix and home-manager rebuild to control what is going on." +echo "Run bash or restart your session to enjoy a much nicer environment." +EOF +chmod +x bootstrap/bin/nix-on-droid-install + + echo "providing a default home-manager config..." + cat > bootstrap/etc/home.nix.default < bootstrap/etc/home.nix.default <