Files
nixos/overlays/hms.nix
T
2022-09-07 20:01:51 -05:00

28 lines
511 B
Nix

{ pkgs, ... }:
pkgs.writeShellScriptBin "hms" ''
set -eo pipefail
# Build different targets with GUI or not
if [ -z "$DISPLAY" ]; then
target="nogui"
else
target="gui"
fi
if [ "$(uname -s)" == "Darwin" ]; then
src="$HOME/.config/nix/"
target=gui
else
src=/etc/nixos
fi
# Build and switch
echo "Building $(uname -m)-$target"
dest=$(mktemp -d)
pushd "$dest" > /dev/null
nix build --impure "$src#homeConfigurations.$(uname -m)-$target.activationPackage"
./result/activate
popd > /dev/null
rm -r "$dest"
''