Skip to content

Commit 796f006

Browse files
committed
style: format readme
1 parent 726d359 commit 796f006

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The goal of Nixwrap is to make sandboxing easy to use for common use cases, redu
1313
> You need to run `npm install` on a project, but you cannot trust all its dependencies.
1414
1515
To run `npm install` only with write access to the current working directory and network access, simply do:
16+
1617
```shell
1718
wrap -n npm install
1819
```
@@ -22,6 +23,7 @@ wrap -n npm install
2223
> You need to run a GUI application, but you want limit access to your filesystem.
2324
2425
To run software using `nix3-run`, in this case vscodium with network and display access, without access to your home directory:
26+
2527
```shell
2628
wrap -n -d -p nix run nixpkgs#vscodium
2729
```
@@ -31,13 +33,15 @@ wrap -n -d -p nix run nixpkgs#vscodium
3133
> You need to run a `python` script that has access to your audio hardware.
3234
3335
Run a python script with Pulse Audio and Pipewire access, but not sharing the current working directory:
36+
3437
```shell
3538
wrap -a -p python my-tool.py
3639
```
3740

3841
## How to use
3942

4043
By default, Nixwrap will:
44+
4145
- ✅ Prevent network access. (Use `-n` to allow.)
4246
- ✅ Prevent access to Wayland and X. (Use `-d` (desktop) to allow.)
4347
- ✅ Prevent camera access. (Use `-c` to allow.)
@@ -51,9 +55,11 @@ By default, Nixwrap will:
5155
-**Allow** access to a set of [common environment variables](https://github.com/rti/nixwrap/blob/main/wrap.sh#L9).
5256

5357
#### General syntax:
58+
5459
`wrap [OPTIONS] [-- BWRAP_ARGS] PROGRAM_TO_WRAP_WITH_ARGS`
5560

5661
#### Options
62+
5763
```
5864
-d Allow Desktop access, Wayland, X11, and rendering hardware.
5965
-n Allow Network access.
@@ -68,26 +74,28 @@ By default, Nixwrap will:
6874
```
6975

7076
#### Advanced Options
77+
7178
```
72-
-p Do not share current working directory. By default wrap will share
73-
the current working directory as a write mount and cd into it
74-
before running the program. With this option, wrap will not share
79+
-p Do not share current working directory. By default wrap will share
80+
the current working directory as a write mount and cd into it
81+
before running the program. With this option, wrap will not share
7582
the directory and leave the current directory untouched.
7683
-f Force share current working directory. By default wrap will share
7784
the current working directory as a write mount and cd into it only
78-
if the directory does not match any of the following patterns:
85+
if the directory does not match any of the following patterns:
7986
^/$, ^/home$, ^\${HOME}$, ^/boot, ^/etc, ^/proc, ^/run, ^/sys, ^/var
80-
This option will bypass the check and share the directory regardless.
81-
-m Manual unsharing. By default wrap unshares ipc, net, pid, and uts
82-
and tries to unshare (continue on failues) user and cgroup
83-
namespaces. With this option, wrap does not automatically unshare
84-
any namespaces. Use together with bwrap --unshare-* options
87+
This option will bypass the check and share the directory regardless.
88+
-m Manual unsharing. By default wrap unshares ipc, net, pid, and uts
89+
and tries to unshare (continue on failues) user and cgroup
90+
namespaces. With this option, wrap does not automatically unshare
91+
any namespaces. Use together with bwrap --unshare-* options
8592
(man bwrap(1)) to unshare manually.
8693
```
8794

8895
### Wrap binaries via Nix
8996

9097
#### Flake
98+
9199
Add the Nixwrap flake as an input in your flake.
92100

93101
```nix
@@ -101,7 +109,9 @@ Add the Nixwrap flake as an input in your flake.
101109
```
102110

103111
#### Wrap a package
112+
104113
To wrap a package, use the function from `inputs.wrap.lib.wrap`. It takes the following arguments:
114+
105115
- `package` The package to wrap.
106116
- `executable` The name of the executable, optional, defaults to package name.
107117
- `wrapArgs` Arguments to wrap, see above.
@@ -135,7 +145,6 @@ This example installs `nodejs` in a devShell, but wraps `node` with Nixwrap, so
135145
pkgs = nixpkgs.legacyPackages.${system};
136146
in
137147
{
138-
139148
devShells.default = pkgs.mkShell {
140149
buildInputs = [
141150
(wrap.lib.${system}.wrap {
@@ -151,12 +160,14 @@ This example installs `nodejs` in a devShell, but wraps `node` with Nixwrap, so
151160
```
152161

153162
## Supported platforms
163+
154164
Nixwrap is at the moment tested exclusively on NixOS, even though the concept should work in any distribution that ships a current kernel.
155165

156166
## License
167+
157168
`wrap` is licensed under the MIT License. See the LICENSE file for more details.
158169

159170
## Similar projects
160171

161-
- https://git.sr.ht/~fgaz/nix-bubblewrap
162-
- https://github.com/Frontear/nix-wrap
172+
- https://git.sr.ht/~fgaz/nix-bubblewrap
173+
- https://github.com/Frontear/nix-wrap

0 commit comments

Comments
 (0)