Skip to content

Commit

Permalink
Merge pull request #8 from vst/7-install-shell-completion
Browse files Browse the repository at this point in the history
Fix and Install Shell Completions
  • Loading branch information
vst committed Mar 11, 2024
2 parents 74923b6 + ae2b0af commit b7bd07d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
16 changes: 15 additions & 1 deletion nix/lib/mk-haskell-app.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
## We need these inputs at buildtime:
extraNativeBuildInputs = [
pkgs.git
pkgs.installShellFiles
pkgs.makeWrapper
pkgs.ronn
] ++ nativeBuildInputs;
Expand All @@ -21,10 +22,23 @@ let
extraPostFixup = ''
## Wrap program:
wrapProgram $out/bin/${name} --prefix PATH : ${binPath}
## Create a temporary directory to store interim artifacts:
_tmpdir=$(mktemp -d)
## Create completion scripts:
$out/bin/${name} --bash-completion-script "$out/bin/${name}" > ''${_tmpdir}/completion.bash
$out/bin/${name} --fish-completion-script "$out/bin/${name}" > ''${_tmpdir}/completion.fish
$out/bin/${name} --zsh-completion-script "$out/bin/${name}" > ''${_tmpdir}/completion.zsh
## Install completion scripts:
installShellCompletion --bash ''${_tmpdir}/completion.bash
installShellCompletion --fish ''${_tmpdir}/completion.fish
installShellCompletion --zsh ''${_tmpdir}/completion.zsh
'';
in
pkgs.haskell.lib.justStaticExecutables (
drv.overrideAttrs (oldAttrs: rec {
drv.overrideAttrs (oldAttrs: {
nativeBuildInputs = (oldAttrs.nativeBuildInputs or [ ]) ++ extraNativeBuildInputs;
postFixup = (oldAttrs.postFixup or "") + extraPostFixup;
})
Expand Down
6 changes: 3 additions & 3 deletions src/Opsops/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ commandNormalize =
<> OA.footer "This command prints the canonical specification."
parser =
doNormalize
<$> OA.strOption (OA.short 'i' <> OA.long "input" <> OA.help "Path to the specification file.")
<$> OA.strOption (OA.short 'i' <> OA.long "input" <> OA.action "file" <> OA.help "Path to the specification file.")


-- | @normalize@ CLI command program.
Expand All @@ -92,7 +92,7 @@ commandRender =
<> OA.footer "This command renders the specification into clear secrets."
parser =
doRender
<$> OA.strOption (OA.short 'i' <> OA.long "input" <> OA.help "Path to the specification file.")
<$> OA.strOption (OA.short 'i' <> OA.long "input" <> OA.action "file" <> OA.help "Path to the specification file.")


-- | @render@ CLI command program.
Expand Down Expand Up @@ -137,7 +137,7 @@ commandSnippetSopsNix =
<> OA.footer "This command prints sample sops-nix snippet."
parser =
doSnippetSopsNix
<$> OA.strOption (OA.short 'i' <> OA.long "input" <> OA.help "Path to the specification file.")
<$> OA.strOption (OA.short 'i' <> OA.long "input" <> OA.action "file" <> OA.help "Path to the specification file.")
<*> OA.optional (OA.strOption (OA.short 'p' <> OA.long "prefix" <> OA.help "Optional prefix for sops-nix path."))


Expand Down

0 comments on commit b7bd07d

Please sign in to comment.