From aa9ddf8f0f7c2575d34a5842ec98a9b00b21679d Mon Sep 17 00:00:00 2001 From: RyanPrussin <3878957+RyanPrussin@users.noreply.github.com> Date: Sat, 2 Aug 2025 15:16:47 -0400 Subject: [PATCH 1/6] Core fix --- nix/shell-plugins.nix | 74 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/nix/shell-plugins.nix b/nix/shell-plugins.nix index 907bf2f5..edfc86a2 100644 --- a/nix/shell-plugins.nix +++ b/nix/shell-plugins.nix @@ -3,13 +3,73 @@ with lib; let cfg = config.programs._1password-shell-plugins; - supported_plugins = splitString "\n" (lib.readFile "${ - # get the list of supported plugin executable names - pkgs.runCommand "op-plugin-list" { } - # 1Password CLI tries to create the config directory automatically, so set a temp XDG_CONFIG_HOME - # since we don't actually need it for this - "mkdir $out && XDG_CONFIG_HOME=$out ${pkgs._1password}/bin/op plugin list | cut -d ' ' -f1 | tail -n +2 > $out/plugins.txt" - }/plugins.txt"); + supported_plugins = [ + "akamai" + "argocd" + "aws" + "cdk" + "axiom" + "binance-cli" + "cachix" + "cargo" + "circleci" + "civo" + "wrangler" + "crowdin" + "databricks" + "dog" + "doctl" + "fastly" + "flyctl" + "fly" + "fossa" + "tea" + "gh" + "glab" + "vault" + "heroku" + "hcloud" + "brew" + "huggingface-cli" + "influx" + "kaggle" + "lacework" + "forge" + "vapor" + "linode-cli" + "localstack" + "atlas" + "mysql" + "ngrok" + "ohdear" + "okta" + "openai" + "oaieval" + "oaievalset" + "pd" + "psql" + "pg_dump" + "pg_restore" + "pgcli" + "pulumi" + "rdme" + "sentry-cli" + "snowsql" + "snyk" + "src" + "stripe" + "todoist" + "td" + "tugboat" + "twilio" + "upstash" + "vercel" + "vsql" + "vultr-cli" + "ysqlsh" + "zapier" + "zcli" + ]; getExeName = package: # NOTE: SAFETY: This is okay because the `packages` list is also referred # to below as `home.packages = packages;` or `environment.systemPackages = packages;` From 52cca5e2a5fab253ac44a006cdf802c7cc5e648c Mon Sep 17 00:00:00 2001 From: RyanPrussin <3878957+RyanPrussin@users.noreply.github.com> Date: Sat, 2 Aug 2025 18:16:31 -0400 Subject: [PATCH 2/6] Get supported plugins in Nix expression via script --- flake.nix | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index fcd77300..0052777d 100644 --- a/flake.nix +++ b/flake.nix @@ -3,10 +3,47 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils = { url = "github:numtide/flake-utils"; }; }; - outputs = { nixpkgs, flake-utils, ... }: + + outputs = inputs@{ self, nixpkgs, flake-utils, ... }: (flake-utils.lib.eachDefaultSystem (system: - let pkgs = nixpkgs.legacyPackages.${system}; + let + pkgs = import nixpkgs { + inherit system; + config = { + allowUnfreePredicate = pkg: + builtins.elem (nixpkgs.lib.getName pkg) [ + "1password-cli" + ]; + }; + }; in { + apps.supported-plugins = { + type = "app"; + program = "${self.packages.${system}.supported-plugins}/bin/supported-plugins"; + meta = { + description = "Generate a Nix expression containing an array of plugins that are currently supported by 1Password."; + }; + }; + + packages.supported-plugins = pkgs.writeShellApplication { + name = "supported-plugins"; + runtimeInputs = [ pkgs._1password ]; + text = '' + + # Get the supported plugins separated by line breaks + SUPPORTED_PLUGINS=$(op plugin list | cut -d ' ' -f1 | tail -n +2) + + if [ -z "$SUPPORTED_PLUGINS" ]; then + echo "Error: No plugins found when calling 'op plugin list' command." >&2 + exit 1 + fi + + echo "# This file was automatically generated using 'nix run .#supported-plugins'" + echo "$SUPPORTED_PLUGINS" | awk 'BEGIN { print "[" } {print " \""$0"\""} END { print "]" }' + + ''; + }; + devShells.default = pkgs.mkShell { name = "Shell with Go toolchain"; packages = with pkgs; [ go gopls ]; From 48a2e0b0c2526260939c48cdf129b0f91b8c4efe Mon Sep 17 00:00:00 2001 From: RyanPrussin <3878957+RyanPrussin@users.noreply.github.com> Date: Sat, 2 Aug 2025 18:21:55 -0400 Subject: [PATCH 3/6] Create supported-plugins.nix manually to ensure all records exist on running script --- flake.nix | 3 +- nix/shell-plugins.nix | 69 +-------------------------------------- nix/supported-plugins.nix | 68 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 69 deletions(-) create mode 100644 nix/supported-plugins.nix diff --git a/flake.nix b/flake.nix index 0052777d..603d357f 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,8 @@ ]; }; }; - in { + in + { apps.supported-plugins = { type = "app"; program = "${self.packages.${system}.supported-plugins}/bin/supported-plugins"; diff --git a/nix/shell-plugins.nix b/nix/shell-plugins.nix index edfc86a2..cf8acfef 100644 --- a/nix/shell-plugins.nix +++ b/nix/shell-plugins.nix @@ -2,74 +2,7 @@ with lib; let cfg = config.programs._1password-shell-plugins; - - supported_plugins = [ - "akamai" - "argocd" - "aws" - "cdk" - "axiom" - "binance-cli" - "cachix" - "cargo" - "circleci" - "civo" - "wrangler" - "crowdin" - "databricks" - "dog" - "doctl" - "fastly" - "flyctl" - "fly" - "fossa" - "tea" - "gh" - "glab" - "vault" - "heroku" - "hcloud" - "brew" - "huggingface-cli" - "influx" - "kaggle" - "lacework" - "forge" - "vapor" - "linode-cli" - "localstack" - "atlas" - "mysql" - "ngrok" - "ohdear" - "okta" - "openai" - "oaieval" - "oaievalset" - "pd" - "psql" - "pg_dump" - "pg_restore" - "pgcli" - "pulumi" - "rdme" - "sentry-cli" - "snowsql" - "snyk" - "src" - "stripe" - "todoist" - "td" - "tugboat" - "twilio" - "upstash" - "vercel" - "vsql" - "vultr-cli" - "ysqlsh" - "zapier" - "zcli" - ]; + supported_plugins = import ./supported-plugins.nix; getExeName = package: # NOTE: SAFETY: This is okay because the `packages` list is also referred # to below as `home.packages = packages;` or `environment.systemPackages = packages;` diff --git a/nix/supported-plugins.nix b/nix/supported-plugins.nix new file mode 100644 index 00000000..57299ecd --- /dev/null +++ b/nix/supported-plugins.nix @@ -0,0 +1,68 @@ +# +[ + "akamai" + "argocd" + "aws" + "cdk" + "axiom" + "binance-cli" + "cachix" + "cargo" + "circleci" + "civo" + "wrangler" + "crowdin" + "databricks" + "dog" + "doctl" + "fastly" + "flyctl" + "fly" + "fossa" + "tea" + "gh" + "glab" + "vault" + "heroku" + "hcloud" + "brew" + "huggingface-cli" + "influx" + "kaggle" + "lacework" + "forge" + "vapor" + "linode-cli" + "localstack" + "atlas" + "mysql" + "ngrok" + "ohdear" + "okta" + "openai" + "oaieval" + "oaievalset" + "pd" + "psql" + "pg_dump" + "pg_restore" + "pgcli" + "pulumi" + "rdme" + "sentry-cli" + "snowsql" + "snyk" + "src" + "stripe" + "todoist" + "td" + "tugboat" + "twilio" + "upstash" + "vercel" + "vsql" + "vultr-cli" + "ysqlsh" + "zapier" + "zcli" +] \ No newline at end of file From 491d2778d21fb153af333a1e16fdad9a36bd44b6 Mon Sep 17 00:00:00 2001 From: RyanPrussin <3878957+RyanPrussin@users.noreply.github.com> Date: Sat, 2 Aug 2025 18:23:35 -0400 Subject: [PATCH 4/6] Run command: nix run .#supported-plugins > ./nix/supported-plugins.nix --- nix/supported-plugins.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/supported-plugins.nix b/nix/supported-plugins.nix index 57299ecd..88ba2f88 100644 --- a/nix/supported-plugins.nix +++ b/nix/supported-plugins.nix @@ -1,4 +1,4 @@ -# +# This file was automatically generated using 'nix run .#supported-plugins' [ "akamai" "argocd" @@ -65,4 +65,4 @@ "ysqlsh" "zapier" "zcli" -] \ No newline at end of file +] From 236857ee8f5e8e2822da84e704e776bab8fce308 Mon Sep 17 00:00:00 2001 From: RyanPrussin <3878957+RyanPrussin@users.noreply.github.com> Date: Sat, 2 Aug 2025 18:47:38 -0400 Subject: [PATCH 5/6] Make script write directly to directory --- flake.nix | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 603d357f..b62b7cc1 100644 --- a/flake.nix +++ b/flake.nix @@ -28,9 +28,15 @@ packages.supported-plugins = pkgs.writeShellApplication { name = "supported-plugins"; - runtimeInputs = [ pkgs._1password ]; + runtimeInputs = [ + pkgs.git + pkgs._1password + ]; text = '' + # Get the flake's directory so the command can be run in subdirectories reproducibly + PROJECT_ROOT=$(git rev-parse --show-toplevel) + # Get the supported plugins separated by line breaks SUPPORTED_PLUGINS=$(op plugin list | cut -d ' ' -f1 | tail -n +2) @@ -39,9 +45,8 @@ exit 1 fi - echo "# This file was automatically generated using 'nix run .#supported-plugins'" - echo "$SUPPORTED_PLUGINS" | awk 'BEGIN { print "[" } {print " \""$0"\""} END { print "]" }' - + echo "# This file was automatically generated using 'nix run .#supported-plugins'" > "$PROJECT_ROOT/nix/supported-plugins.nix" + echo "$SUPPORTED_PLUGINS" | awk 'BEGIN { print "[" } {print " \""$0"\""} END { print "]" }' >> "$PROJECT_ROOT/nix/supported-plugins.nix" ''; }; From f9c16866f09c101ba9bd431c53cb4e6b37145f8b Mon Sep 17 00:00:00 2001 From: RyanPrussin <3878957+RyanPrussin@users.noreply.github.com> Date: Sat, 2 Aug 2025 19:09:18 -0400 Subject: [PATCH 6/6] add comments + update name --- flake.nix | 11 ++++++----- nix/supported-plugins.nix | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index b62b7cc1..19616249 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,7 @@ pkgs = import nixpkgs { inherit system; config = { + # Ensure that the op CLI command can be used in this flake without getting warnings about it being unfree allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "1password-cli" @@ -18,16 +19,16 @@ }; in { - apps.supported-plugins = { + apps.make-supported-plugins = { type = "app"; - program = "${self.packages.${system}.supported-plugins}/bin/supported-plugins"; + program = "${self.packages.${system}.make-supported-plugins}/bin/make-supported-plugins"; meta = { description = "Generate a Nix expression containing an array of plugins that are currently supported by 1Password."; }; }; - packages.supported-plugins = pkgs.writeShellApplication { - name = "supported-plugins"; + packages.make-supported-plugins = pkgs.writeShellApplication { + name = "make-supported-plugins"; runtimeInputs = [ pkgs.git pkgs._1password @@ -45,7 +46,7 @@ exit 1 fi - echo "# This file was automatically generated using 'nix run .#supported-plugins'" > "$PROJECT_ROOT/nix/supported-plugins.nix" + echo "# This file was automatically generated using 'nix run .#make-supported-plugins'" > "$PROJECT_ROOT/nix/supported-plugins.nix" echo "$SUPPORTED_PLUGINS" | awk 'BEGIN { print "[" } {print " \""$0"\""} END { print "]" }' >> "$PROJECT_ROOT/nix/supported-plugins.nix" ''; }; diff --git a/nix/supported-plugins.nix b/nix/supported-plugins.nix index 88ba2f88..194f6007 100644 --- a/nix/supported-plugins.nix +++ b/nix/supported-plugins.nix @@ -1,4 +1,4 @@ -# This file was automatically generated using 'nix run .#supported-plugins' +# This file was automatically generated using 'nix run .#make-supported-plugins' [ "akamai" "argocd"