• Nix 51.2%
  • Haskell 48.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-06 11:34:09 +02:00
lib Add combinators for system dbus access 2026-10-06 11:34:09 +02:00
tests Handle errors from runNixDrv better 2026-09-08 20:58:56 -07:00
website Update tests/website flakes to 26.05 2026-07-08 10:45:14 -07:00
.build.yml Update tests/website flakes to 26.05 2026-07-08 10:45:14 -07:00
default.nix Allow consuming jail.nix without flakes 2025-08-15 08:06:02 -07:00
flake.nix Restructure source 2025-08-07 15:54:50 -07:00
LICENSE Add initial spike 2025-04-27 12:07:03 -07:00
README.md Add Codeberg links to README 2026-08-31 11:58:01 -07:00

jail.nix builds.sr.ht status

Docs | SourceHut Issues / Patches | Codeberg Issues / Patches | Matrix

A helper to make it easy and ergonomic to wrap your derivations in bubblewrap.

Getting Started

Documentation to install and get started can be found here.

Example

# flake.nix
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
  inputs.jail-nix.url = "sourcehut:~alexdavid/jail.nix";

  outputs = { nixpkgs, jail-nix, ... }: let
    pkgs = import nixpkgs { system = "x86_64-linux"; };
    jail = jail-nix.lib.init pkgs;

    untrusted-package = pkgs.writeScriptBin "untrusted" ''
      ls -la $HOME
    '';
  in {
    packages.x86_64-linux.jailed = jail "my-jail" untrusted-package (with jail.combinators; [
      # See combinators section below for more functions that can go here

      # Give program access to the network
      network

      # Allow program to create windows
      gui

      # Give program access to the GPU
      gpu

      # Give program read-only access to /var/log/journal
      (readonly "/var/log/journal")

      # Mount ~/foo to /bar in the jail as read-write
      # (noescape due to `~` — all arguments are shell escaped by default)
      (rw-bind (noescape "~/foo") "/bar")
    ]);
  };
}

Combinators

By default, only the bare minimum permissions are exposed. By passing combinators into the jail you can modify the jail to expose more permissions.

Click here for a full list of combinators and their documentation.

Help / Comments / Suggestions

I am working on docs with examples of combinators for various common software projects, but this isn't finished yet. In the meantime, if you need help jailing software, run into issues, or have suggestions, feel free to join #jail.nix:woh.place on matrix, or open an issue.