wip
This commit is contained in:
parent
35d687500b
commit
a46a304ae1
10 changed files with 237 additions and 1 deletions
19
pkgs/sops/bash_autocomplete
Normal file
19
pkgs/sops/bash_autocomplete
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
# based on https://github.com/urfave/cli/blob/v2.3.0/autocomplete/bash_autocomplete
|
||||
|
||||
_cli_bash_autocomplete() {
|
||||
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
|
||||
local cur opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=$("${COMP_WORDS[@]:0:$COMP_CWORD}" "${cur}" --generate-bash-completion)
|
||||
else
|
||||
opts=$("${COMP_WORDS[@]:0:$COMP_CWORD}" --generate-bash-completion)
|
||||
fi
|
||||
IFS=$'\n' read -d '' -ra COMPREPLY < <(compgen -W "${opts}" -- "${cur}")
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete sops
|
60
pkgs/sops/package.nix
Normal file
60
pkgs/sops/package.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
lib,
|
||||
buildGo123Module,
|
||||
fetchFromGitHub,
|
||||
installShellFiles,
|
||||
versionCheckHook,
|
||||
nix-update-script,
|
||||
}:
|
||||
|
||||
buildGo123Module rec {
|
||||
pname = "sops";
|
||||
version = "3.9.4-unstable";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "getsops";
|
||||
repo = "sops";
|
||||
rev = "024b94f67afa967ed758ae17433d7da600e87599";
|
||||
hash = "sha256-rNO9+gIxxH4sYoemFbOD8HaKWL48VnbdCOKvQ0FoTgI=";
|
||||
};
|
||||
|
||||
vendorHash = "sha256-wdsPuUpYHEBkZ80d7L3iXIbBsnK4to0zDUOOlvOtde4=";
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace go.mod \
|
||||
--replace-fail "go 1.22" "go 1.23.0"
|
||||
'';
|
||||
|
||||
subPackages = [ "cmd/sops" ];
|
||||
|
||||
ldflags = [
|
||||
"-s"
|
||||
"-w"
|
||||
"-X github.com/getsops/sops/v3/version.Version=${version}"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ installShellFiles ];
|
||||
|
||||
postInstall = ''
|
||||
installShellCompletion --cmd sops --bash ${./bash_autocomplete}
|
||||
installShellCompletion --cmd sops --zsh ${./zsh_autocomplete}
|
||||
'';
|
||||
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
versionCheckProgramArg = "--version";
|
||||
doInstallCheck = true;
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
|
||||
meta = {
|
||||
homepage = "https://getsops.io/";
|
||||
description = "Simple and flexible tool for managing secrets";
|
||||
changelog = "https://github.com/getsops/sops/blob/v${version}/CHANGELOG.rst";
|
||||
mainProgram = "sops";
|
||||
maintainers = with lib.maintainers; [
|
||||
Scrumplex
|
||||
mic92
|
||||
];
|
||||
license = lib.licenses.mpl20;
|
||||
};
|
||||
}
|
25
pkgs/sops/zsh_autocomplete
Normal file
25
pkgs/sops/zsh_autocomplete
Normal file
|
@ -0,0 +1,25 @@
|
|||
#compdef sops
|
||||
|
||||
## based on https://github.com/urfave/cli/blob/v2.3.0/autocomplete/zsh_autocomplete
|
||||
|
||||
_cli_zsh_autocomplete() {
|
||||
|
||||
local -a opts
|
||||
local cur
|
||||
cur=${words[-1]}
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
|
||||
else
|
||||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
|
||||
fi
|
||||
|
||||
if [[ "${opts[1]}" != "" ]]; then
|
||||
_describe 'values' opts
|
||||
else
|
||||
_files
|
||||
fi
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
compdef _cli_zsh_autocomplete sops
|
Loading…
Add table
Add a link
Reference in a new issue