Skip to content

Commit 3cffcee

Browse files
committed
doc.patterns: Add shell completion example to mkApplication
Closes pyproject-nix/pyproject.nix#429
1 parent 1667614 commit 3cffcee

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

doc/src/patterns/applications.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,24 @@ For such cases `pyproject.nix` provides a utility function [`mkApplication`](htt
3131
};
3232
}
3333
```
34+
35+
## Additional data
36+
37+
When shipping an application you might want to ship additional data such as shell completions.
38+
39+
To ship additional data in the same derivation as the application derivation use an override:
40+
41+
```nix
42+
(mkApplication {
43+
venv = pythonSet.mkVirtualEnv "application-env" workspace.deps.default;
44+
package = pythonSet.hello-world;
45+
}).overrideAttrs(old: {
46+
nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.installShellFiles ];
47+
postInstall = ''
48+
installShellCompletion --cmd ${cmd} \
49+
--bash <($out/bin/${cmd} --show-completion bash) \
50+
--fish <($out/bin/${cmd} --show-completion fish) \
51+
--zsh <($out/bin/${cmd} --show-completion zsh)
52+
'';
53+
})
54+
```

0 commit comments

Comments
 (0)