Files
nixos/overlays/hms.nix
T

31 lines
583 B
Nix
Raw Normal View History

2022-08-02 01:50:50 -05:00
{ pkgs, ... }:
pkgs.writeShellScriptBin "hms" ''
set -eo pipefail
# Build different targets with GUI or not
2022-09-09 11:54:18 -05:00
arch="$(uname -m)"
2022-09-07 20:01:51 -05:00
if [ "$(uname -s)" == "Darwin" ]; then
2022-09-09 11:54:18 -05:00
# On macOS
2022-09-07 20:01:51 -05:00
src="$HOME/.config/nix/"
2022-09-09 11:54:18 -05:00
target="''${arch}-darwin"
2022-09-07 20:01:51 -05:00
else
2022-09-09 11:54:18 -05:00
# On Linux/WSL2 systems
if [ -z "$DISPLAY" ]; then
target="''${arch}-nogui"
else
target="''${arch}-gui"
fi
2022-09-07 20:01:51 -05:00
src=/etc/nixos
fi
2022-08-02 01:50:50 -05:00
# Build and switch
2022-10-15 00:19:38 -05:00
echo "Building $target"
2022-08-02 01:50:50 -05:00
dest=$(mktemp -d)
pushd "$dest" > /dev/null
2022-09-09 11:54:18 -05:00
nix build --impure "$src#homeConfigurations.$target.activationPackage"
2022-08-02 01:50:50 -05:00
./result/activate
popd > /dev/null
rm -r "$dest"
''