Commit graph

74 commits

Author SHA1 Message Date
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
Alex David
275a1296e7 Fix network combinator binding too many paths 2025-09-01 21:47:48 -07:00
Alex David
d8b14ca5ee Rewrite tests in haskell 2025-08-27 12:14:55 -07:00
Alex David
b28610bb1e Bind write-text/bind-pkg runtime closure
39ca901 introduced only bind-mounting in the individual store paths that
make up the runtime closure for the jail. However, in practice I found a
few jails that were using `write-text` for configuration files that
referenced other store paths were no longer being bind mounted into the
jail.

I think it's reasonable that if you `write-text` or `bind-pkg`, and it
has runtime dependencies, those dependencies should be made available to
the jail.
2025-08-27 12:14:55 -07:00
Alex David
7d3efead61 Only expose runtime closure by default
Instead of binding the entire `/nix/store`. This behavior can be changed
by overriding `basePermissions`.
2025-08-27 12:14:55 -07:00
Alex David
cd825bf411 Fix missing '' in add-cleanup docs
This one is a bit confusing since these docs document a nix multi-line
string within a multi-line string, *and* there is a bash interpolation
within. We want the docs to render as `if [ -e "''${TMPFILE-}" ]`, since
the docs are within a multi-line string.

Sorry in advance for anyone attempting to parse this in the nix source
code instead of the docs website :(.
2025-08-27 12:14:55 -07:00
Alex David
fa989aa4fc Fix add-path docs
06c7210 changed this to prepend paths, but didn't update the docs.
2025-08-27 12:14:55 -07:00
Alex David
d966d48182 Add Permission description to combinators docs 2025-08-27 12:14:55 -07:00
Alex David
8fe97d2ece Link to markdown files rather than relative links
Instead of needing to manually figure out these links, mkdocs will
automatically generate the correct relative path if you link to `.md`
files. Neat!
2025-08-15 08:31:06 -07:00
Alex David
1f6ae5d5b1 Add CI badge to readme 2025-08-15 08:19:53 -07:00
Alex David
1f3db346eb Update documentation nixpkgs branch 2025-08-15 08:14:35 -07:00
Alex David
1f7587326e Don't parallelize tests
On CI this causes them to be flaky since sometimes they output
`error (ignored): error: SQLite database ... is busy`.
2025-08-15 08:12:21 -07:00
Alex David
c37ae887fd Allow consuming jail.nix without flakes 2025-08-15 08:06:02 -07:00
Alex David
d8500ab273 Move fake-passwd into combinators 2025-08-07 17:26:51 -07:00
Alex David
5e86199537 Include deprecated combinators in the docs 2025-08-07 17:23:52 -07:00
Alex David
2ca02c8bfe Use camelCase for state attributes 2025-08-07 16:36:13 -07:00
Alex David
595bc0e2e4 Allow overriding bubblewrap 2025-08-07 16:32:58 -07:00
Alex David
06c7210127 Refactor path handling
* Moves the default coreutils path into base permissions to allow
  override.
* Makes paths defined *later* in the permissions list appear *earlier*
  which should have the effect of later calls to `add-path` override
  binaries provided by earlier ones.
* Makes the `path` variable on state a list rather than a string.
2025-08-07 16:26:18 -07:00
Alex David
7f17289a72 Add CI 2025-08-07 15:59:48 -07:00
Alex David
c7685334cf Restructure source 2025-08-07 15:54:50 -07:00
Alex David
09edd097b9 Clean up combinator/permission naming
The term `combinator` was overloaded before, being used to refer both to
the functions that are exposed to help build a jail, and their return
value to be passed into `jail`/`basePermissions`. This commit renames
the latter to `Permission`.
2025-08-07 15:42:36 -07:00
Alex David
f18f1cf701 Allow overriding jail base permissions 2025-08-07 15:29:16 -07:00
Alex David
24de419827 Create dconf config dir if it doesn't exist 2025-07-21 20:26:12 -07:00
Alex David
aa544c66a3 Allow unset XCURSOR_* vars for gui combinator 2025-07-21 20:21:03 -07:00
Alex David
ac316857f4 Allow unset readonly-paths-from-var variable 2025-07-21 20:19:50 -07:00
Alex David
ba42171b16 Add readonly-paths-from-var combinator 2025-07-18 11:30:55 -07:00
Alex David
3abb0273cd Add app to run all tests with nice output 2025-07-18 10:46:48 -07:00
Alex David
38b5138956 Add initial simple test cases 2025-07-17 20:25:17 -07:00
Alex David
921b443cc9 Remove which in builtin passwd combinator
This remove the requirement on `which` binary when running any jail.
This was preventing jailed apps from running within nix sandbox without
manually specifying `pkgs.which` as a build input.
2025-07-17 20:23:20 -07:00
Alex David
8dc2189e08 Add combinators to bind runtime args
This adds `readonly-runtime-args` and `readwrite-runtime-args`
combinators.
2025-07-14 21:10:30 -07:00
Alex David
c5ba72dc5a Make combinators available at jail.combinators
Instead of requiring the third argument to be a function that passes in
combinators, this exposes all combinators on `jail.combinators` and
allows the third argument to just be a list (or even null!). This may be
more ergonomic in some contexts (like nixpkgs overlays).

This isn't a breaking change, the third argument can still be a function
and will receive the combinators if it is.
2025-07-11 11:44:12 -07:00
Alex David
2f6e7c3078 Improve docs 2025-07-11 11:16:47 -07:00
Alex David
b10ff57b1e Add cleanup combinator 2025-06-14 22:11:21 -07:00
Alex David
fce1224bdd Use __functor to simplify combinators
By using `__functor` combinators can call each other directly by using
`rec` rather than needing to mapAttrs over all of the combinators to
inject them into each one.
2025-06-13 22:14:13 -07:00
Alex David
313d10b952 Improve add-runtime documentation 2025-06-07 20:12:40 -07:00