diff --git a/modules/home-manager/profiles/desktop.nix b/modules/home-manager/profiles/desktop.nix index 8c0766a..a2d9062 100644 --- a/modules/home-manager/profiles/desktop.nix +++ b/modules/home-manager/profiles/desktop.nix @@ -6,6 +6,7 @@ imports = with inputs.self.homeModules; [ onepassword ghostty + sublime ]; }; } diff --git a/modules/home-manager/users/john.nix b/modules/home-manager/users/john.nix index c3f969b..90fb127 100644 --- a/modules/home-manager/users/john.nix +++ b/modules/home-manager/users/john.nix @@ -12,12 +12,11 @@ imports = with inputs.self.homeModules; [ base docker - sublime - desktop # resticprofile ]; }; + # This is the base homeConfiguration for the john user that will be used if no other flake.homeConfigurations.john = inputs.home-manager.lib.homeManagerConfiguration { pkgs = import inputs.nixpkgs { system = "x86_64-linux"; }; modules = [ @@ -25,11 +24,9 @@ # Include another inline module to set the options created through the jsl-home modules { - homeManagerFlakeDir = "~/.config/home-manager"; - docker.enable = true; + docker.enable = false; ssh.matchSets = { certs = true; - appdaemon = true; homelab = true; }; } diff --git a/modules/hosts/john-pc-ubuntu.nix b/modules/hosts/john-pc-ubuntu.nix index 7455b2c..1905d6b 100644 --- a/modules/hosts/john-pc-ubuntu.nix +++ b/modules/hosts/john-pc-ubuntu.nix @@ -3,10 +3,7 @@ flake.homeModules."john-pc-ubuntu" = { imports = with inputs.self.homeModules; [ desktop - home - onepassword - sublime - # resticprofile + john ]; # TODO: Add host-specific settings here: @@ -22,7 +19,7 @@ # Include another inline module to set the options created through the jsl-home modules { - homeManagerFlakeDir = "~/.config/home-manager"; + homeManagerFlakeDir = "~/.config/home-manager/jsl-dendritic"; docker.enable = true; ssh.matchSets = { certs = true; diff --git a/scripts/inspect.sh b/scripts/inspect.sh new file mode 100755 index 0000000..bc290a4 --- /dev/null +++ b/scripts/inspect.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh + +NIX_EVAL_CMD="nix eval --json --no-warn-dirty --apply builtins.attrNames" + +list_flake_attr() { + attr="$1" + flake="${2:-.}" + echo "${attr} [${flake}]:" + $NIX_EVAL_CMD "${flake}#${attr}" | jq -r '" - " + .[]' + echo +} + +list_home_modules() { + list_flake_attr "homeModules" "$1" +} + +list_home_configurations() { + list_flake_attr "homeConfigurations" "$1" +} + +current_dir=$(readlink -f .) +flake="${1:-$current_dir}" +list_home_modules "$flake" +list_home_configurations "$flake" diff --git a/scripts/switch.sh b/scripts/switch.sh new file mode 100755 index 0000000..81600b9 --- /dev/null +++ b/scripts/switch.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +FLAKE_DIR="/home/john/.config/home-manager/jsl-dendritic" + +is_in_array() { + local needle="$1" + shift + local arr=("$@") + [[ " ${arr[*]} " == *" ${needle} "* ]] && echo true || echo false +} + +hostname_exists() { + NIX_EVAL_CMD="nix eval --json --no-warn-dirty --apply builtins.attrNames" + mapfile -t HOME_CONFIGS < <(${NIX_EVAL_CMD} ${FLAKE_DIR}#homeConfigurations | jq -r '.[]') + is_in_array "$(hostname)" "${HOME_CONFIGS[@]}" +} + +HOSTNAME=$(hostname) +if [[ "$(hostname_exists)" == "true" ]]; then + home-manager switch --flake "${FLAKE_DIR}#${HOSTNAME}" +else + echo "No homeConfiguration found for hostname '${HOSTNAME}'." >&2 + exit 1 +fi