Compare commits
10 commits
42b355c38c
...
a057ce75e9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a057ce75e9 | ||
|
|
d246c4b5da | ||
|
|
6c68b722cc | ||
|
|
9e4e4b82d4 | ||
|
|
9c04e65bca | ||
|
|
404e7da9da | ||
|
|
731ba22f60 | ||
|
|
7acd363b6d | ||
|
|
49aa817e4f | ||
|
|
da894f6e13 |
19 changed files with 309 additions and 142 deletions
|
|
@ -1,4 +1,4 @@
|
|||
image: nixos/25.05
|
||||
image: nixos/26.05
|
||||
environment:
|
||||
NIX_CONFIG: "experimental-features = nix-command flakes"
|
||||
secrets:
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
_: import ./lib
|
||||
_: { lib = import ./lib; }
|
||||
|
|
|
|||
|
|
@ -1,107 +1,51 @@
|
|||
pkgs: jail:
|
||||
{
|
||||
pkgs,
|
||||
suppressExperimentalWarnings ? false,
|
||||
...
|
||||
}:
|
||||
jail:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
helpers = import ./helpers.nix pkgs;
|
||||
|
||||
rawCombinators =
|
||||
lib.mapAttrs
|
||||
(
|
||||
_: file:
|
||||
import file {
|
||||
inherit
|
||||
combinators
|
||||
helpers
|
||||
jail
|
||||
lib
|
||||
pkgs
|
||||
;
|
||||
}
|
||||
)
|
||||
{
|
||||
add-cleanup = ./combinators/add-cleanup.nix;
|
||||
add-path = ./combinators/add-path.nix;
|
||||
add-pkg-deps = ./combinators/add-pkg-deps.nix;
|
||||
add-runtime = ./combinators/add-runtime.nix;
|
||||
add-seccomp = ./combinators/add-seccomp.nix;
|
||||
base = ./combinators/base.nix;
|
||||
bind-nix-store-runtime-closure = ./combinators/bind-nix-store-runtime-closure.nix;
|
||||
bind-pkg = ./combinators/bind-pkg.nix;
|
||||
camera = ./combinators/camera.nix;
|
||||
compose = ./combinators/compose.nix;
|
||||
dbus = ./combinators/dbus.nix;
|
||||
defer = ./combinators/defer.nix;
|
||||
escape = ./combinators/escape.nix;
|
||||
fake-passwd = ./combinators/fake-passwd.nix;
|
||||
fwd-env = ./combinators/fwd-env.nix;
|
||||
gpu = ./combinators/gpu.nix;
|
||||
gui = ./combinators/gui.nix;
|
||||
include-once = ./combinators/include-once.nix;
|
||||
jail-to-host-channel = ./combinators/jail-to-host-channel.nix;
|
||||
mount-cwd = ./combinators/mount-cwd.nix;
|
||||
network = ./combinators/network.nix;
|
||||
no-die-with-parent = ./combinators/no-die-with-parent.nix;
|
||||
no-new-session = ./combinators/no-new-session.nix;
|
||||
noescape = ./combinators/noescape.nix;
|
||||
notifications = ./combinators/notifications.nix;
|
||||
open-urls-in-browser = ./combinators/open-urls-in-browser.nix;
|
||||
persist-home = ./combinators/persist-home.nix;
|
||||
pipewire = ./combinators/pipewire.nix;
|
||||
pulse = ./combinators/pulse.nix;
|
||||
readonly = ./combinators/readonly.nix;
|
||||
readonly-paths-from-var = ./combinators/readonly-paths-from-var.nix;
|
||||
readonly-runtime-args = ./combinators/readonly-runtime-args.nix;
|
||||
readwrite = ./combinators/readwrite.nix;
|
||||
readwrite-runtime-args = ./combinators/readwrite-runtime-args.nix;
|
||||
reset = ./combinators/reset.nix;
|
||||
ro-bind = ./combinators/ro-bind.nix;
|
||||
runtime-deep-ro-bind = ./combinators/runtime-deep-ro-bind.nix;
|
||||
rw-bind = ./combinators/rw-bind.nix;
|
||||
set-argv = ./combinators/set-argv.nix;
|
||||
set-env = ./combinators/set-env.nix;
|
||||
set-hostname = ./combinators/set-hostname.nix;
|
||||
share-ns = ./combinators/share-ns.nix;
|
||||
time-zone = ./combinators/time-zone.nix;
|
||||
tmpfs = ./combinators/tmpfs.nix;
|
||||
try-fwd-env = ./combinators/try-fwd-env.nix;
|
||||
try-readonly = ./combinators/try-readonly.nix;
|
||||
try-readwrite = ./combinators/try-readwrite.nix;
|
||||
try-ro-bind = ./combinators/try-ro-bind.nix;
|
||||
try-rw-bind = ./combinators/try-rw-bind.nix;
|
||||
unsafe-add-raw-args = ./combinators/unsafe-add-raw-args.nix;
|
||||
unsafe-dbus = ./combinators/unsafe-dbus.nix;
|
||||
unsafe-x11 = ./combinators/unsafe-x11.nix;
|
||||
wayland = ./combinators/wayland.nix;
|
||||
wrap-entry = ./combinators/wrap-entry.nix;
|
||||
write-text = ./combinators/write-text.nix;
|
||||
xwayland = ./combinators/xwayland.nix;
|
||||
rawCombinators = lib.mapAttrs' (
|
||||
fileName: _:
|
||||
lib.nameValuePair (lib.removeSuffix ".nix" fileName) (
|
||||
import ./combinators/${fileName} {
|
||||
inherit
|
||||
combinators
|
||||
helpers
|
||||
jail
|
||||
lib
|
||||
pkgs
|
||||
;
|
||||
}
|
||||
//
|
||||
############################################
|
||||
# deprecated combinators:
|
||||
{
|
||||
persisthome = {
|
||||
deprecated = true;
|
||||
sig = "Permission";
|
||||
doc = "This was reworked to store data under `~/.local/share/jail.nix` and renamed to [persist-home](#persist-home).";
|
||||
impl =
|
||||
with combinators;
|
||||
name:
|
||||
lib.warn
|
||||
"persisthome is deprecated, use persist-home instead. When doing so, rename ~/.local/share/jails/${name} to ${helpers.dataDirSubPath "home/${name}"}"
|
||||
(compose [
|
||||
(add-runtime "mkdir -p ~/.local/share/jails/${lib.escapeShellArg name}")
|
||||
(rw-bind (noescape "~/.local/share/jails/${lib.escapeShellArg name}") (noescape "~"))
|
||||
]);
|
||||
};
|
||||
)
|
||||
) (builtins.readDir ./combinators);
|
||||
|
||||
dbus-unsafe = {
|
||||
deprecated = true;
|
||||
sig = "Permission";
|
||||
doc = "This was renamed to [unsafe-dbus](#unsafe-dbus).";
|
||||
impl = lib.warn "dbus-unsafe is deprecated, use unsafe-dbus instead" combinators.unsafe-dbus;
|
||||
};
|
||||
};
|
||||
combinators = lib.mapAttrs (_: combinatorObj: combinatorObj.impl) rawCombinators;
|
||||
combinators =
|
||||
let
|
||||
foldCombinator =
|
||||
acc: names: combinator:
|
||||
if lib.length names == 0 then
|
||||
acc
|
||||
else
|
||||
let
|
||||
name = lib.head names;
|
||||
combinatorImpl =
|
||||
if combinator.experimental or false && !suppressExperimentalWarnings then
|
||||
builtins.warn "jail.nix combinator ${name} is experimental!" combinator.impl
|
||||
else
|
||||
combinator.impl;
|
||||
in
|
||||
if acc ? ${name} then
|
||||
throw "duplicate combinator ${name}"
|
||||
else
|
||||
foldCombinator (acc // { ${name} = combinatorImpl; }) (lib.tail names) combinator;
|
||||
in
|
||||
lib.foldl' (acc: { name, value }: foldCombinator acc ([ name ] ++ value.aliases or [ ]) value) { } (
|
||||
lib.attrsToList rawCombinators
|
||||
);
|
||||
in
|
||||
{
|
||||
inherit combinators;
|
||||
|
|
|
|||
32
lib/combinators/overlay-ro.nix
Normal file
32
lib/combinators/overlay-ro.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{ combinators, ... }:
|
||||
let
|
||||
inherit (combinators) escape unsafe-add-raw-args;
|
||||
in
|
||||
{
|
||||
experimental = true;
|
||||
sig = "[String] -> String -> Permission";
|
||||
doc = ''
|
||||
Creates a readonly overlay fs mount at a destination.
|
||||
|
||||
The first argument is a list of sources to be composed, the second is the
|
||||
destination in the jail where to mount the overlayfs.
|
||||
|
||||
If multiple sources contain the same files, sources specified later in the
|
||||
sources list will shadow earlier ones.
|
||||
|
||||
At least one source must be specified.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
overlay-ro ["/source/foo" "/source/bar"] "/dest"
|
||||
```
|
||||
'';
|
||||
impl =
|
||||
sources: dest:
|
||||
assert builtins.length sources > 0;
|
||||
unsafe-add-raw-args (
|
||||
builtins.concatStringsSep " " (
|
||||
map (source: "--overlay-src ${escape source}") sources ++ [ "--ro-overlay ${escape dest}" ]
|
||||
)
|
||||
);
|
||||
}
|
||||
39
lib/combinators/overlay-rw.nix
Normal file
39
lib/combinators/overlay-rw.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{ combinators, ... }:
|
||||
let
|
||||
inherit (combinators) escape unsafe-add-raw-args;
|
||||
in
|
||||
{
|
||||
experimental = true;
|
||||
sig = "[String] -> String -> String -> String -> Permission";
|
||||
doc = ''
|
||||
Creates an overlay fs mount at a destination.
|
||||
|
||||
The first argument is a list of sources to be composed.
|
||||
|
||||
The second argument is the rw source, a directory to persist writes to.
|
||||
|
||||
The third argument is the workdir, a scratch space the kernel uses for the
|
||||
overlayFS (it must be on the same filesystem as the rw source).
|
||||
|
||||
The final argument is the destination in the jail where to mount the overlayfs.
|
||||
|
||||
If multiple sources contain the same files, sources specified later in the
|
||||
sources list will shadow earlier ones.
|
||||
|
||||
At least one source must be specified.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
overlay-rw ["/source/foo" "/source/bar"] "/tmp/rw" "/tmp/workdir" "/dest"
|
||||
```
|
||||
'';
|
||||
impl =
|
||||
sources: rwSource: workdir: dest:
|
||||
assert builtins.length sources > 0;
|
||||
unsafe-add-raw-args (
|
||||
builtins.concatStringsSep " " (
|
||||
map (source: "--overlay-src ${escape source}") sources
|
||||
++ [ "--overlay ${escape rwSource} ${escape workdir} ${escape dest}" ]
|
||||
)
|
||||
);
|
||||
}
|
||||
32
lib/combinators/overlay-tmp.nix
Normal file
32
lib/combinators/overlay-tmp.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{ combinators, ... }:
|
||||
let
|
||||
inherit (combinators) escape unsafe-add-raw-args;
|
||||
in
|
||||
{
|
||||
experimental = true;
|
||||
sig = "[String] -> String -> Permission";
|
||||
doc = ''
|
||||
Creates a tempfs overlay mount at a destination.
|
||||
|
||||
The first argument is a list of sources to be composed, the second is the
|
||||
destination in the jail where to mount the overlayfs.
|
||||
|
||||
If multiple sources contain the same files, sources specified later in the
|
||||
sources list will shadow earlier ones.
|
||||
|
||||
At least one source must be specified.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
overlay-tmp ["/source/foo" "/source/bar"] "/dest"
|
||||
```
|
||||
'';
|
||||
impl =
|
||||
sources: dest:
|
||||
assert builtins.length sources > 0;
|
||||
unsafe-add-raw-args (
|
||||
builtins.concatStringsSep " " (
|
||||
map (source: "--overlay-src ${escape source}") sources ++ [ "--tmp-overlay ${escape dest}" ]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -31,11 +31,10 @@ in
|
|||
assert lib.isValidPosixName var;
|
||||
include-once "readonly-paths-from-var-${var}" (add-runtime ''
|
||||
IFS=${lib.escapeShellArg separator} read -ra DIRS <<< "''${${var}-}"
|
||||
for DIR in "''${DIRS[@]}"; do
|
||||
if [ -e "$DIR" ]; then
|
||||
P="$(realpath "$DIR")"
|
||||
if ((''${#DIRS[@]})); then
|
||||
while IFS= read -r -d ''' P; do
|
||||
RUNTIME_ARGS+=(--ro-bind "$P" "$P")
|
||||
fi
|
||||
done
|
||||
done < <(realpath -ezq -- "''${DIRS[@]}")
|
||||
fi
|
||||
'');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
{
|
||||
jailNixCfg@{
|
||||
pkgs,
|
||||
additionalCombinators ? _: { },
|
||||
basePermissions ? import ./base-permissions.nix pkgs,
|
||||
bubblewrapPackage ? pkgs.bubblewrap,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
|
||||
builtinCombinators = (import ./combinators.nix pkgs jail).combinators;
|
||||
builtinCombinators = (import ./combinators.nix jailNixCfg jail).combinators;
|
||||
|
||||
allCombinators = builtinCombinators // additionalCombinators builtinCombinators;
|
||||
|
||||
|
|
|
|||
8
tests/flake.lock
generated
8
tests/flake.lock
generated
|
|
@ -2,16 +2,16 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1769318308,
|
||||
"narHash": "sha256-Mjx6p96Pkefks3+aA+72lu1xVehb6mv2yTUUqmSet6Q=",
|
||||
"lastModified": 1783389287,
|
||||
"narHash": "sha256-0xIy4dVLqq47rA+mRy0hXDfjhQd4E5PoIns/RmB7nR4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1cd347bf3355fce6c64ab37d3967b4a2cb4b878c",
|
||||
"rev": "0ad6f47ea4fe188f4bc8f0380f93ae8523337c6c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-25.11",
|
||||
"ref": "nixos-26.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
# This is a separate flake file from the one at the root because we don't
|
||||
# want to depend on nixpkgs
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
||||
outputs =
|
||||
{ nixpkgs, ... }:
|
||||
let
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ spec = parallel $ inTestM $ do
|
|||
runNixDrv
|
||||
[i|
|
||||
let
|
||||
jail' = jail-nix.extend {
|
||||
jail' = jail-nix.lib.extend {
|
||||
inherit pkgs;
|
||||
bubblewrapPackage = pkgs.writeShellApplication {
|
||||
name = "my-bubblewrap";
|
||||
|
|
@ -284,6 +284,94 @@ spec = parallel $ inTestM $ do
|
|||
|]
|
||||
liftIO $ doesFileExist (tmpDir </> "fake-browser") `shouldReturn` False
|
||||
|
||||
describe "overlay combinators" $ do
|
||||
let runOverlayTest :: String -> String -> TestM String
|
||||
runOverlayTest combinatorInvocation shellCmd = do
|
||||
tmpDir <- getTestDir
|
||||
let fooSource = tmpDir </> "source/foo"
|
||||
let barSource = tmpDir </> "source/bar"
|
||||
let rwSource = tmpDir </> "rwSource"
|
||||
let workDir = tmpDir </> "workDir"
|
||||
liftIO $ do
|
||||
createDirectoryIfMissing True fooSource
|
||||
createDirectoryIfMissing True barSource
|
||||
createDirectoryIfMissing True rwSource
|
||||
createDirectoryIfMissing True workDir
|
||||
writeFile (fooSource </> "only-foo") "only-foo"
|
||||
writeFile (barSource </> "only-bar") "only-bar"
|
||||
writeFile (fooSource </> "both") "both-foo"
|
||||
writeFile (barSource </> "both") "both-bar"
|
||||
runNixDrv
|
||||
[i|
|
||||
let
|
||||
fooSource = "#{fooSource}";
|
||||
barSource = "#{barSource}";
|
||||
rwSource = "#{rwSource}";
|
||||
workDir = "#{workDir}";
|
||||
in
|
||||
jail "test" (sh "#{shellCmd}") (c: [
|
||||
(#{combinatorInvocation})
|
||||
])
|
||||
|]
|
||||
|
||||
describe "overlay-tmp" $ do
|
||||
let runTest = runOverlayTest [i| c.overlay-tmp [ fooSource barSource ] "/dest" |]
|
||||
it "overlays files from the sources list" $ do
|
||||
runTest "ls /dest"
|
||||
`shouldReturnTestM` unindent
|
||||
[i|
|
||||
both
|
||||
only-bar
|
||||
only-foo
|
||||
|]
|
||||
|
||||
it "uses sources specified later to shadow files specified in multiple sources" $ do
|
||||
runTest "cat /dest/both"
|
||||
`shouldReturnTestM` "both-bar"
|
||||
|
||||
it "creates a writable tmpfs overlay" $ do
|
||||
runTest "echo baz > /dest/baz && cat /dest/baz"
|
||||
`shouldReturnTestM` "baz\n"
|
||||
|
||||
describe "overlay-ro" $ do
|
||||
let runTest = runOverlayTest [i| c.overlay-ro [ fooSource barSource ] "/dest" |]
|
||||
it "overlays files from the sources list" $ do
|
||||
runTest "ls /dest"
|
||||
`shouldReturnTestM` unindent
|
||||
[i|
|
||||
both
|
||||
only-bar
|
||||
only-foo
|
||||
|]
|
||||
|
||||
it "uses sources specified later to shadow files specified in multiple sources" $ do
|
||||
runTest "cat /dest/both"
|
||||
`shouldReturnTestM` "both-bar"
|
||||
|
||||
it "mounts a read-only destination" $ do
|
||||
runTest "echo baz > /dest/baz || echo failed"
|
||||
`shouldReturnTestM` "failed\n"
|
||||
|
||||
describe "overlay-rw" $ do
|
||||
let runTest = runOverlayTest [i| c.overlay-rw [ fooSource barSource ] rwSource workDir "/dest" |]
|
||||
it "overlays files from the sources list" $ do
|
||||
runTest "ls /dest"
|
||||
`shouldReturnTestM` unindent
|
||||
[i|
|
||||
both
|
||||
only-bar
|
||||
only-foo
|
||||
|]
|
||||
|
||||
it "uses sources specified later to shadow files specified in multiple sources" $ do
|
||||
runTest "cat /dest/both"
|
||||
`shouldReturnTestM` "both-bar"
|
||||
|
||||
it "writes chagnes to the rw directory" $ do
|
||||
void $ runTest "echo baz > /dest/baz"
|
||||
tmpDir <- getTestDir
|
||||
liftIO $ readFile (tmpDir </> "rwSource/baz") `shouldReturn` "baz\n"
|
||||
|
||||
describe "readonly-paths-from-var" $ do
|
||||
forM_ [":", " "] $ \separator ->
|
||||
describe ("with separator \"" <> separator <> "\"") $ do
|
||||
|
|
@ -341,7 +429,7 @@ spec = parallel $ inTestM $ do
|
|||
it "clears all set permissions - including ones set in base permissions" $ do
|
||||
[i|
|
||||
let
|
||||
jail' = jail-nix.extend {
|
||||
jail' = jail-nix.lib.extend {
|
||||
inherit pkgs;
|
||||
basePermissions = c: [
|
||||
c.base
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ spec = parallel $ inTestM $ do
|
|||
it "can be imported using callPackage" $ do
|
||||
[i|
|
||||
let
|
||||
jail-nix-without-flake = pkgs.callPackage <jail-nix> {};
|
||||
jail-without-flake = jail-nix-without-flake.init pkgs;
|
||||
jail-nix-without-flake = import <jail-nix> {};
|
||||
jail-without-flake = jail-nix-without-flake.lib.init pkgs;
|
||||
in
|
||||
jail-without-flake "hello" pkgs.hello []
|
||||
|]
|
||||
|
|
@ -85,7 +85,7 @@ spec = parallel $ inTestM $ do
|
|||
liftIO $ writeFile secretPath "hunter2"
|
||||
[i|
|
||||
let
|
||||
jail' = jail-nix.extend {
|
||||
jail' = jail-nix.lib.extend {
|
||||
inherit pkgs;
|
||||
basePermissions = c: [
|
||||
(c.readonly #{toNixString secretPath})
|
||||
|
|
@ -101,7 +101,7 @@ spec = parallel $ inTestM $ do
|
|||
it "allows overriding the bubblewrap package" $ do
|
||||
[i|
|
||||
let
|
||||
jail' = jail-nix.extend {
|
||||
jail' = jail-nix.lib.extend {
|
||||
inherit pkgs;
|
||||
bubblewrapPackage = pkgs.writeShellApplication {
|
||||
name = "my-bubblewrap";
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ spec = parallel $ inTestM $ do
|
|||
let
|
||||
pkgs = import <nixpkgs> { overlays = [ jailOverlay ]; };
|
||||
jailOverlay = final: prev:
|
||||
jail-nix.mkOverlay {
|
||||
jail-nix.lib.mkOverlay {
|
||||
inherit final prev;
|
||||
packages = combinators: with combinators; {
|
||||
nodejs = [ (readonly #{toNixString $ tmpDir </> "visible"}) ];
|
||||
|
|
@ -53,7 +53,7 @@ spec = parallel $ inTestM $ do
|
|||
let
|
||||
pkgs = import <nixpkgs> { overlays = [ jailOverlay ]; };
|
||||
jailOverlay = final: prev:
|
||||
jail-nix.mkOverlay {
|
||||
jail-nix.lib.mkOverlay {
|
||||
inherit final prev;
|
||||
additionalCombinators = combinators: {
|
||||
my-combinator = combinators.readonly #{toNixString $ tmpDir </> "file"};
|
||||
|
|
@ -76,7 +76,7 @@ spec = parallel $ inTestM $ do
|
|||
let
|
||||
pkgs = import <nixpkgs> { overlays = [ jailOverlay ]; };
|
||||
jailOverlay = final: prev:
|
||||
jail-nix.mkOverlay {
|
||||
jail-nix.lib.mkOverlay {
|
||||
inherit final prev;
|
||||
basePermissions = combinators: [
|
||||
(combinators.readonly #{toNixString $ tmpDir </> "file"})
|
||||
|
|
@ -100,7 +100,7 @@ spec = parallel $ inTestM $ do
|
|||
let
|
||||
pkgs = import <nixpkgs> { overlays = [ jailOverlay ]; };
|
||||
jailOverlay = final: prev:
|
||||
jail-nix.mkOverlay {
|
||||
jail-nix.lib.mkOverlay {
|
||||
inherit final prev;
|
||||
bubblewrapPackage = pkgs.writeShellApplication {
|
||||
name = "my-bubblewrap";
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ runNixDrvWithinVm vmConfig nixDrvExpr = do
|
|||
};
|
||||
script = let
|
||||
jail-nix = import <jail-nix> {};
|
||||
jail = jail-nix.extend { inherit pkgs; };
|
||||
jail = jail-nix.lib.extend { inherit pkgs; suppressExperimentalWarnings = true; };
|
||||
testToRun = #{nixDrvExpr};
|
||||
in ''
|
||||
(
|
||||
|
|
@ -204,7 +204,7 @@ evalNixExpr nixExpr = do
|
|||
lib = pkgs.lib;
|
||||
sh = script: (pkgs.writeShellApplication { name = "test-script"; text = script; });
|
||||
jail-nix = import <jail-nix> {};
|
||||
jail = jail-nix.extend { inherit pkgs; };
|
||||
jail = jail-nix.lib.extend { inherit pkgs; suppressExperimentalWarnings = true; };
|
||||
in #{nixExpr}
|
||||
|]
|
||||
liftIO $
|
||||
|
|
|
|||
8
website/flake.lock
generated
8
website/flake.lock
generated
|
|
@ -2,16 +2,16 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1769318308,
|
||||
"narHash": "sha256-Mjx6p96Pkefks3+aA+72lu1xVehb6mv2yTUUqmSet6Q=",
|
||||
"lastModified": 1783389287,
|
||||
"narHash": "sha256-0xIy4dVLqq47rA+mRy0hXDfjhQd4E5PoIns/RmB7nR4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1cd347bf3355fce6c64ab37d3967b4a2cb4b878c",
|
||||
"rev": "0ad6f47ea4fe188f4bc8f0380f93ae8523337c6c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-25.11",
|
||||
"ref": "nixos-26.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
# This is a separate flake file from the one at the root because we don't
|
||||
# want to depend on nixpkgs
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs, ... }:
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
lib = pkgs.lib;
|
||||
|
||||
repo = rec {
|
||||
rev = if self ? rev then self.rev else lib.warn "Repo is dirty, links will not work!" "???";
|
||||
rev = if self ? rev then self.rev else lib.warn "Repo is dirty, links point to main!" "main";
|
||||
shortRev = lib.substring 0 8 rev;
|
||||
urls = {
|
||||
base = "https://git.sr.ht/~alexdavid/jail.nix";
|
||||
|
|
@ -34,9 +34,16 @@
|
|||
in
|
||||
''
|
||||
### ${name}
|
||||
<a class="source" href="${repo.urls.file file attrPos.line}">Source</a>
|
||||
|
||||
**${name} :: ${combinatorObj.sig}**
|
||||
|
||||
[Source](${repo.urls.file file attrPos.line})
|
||||
${
|
||||
if combinatorObj ? aliases then
|
||||
"Aliases: ${lib.concatMapStringsSep ", " (alias: "`${alias}`") combinatorObj.aliases}"
|
||||
else
|
||||
""
|
||||
}
|
||||
|
||||
${combinatorObj.doc}
|
||||
'';
|
||||
|
|
@ -44,7 +51,9 @@
|
|||
combinatorDocs =
|
||||
let
|
||||
allCombinators =
|
||||
(import (docsFileSet + /lib/combinators.nix) pkgs (throw "Docs must not depend on jail arg")).docs;
|
||||
(import (docsFileSet + /lib/combinators.nix) { inherit pkgs; } (
|
||||
throw "Docs must not depend on jail arg"
|
||||
)).docs;
|
||||
|
||||
formatSection =
|
||||
filter:
|
||||
|
|
@ -75,7 +84,7 @@
|
|||
|
||||
${hr}
|
||||
|
||||
${formatSection (v: !(is "deprecated" v || is "includedInBasePermissions" v || is "internal" v))}
|
||||
${formatSection (v: !(is "includedInBasePermissions" v || is "internal" v || is "experimental" v))}
|
||||
|
||||
${hr}
|
||||
|
||||
|
|
@ -89,12 +98,17 @@
|
|||
|
||||
${hr}
|
||||
|
||||
## Deprecated Combinators
|
||||
## Experimental Combinators
|
||||
|
||||
The following combinators have been deprecated, and may be removed in the
|
||||
future.
|
||||
The following combinators are experimental, and may be removed, or
|
||||
have breaking changes in the future. Please reach out if you have any
|
||||
feedback on them.
|
||||
|
||||
${formatSection (is "deprecated")}
|
||||
Using these combinators will emit an evaluation warning, you can
|
||||
suppress this warning with
|
||||
[suppressExperimentalWarnings](advanced-configuration.md#suppressexperimentalwarnings).
|
||||
|
||||
${formatSection (is "experimental")}
|
||||
'';
|
||||
|
||||
mkdocsSettings = {
|
||||
|
|
@ -104,6 +118,7 @@
|
|||
name = "readthedocs";
|
||||
hljs_languages = [ "nix" ];
|
||||
};
|
||||
extra_css = [ "extra.css" ];
|
||||
# Copyright is placed directly into the page within a <p> tag.
|
||||
# Concatenating with </p><p> here is super janky, but good enough for
|
||||
# now.
|
||||
|
|
|
|||
|
|
@ -76,3 +76,9 @@ jail = jail-nix.lib.extend {
|
|||
|
||||
This configuration option allows you to override what bubblewrap package
|
||||
jail.nix uses for its jails. The default value is `pkgs.bubblewrap`.
|
||||
|
||||
## suppressExperimentalWarnings
|
||||
|
||||
By default, jail.nix will emit an evaluation warning if you use an
|
||||
[experimental combinator](combinators.md#experimental-combinators). Setting
|
||||
this to true suppresses these warnings.
|
||||
|
|
|
|||
9
website/static-docs/extra.css
Normal file
9
website/static-docs/extra.css
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
.document {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
a.source {
|
||||
position: absolute;
|
||||
margin-top: -48px;
|
||||
right: 0;
|
||||
}
|
||||
|
|
@ -17,17 +17,17 @@ To install jail.nix using flakes, add jail.nix to your flake inputs:
|
|||
}
|
||||
```
|
||||
|
||||
### callPackage
|
||||
### Non-flakes
|
||||
|
||||
To install jail.nix using a different dependency manager like
|
||||
[niv](https://github.com/nmattia/niv), you can use `pkgs.callPackage`:
|
||||
[niv](https://github.com/nmattia/niv), you can use the following snippet:
|
||||
|
||||
```nix
|
||||
let
|
||||
sources = import ./nix/sources.nix;
|
||||
pkgs = import sources.nixpkgs {};
|
||||
jail-nix = pkgs.callPackage sources."jail.nix" {};
|
||||
jail = jail-nix.init pkgs;
|
||||
jail-nix = import sources."jail.nix" {};
|
||||
jail = jail-nix.lib.init pkgs;
|
||||
in
|
||||
# ...
|
||||
```
|
||||
|
|
@ -105,6 +105,8 @@ optionally be passed into `mkOverlay` attribute set as well.
|
|||
Example:
|
||||
|
||||
```nix
|
||||
sources = import ./nix/sources.nix;
|
||||
jail-nix = import sources."jail.nix" { };
|
||||
jailOverlay = final: prev: jail-nix.lib.mkOverlay {
|
||||
inherit final prev;
|
||||
packages = combinators: with combinators; {
|
||||
|
|
@ -112,7 +114,7 @@ jailOverlay = final: prev: jail-nix.lib.mkOverlay {
|
|||
firefox = [ network gui gpu ];
|
||||
};
|
||||
};
|
||||
pkgs = import nixpkgs {
|
||||
pkgs = import sources.nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
overlays = [ jailOverlay ];
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue