Commit graph

108 commits

Author SHA1 Message Date
Alex David
54d4c6c0e7 Forward shellPath on shell derivations 2026-01-28 13:46:12 -08:00
Alex David
a06fc7d27f Use filesets to improve caching 2026-01-28 13:21:10 -08:00
Alex David
7a05b0f6cf Set up cachix 2026-01-28 12:46:54 -08:00
Alex David
26d2149e42 Update to ghc 9.12 2026-01-28 10:10:01 -08:00
Alex David
bf9f49c811 Update tests and website to nixpkgs-25.11 2025-12-16 08:50:53 -08:00
Alex David
eaf7e343d8 Fix network combinator with systemd resolved 2025-12-16 08:50:53 -08:00
Alex David
2f8e84bf0a Backfill tests for fwd-env and try-fwd-env 2025-12-16 08:50:53 -08:00
Josh Heinrichs
ff5dd74cbf Fix try-fwd-env setting unset variables
If an environment variable is unset, `try-fwd-env` will set it to an
empty string. This can cause issues for programs that treat unset and
empty environment variables differently. For instance, when jailing
Spotify with the `pulse` combinator, `$PULSE_SERVER` gets set to an
empty string, Spotify tries to use it as-is, fails, and then falls back
to using ALSA.

Ideally I would've liked to wire this into the existing env logic
somehow but it's a bit tricky to do since `--setenv` needs to be
provided to Bubblewrap conditionally based on a value that isn't known
until the script is executed. Bubblewrap appears to handle `--setenv`
being specified multiple times for the same variable okay, so not using
the existing env logic doesn't break the ability to override environment
variables.
2025-12-16 08:50:53 -08:00
Alex David
053e2c1364 Add no-die-with-parent combinator 2025-12-16 08:50:53 -08:00
Alex David
8f61c14085 Add repo to sources
Patches currently fail to build because the repo fails to check out
2025-11-30 12:49:48 -08:00
Alex David
98a6bd032c Add reset combinator 2025-11-10 11:50:37 -08:00
Alex David
7720833ef4 Fix wrap-entry not passing argv to entry 2025-11-07 09:56:37 -08:00
Alex David
f777a5e2f3 Fix wrong brackets in advanced configuration docs 2025-10-28 12:37:58 -07:00
Alex David
b843338efa Expose sh in $PATH in the base combinator
Some software reasonably expects `sh` to exist in PATH. I think I
haven't run into this before since a lot of nixified software explicitly
declares its dependencies on bash, but I've run into a few where this
isn't the case.
2025-10-26 10:06:06 -07:00
Alex David
ec9f9f98d8 Improve test apps
* Allow running test apps in repo root (e.g. `nix run ./tests#runTests`)
* Pass argv to cabal to allow filtering tests with `-m`
* Use `cabal run spec` rather than `cabal test`
2025-10-19 12:15:48 -07:00
Alex David
9e2f3895e9 Update readme
I took inspiration from ~whynothugo's repos for links to docs, source,
issues, etc... (e.g. https://git.sr.ht/~whynothugo/pimsync)
2025-10-19 11:51:46 -07:00
Alex David
1d8ec0b1cc Lock down GPU combinator
This is one of the original combinators I wrote for myself before even
open sourcing jail.nix. It was exposing all of `/sys` which is
unnecessary.

With this change, only `/sys/dev/char` is shared, (which should only
contain symlinks), and any PCI devices that contain a `drm` directory.
This seems to be the most reliable way I can tell of finding GPUs from
testing various combinations of distros and GPUs. The other signal seems
to be if `class` is `0x030000`, although I struggled to find
documentation where these classes are defined, and if they are in-fact
constant across all linux systems.

Anyway, this is a massive improvement over binding all of `/sys`, and
hopefully not a breaking change for anyone. If anyone runs into issues,
or has suggestions on better approaches I would love to hear it.
2025-10-19 11:30:21 -07:00
Alex David
0a6da614ea Add add-seccomp combinator
https://lists.sr.ht/~alexdavid/general/patches/62972
2025-10-18 22:54:19 -07:00
Alex David
5c3e611da7 Run fmt 2025-10-18 22:44:45 -07:00
Mathias Sven
9857627b48 Add tests for the seccomp combinator 2025-10-18 22:44:01 -07:00
Mathias Sven
23bf74dad6 Add add-seccomp combinator
This combinator allows for the use of bubblewrap's `--add-seccomp-fd`
option. Since multiple invocations of this combinator are allowed, this
commit also introduces a new state attribute `seccompPermissions`.

The implementation uses `test -x` against the given argument to decide
whether to use input redirection to a FD or process substitution.
2025-10-18 22:44:01 -07:00
Alex David
d596e0bc81 Fix time-zone combinator on missing /etc/localtime
Thanks ~charlie-collard for reporting this

Fixes https://todo.sr.ht/~alexdavid/jail.nix/2
2025-10-14 19:38:49 -07:00
Alex David
b42ed9103f Add link to matrix channel to readme 2025-10-13 18:19:09 -07:00
Alex David
f55483fb38 Forward override to jailed derivations
On Nixos, it may be desirable to install some software using
`programs.*.enable = true`. Jail.nix mostly supports this because you
can either use `jail-nix.mkOverlay`, or just use Nixos
`programs.*.package = jail ...` to inject a jailed version of the
package.

However, for some modules, like Firefox, the Nixos module calls
`override` on the package. Normally, you would just call `override` on
the package passed into jail, but this is not possible to do within a
Nixos module.

To address this, this patch will check to see if a package passed into
jail has an `override` field, and if so will add an `override` on the
jailed derivation that passes the override function to the entrypoint.

Thanks to ~juanjakobo for reporting this!

Fixes https://todo.sr.ht/~alexdavid/jail.nix/1
2025-10-13 16:06:29 -07:00
Alex David
fc6e1a54ba Add link to issue tracker 2025-10-11 17:41:40 -07:00
Alex David
92b37dfee1 Improve share-ns doc 2025-10-10 22:51:25 -07:00
Alex David
dffe5d150c Update readonly-paths-from-var test case
In 8fa6d132e1, ~mathiassven submitted a
patch that fixes the `readonly-paths-from-var` combinator omitting the
final path.

The tests didn't catch this since the final path in the test was a
non-existent path.

This commit backfills the test to catch regressions related to this bug.
The test now makes sure that the first, last, and at least one middle
test path are real paths that show up in the jail.
2025-10-10 16:45:13 -07:00
Alex David
b0a8a22983 Pull remaining default perms into base combinator
`base-permissions.nix` was the source of truth for all of the base
combinators, but it was not documented well anywhere.

To make this easier and more obvious for users, this commit pulls all
remaining custom permissions into a new `base` combinator which is
included by default. This way there is no more undocumented permissions
included by default, they are all documented in the `Default included
combinators` section of the docs.

This should also make it easier to override base permissions because
users can now just specify `base` instead of all of the
`unsafe-add-raw-args` calls unless they really want to change them.
2025-10-10 16:28:45 -07:00
Alex David
e45e8a7ccb Only forward valid URLs in open-urls-in-browser
This is unlikely to be exploited since the combinator only allows a
single argument and is not parsed by any shell, but it seems like a good
thing to ensure that only valid non-local URLs will be forwarded to
$BROWSER.
2025-10-10 16:28:45 -07:00
Alex David
977c3f2426 Add notifications combinator 2025-10-10 16:28:45 -07:00
Alex David
c4fb625497 Add website#serve app 2025-10-10 16:28:45 -07:00
Alex David
6181276ae1 Split combinators into files
The `lib/combinators.nix` file was getting quite long and some ideas I
have for future combinators may even require ancillary files. To help
scale these changes, this commit breaks each combinator into its own
file under the `lib/combinators` directory.
2025-10-10 16:28:43 -07:00
Mathias Sven
8fa6d132e1 Fix readonly-paths-from-var trailing DIR 2025-10-10 13:23:05 -07:00
Alex David
61b0a147af Use coreutils from nixpkgs rather than from PATH
Before this change, combinators that call `add-runtime` were assuming
coreutils were available, however `add-runtime` did not inject coreutils
as a runtime input.

This also removes forwarding $PATH in the tests which should catch any
issues like this in the future.

Thanks Epsylon for the report:
https://lists.sr.ht/~alexdavid/general/%3C331f3203-d6bf-4c53-824c-4d05088ec47e@gmail.com%3E
2025-10-03 10:53:39 -07:00
Alex David
22ec74b9d1 Add pushState helper 2025-09-28 15:58:58 -07:00
Alex David
3610987241 Allow multiple calls to dbus combinator
Before this change, additional calls to the dbus combinator would add
multiple `xdg-dbus-proxy` instances, but only the latest call would be
forwarded into the jail.

With this change, all permissions are saved in state, then, in a
deferred `add-runtime` we add a single `xdg-dbus-proxy` exposing the
union of all previous dbus calls.

This should allow writing combinators that expose dbus permissions like
notifications, or reading light/dark mode changes which can be composed
just like the other non-dbus combinators.
2025-09-28 15:44:36 -07:00
Alex David
7f20103af7 Explicitly declare ghc version for tests 2025-09-27 21:48:39 -07:00
Alex David
3ccf1d42e2 Add try-* bind combinators 2025-09-27 10:51:19 -07:00
Alex David
25fe216eec Fix signature of open-urls-in-browser combinator 2025-09-15 22:26:44 -07:00
Alex David
45c2b47d71 Fix time-zone combinator
Most software that wants to know the timezone reads the symlink in
`/etc/localtime`. A previous update broke this assumption when
attempting to fix the combinator to work on non-NixOS systems.

This change should fix the time-zone combinator in both NixOS and
non-NixOS systems.
2025-09-15 22:26:44 -07:00
Alex David
700189112f Format nix files with nixfmt-tree 2025-09-11 07:31:48 -07:00
Alex David
09d0c55e12 Add link to getting started docs in readme 2025-09-04 15:10:25 -07:00
Alex David
2cef740876 Bind bash to /bin/sh
This fixes a bug on non-nixos systems where bash may not be statically
linked.
2025-09-04 15:08:47 -07:00
Alex David
39f7aaef09 Fix typo in website docs 2025-09-04 14:32:19 -07:00
Alex David
6fbd3729cc Add mkOverlay 2025-09-02 15:39:40 -07:00
Alex David
8b6484c870 Generate random DBus bus names for tests 2025-09-01 21:57:41 -07:00
Alex David
0532ce0e88 Remove unused let in 2025-09-01 21:47:48 -07:00
Alex David
d35e9df391 Add open-urls-in-browser combinator 2025-09-01 21:47:48 -07:00
Alex David
f5cc61ef63 Add jail-to-host-channel combinator 2025-09-01 21:47:48 -07:00
Alex David
7dc202a5a7 Add dbus combinator 2025-09-01 21:47:48 -07:00