• Operand
  • de ploy? ed.

gram:build

> ./proceed.sh

Lenses
(coming soon!)


# ---

# module could use some naming help;
# main idea is running behind a launch program,
# one of `./prepare/launch.linux.sh`
# or     `./prepare/launch.nix.sh`

# prepare/proceed.sh seems sensible?
# only our purpose should be making sure is easily runnable.

# more and more, seems like this one program
# plays the role of both earlier `prepare/launch.*.sh` ones.

# probably makes more sense to scrap `./prepare`,
# has been a hodgepodge of old and decaying recipes.

if [ $(whoami) = "root" ]; then exit 1; fi

# should be runnable on nearly any machine.
link_nodes() {
  for node in zshrc sh.d config; do
    place="$HOME/.$node"
    if [ -d ~/.build/$node ]; then
      [ -e $place ] || mkdir $place
      for n in ~/.build/$node/*; do
        name=$(basename $n)
        [ -e "$place/$name" ] && echo "already in place: $place/$name" ||
          (echo "linking: $place/$name" && ln -s "$n" "$place/$name")
      done
    else
      [ -e $place ] || ln -s $HOME/.build/$node $place
    fi
  done
}

prepare_apple() { if [ "$(uname)" == "Darwin" ]; then ./prepare/apple.sh; fi; }

link_nodes
prepare_apple

echo "dropping ~/.config/nushell, using linked copy!"
rm -rf ~/.config/nushell
ln -s ~/.build/config/nushell ~/.config/nushell

# mkdir -p ~/.config/xplr/plugins
# [ ! -d ~/.config/xplr/plugins/map ] && git clone https://github.com/sayanarijit/map.xplr ~/.config/xplr/plugins/map

# [upgrade] condicional guard based on presence of nixos in `uname -a`
if [ $@ = "-n" ]; then
  echo 'you chose `-n` mode, nushell layer only; ending here.'
  echo 'go deeper on nixos: https://nixos.org'
else
  echo 'no `-n`, proceeding deeper.'

  sudo echo "super user permissions enabled; proceeding."
  sudo nix-env -iA nixos.git

  echo "Pull nix channels..."
  sudo nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
  sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixos
  sudo nix-channel --add https://github.com/nixos/nixos-hardware/archive/master.tar.gz nixos-hardware
  sudo nix-channel --update

  echo "Linking $BUILD"
  BUILD=$HOME/.build
  [ -e $BUILD/nixos/mach/base.nix ] || sudo cp /etc/nixos/configuration.nix $BUILD/nixos/mach/base.nix
  [ -e $BUILD/.build/nixos/mach/hardware-configuration.nix ] || sudo cp /etc/nixos/hardware-configuration.nix $BUILD/nixos/mach/
  sudo chown $(whoami) $BUILD/nixos/mach/{base,hardware-configuration}.nix

  [ -e $BUILD/nixos/mach/base.nix ] &&
    [ -e $BUILD/nixos/mach/hardware-configuration.nix ] &&
    sudo rm -rf /etc/nixos && sudo ln -s $BUILD/nixos /etc/nixos
  sudo nixos-rebuild switch
fi