# nixpkgs ## Install NIX ``` sh <(curl -L https://nixos.org/nix/install) --no-daemon ``` ## Enable profile ``` . /home/sstent/.nix-profile/etc/profile.d/nix.sh ``` ## Setup channels and enable path ``` nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager nix-channel --update export NIX_PATH=$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels${NIX_PATH:+:$NIX_PATH} ``` ### Setup ssh keys ``` nix-shell -p wget p7zip socat ``` ## Inside SHELL ``` wget https://github.com/rupor-github/wsl-ssh-agent/releases/download/v1.5.2/wsl-ssh-agent.zip -P /tmp mkdir -p ~/bin 7z e -y /tmp/wsl-ssh-agent.zip -o$HOME/bin/ chmod +x ~/bin/npiperelay.exe mkdir -p $HOME/.ssh touch $HOME/.ssh/agent.sock ``` ## Create ~/bin/wsl-ssh-agent-forwarder ``` nano ~/bin/wsl-ssh-agent-forwarder ``` paste ``` #!/usr/bin/env bash # Usage: wsl-ssh-agent-forward [ -k | -r ] # Options: # -k Kill the current process (if exists) and do not restart it. # -r Kill the current process (if exists) and restart it. # Default operation is to start a process only if it does not exist. export SSH_AUTH_SOCK=$HOME/.ssh/agent.sock sshpid=$(ss -ap | grep "$SSH_AUTH_SOCK") if [ "$1" = "-k" ] || [ "$1" = "-r" ]; then sshpid=${sshpid//*pid=/} sshpid=${sshpid%%,*} if [ -n "${sshpid}" ]; then kill "${sshpid}" else echo "'socat' not found or PID not found" fi if [ "$1" = "-k" ]; then exit fi unset sshpid fi if [ -z "${sshpid}" ]; then rm -f $SSH_AUTH_SOCK ( setsid socat UNIX-LISTEN:$SSH_AUTH_SOCK,fork EXEC:"$HOME/bin/npiperelay.exe -ei -s //./pipe/openssh-ssh-agent",nofork & ) >/de>fi ``` ## Enable the forwarder ``` chmod +x ~/bin/wsl-ssh-agent-forwarder . ~/bin/wsl-ssh-agent-forwarder ssh-add -l exit ``` ## Check keys loaded ``` ssh-add -l ``` ## Install Home Manager ``` nix-shell '' -A install ``` ## Grab config repo ``` rm -f /home/sstent/.config/nixpkgs/home.nix git clone git@github.com:sstent/nixpkgs.git /home/sstent/.config/nixpkgs ``` ## Enable profile ``` home-manager switch -b backup ``` # Updates ``` home-manager switch ```