diff --git a/flake.nix b/flake.nix index 00161e1..6e58cdd 100644 --- a/flake.nix +++ b/flake.nix @@ -7,9 +7,10 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + _1password-shell-plugins.url = "github:1Password/shell-plugins"; }; - outputs = { nixpkgs, home-manager, ... }: + outputs = { nixpkgs, ... }@inputs: let system = "x86_64-linux"; pkgs = nixpkgs.legacyPackages.${system}; @@ -21,6 +22,10 @@ ./options.nix ./home.nix ./git.nix + inputs._1password-shell-plugins.hmModules.default + ]; + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [ + "1password-cli" ]; }; }; diff --git a/home.nix b/home.nix index 7a09716..f83d6b8 100644 --- a/home.nix +++ b/home.nix @@ -100,25 +100,47 @@ "git" "ssh" "ssh-agent" - ]; + ] ++ lib.optional config._1password "1password"; }; shellAliases.ls = "${pkgs.eza}/bin/eza -lgos type --no-time"; + # initContent = lib.mkIf config._1password '' + # source ${config.home.homeDirectory}/.config/op/plugins.sh + # ''; }; programs.ssh = lib.mkIf config.ssh { enable = true; extraConfig = '' SetEnv TERM="xterm-256color" + ${lib.optionalString config._1password "IdentityAgent ~/.1password/agent.sock"} ''; - matchBlocks = lib.mkIf (config.profile == "personal") { - "panoptes" = { - hostname = "192.168.1.107"; - user = "panoptes"; - }; - "pve5070" = { - hostname = "192.168.1.130"; - user = "root"; - }; - }; + matchBlocks = lib.mkMerge [ + (lib.mkIf (config.profile == "personal") { + "panoptes" = { + hostname = "192.168.1.107"; + user = "panoptes"; + }; + "pve5070" = { + hostname = "192.168.1.130"; + user = "root"; + }; + }) + (lib.mkIf (config.profile == "work") { + "ubuntu-nvidia" = { + hostname = "10.118.46.120"; + user = "john"; + }; + }) + ]; + }; + + # https://developer.1password.com/docs/cli/shell-plugins/nix/ + programs._1password-shell-plugins = lib.mkIf config._1password { + # enable 1Password shell plugins for bash, zsh, and fish shell + enable = true; + # the specified packages as well as 1Password CLI will be + # automatically installed and configured to use shell plugins + # https://developer.1password.com/docs/cli/shell-plugins + plugins = with pkgs; [ gh ]; }; } diff --git a/options.nix b/options.nix index a8e1eae..ac6fcbb 100644 --- a/options.nix +++ b/options.nix @@ -23,4 +23,10 @@ default = true; description = "Whether to enable SSH configuration"; }; + + options._1password = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Whether to enable 1 password stuff"; + }; }