Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,54 @@
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};
in {
let
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"
];
};
};
in
{
apps.make-supported-plugins = {
type = "app";
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.make-supported-plugins = pkgs.writeShellApplication {
name = "make-supported-plugins";
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)

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 .#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"
'';
};

devShells.default = pkgs.mkShell {
name = "Shell with Go toolchain";
packages = with pkgs; [ go gopls ];
Expand Down
9 changes: 1 addition & 8 deletions nix/shell-plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@
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 = 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;`
Expand Down
68 changes: 68 additions & 0 deletions nix/supported-plugins.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# This file was automatically generated using 'nix run .#make-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"
]
Loading