Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

srid/landrun-nix

Nix flake-parts module for landrun (wrap Nix paths in Landlock based sandbox)

srid/landrun-nix.json
{
"createdAt": "2025-10-10T23:09:16Z",
"defaultBranch": "master",
"description": "Nix flake-parts module for landrun (wrap Nix paths in Landlock based sandbox)",
"fullName": "srid/landrun-nix",
"homepage": null,
"language": "Nix",
"name": "landrun-nix",
"pushedAt": "2025-11-10T19:35:45Z",
"stargazersCount": 17,
"topics": [],
"updatedAt": "2025-11-10T19:35:49Z",
"url": "https://github.com/srid/landrun-nix"
}

GitHub Discussions

A Nix flake-parts module for wrapping programs with landrun (Landlock) sandbox.

In your flake.nix:

{
inputs.landrun-nix.url = "github:srid/landrun-nix";
outputs = { flake-parts, landrun-nix, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ landrun-nix.flakeModule ];
perSystem = { pkgs, ... }: {
landrunApps.my-app-sandboxed = {
program = "${pkgs.my-app}/bin/my-app";
features = {
tty = true; # Terminal support
nix = true; # Nix store access (default)
network = true; # Network access
tmp = true; # /tmp access (default)
};
# Raw arguments to pass to `landrun` CLI
cli = {
rw = [ "$HOME/.config/my-app" ];
rox = [ "/etc/hosts" ];
};
};
};
};
}

Run with: nix run .#my-app-sandboxed

landrun-nix provides reusable modules for common applications via landrunModules.*. These can be imported into your app configurations:

{
inputs.landrun-nix.url = "github:srid/landrun-nix";
outputs = { flake-parts, landrun-nix, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ landrun-nix.flakeModule ];
perSystem = { pkgs, ... }: {
landrunApps.my-app = {
imports = [
landrun-nix.landrunModules.gh # Import GitHub CLI module
];
program = "${pkgs.my-app}/bin/my-app";
features.network = true;
};
};
};
}
ModuleDescription
landrunModules.ghGitHub CLI (gh) configuration with D-Bus keyring support
landrunModules.gitGit configuration with TTY support and repository access
landrunModules.haskellHaskell tooling with Cabal configuration and state directory access
landrunModules.markitdownMarkitdown configuration with /proc/cpuinfo access

Sandbox Claude Code with access to project directory, config files, and network.

See [examples/claude-sandboxed]!(./examples/claude-sandboxed/flake.nix) for a complete working example.

Try it:

Terminal window
nix run github:srid/landrun-nix?dir=examples/claude-sandboxed

High-level feature flags automatically configure common sandboxing patterns:

FeatureDefaultDescription
features.ttyfalseTTY devices, terminfo, locale env vars
features.nixtrueNix store, system paths, PATH env var
features.networkfalseDNS resolution, SSL certificates, unrestricted network
features.tmptrueRead-write access to /tmp
features.dbusfalseD-Bus session bus, keyring access for Secret Service API

Fine-grained control via cli.*:

OptionDescription
roxRead-only + execute paths
roRead-only paths
rwxRead-write-execute paths
rwRead-write paths
envEnvironment variables to pass through
unrestrictedNetworkAllow all network access
addExecAuto-add executable to rox (default: true)

https://github.com/srid/landrun-nix/discussions

GPL-3.0

From the original announcement post:

  • nixpak: a fancy declarative wrapper around bubblewrap.
  • jail.nix: helper to make it easy and ergonomic to wrap your derivations in bubblewrap.