|
| 1 | +let |
| 2 | + pkgs = import ./nixpkgs.nix; |
| 3 | + nixpak = import ./nixpak.nix; |
| 4 | + mkNixPak = nixpak.lib.nixpak { |
| 5 | + inherit (pkgs) lib; |
| 6 | + inherit pkgs; |
| 7 | + }; |
| 8 | + sandbox = mkNixPak { |
| 9 | + config = {sloth, ...}: { |
| 10 | + # the application to isolate |
| 11 | + app.package = pkgs.hello; |
| 12 | + |
| 13 | + # path to the executable to be wrapped |
| 14 | + # this is usually autodetected but |
| 15 | + # can be set explicitly nonetheless |
| 16 | + app.binPath = "bin/hello"; |
| 17 | + |
| 18 | + # enabled by default, flip to disable |
| 19 | + # and to remove dependency on xdg-dbus-proxy |
| 20 | + dbus.enable = true; |
| 21 | + |
| 22 | + # same usage as --see, --talk, --own |
| 23 | + dbus.policies = { |
| 24 | + "org.freedesktop.DBus" = "talk"; |
| 25 | + "ca.desrt.dconf" = "talk"; |
| 26 | + }; |
| 27 | + |
| 28 | + # needs to be set for Flatpak emulation |
| 29 | + # defaults to com.nixpak.${name} |
| 30 | + # where ${name} is generated from the drv name like: |
| 31 | + # hello -> Hello |
| 32 | + # my-app -> MyApp |
| 33 | + flatpak.appId = "org.myself.HelloApp"; |
| 34 | + |
| 35 | + bubblewrap = { |
| 36 | + # disable all network access |
| 37 | + network = false; |
| 38 | + |
| 39 | + # lists of paths to be mounted inside the sandbox |
| 40 | + # supports runtime resolution of environment variables |
| 41 | + # see "Sloth values" below |
| 42 | + |
| 43 | + # bind.rw = [ |
| 44 | + # (sloth.concat' sloth.homeDir "/Documents") |
| 45 | + # (sloth.env "XDG_RUNTIME_DIR") |
| 46 | + # # a nested list represents a src -> dest mapping |
| 47 | + # # where src != dest |
| 48 | + # [ |
| 49 | + # (sloth.concat' sloth.homeDir "/.local/state/nixpak/hello/config") |
| 50 | + # (sloth.concat' sloth.homeDir "/.config") |
| 51 | + # ] |
| 52 | + # ]; |
| 53 | + |
| 54 | + bind.ro = [ |
| 55 | + (sloth.concat' sloth.homeDir "/Downloads") |
| 56 | + ]; |
| 57 | + |
| 58 | + bind.dev = [ |
| 59 | + "/dev/dri" |
| 60 | + ]; |
| 61 | + }; |
| 62 | + }; |
| 63 | + }; |
| 64 | +in |
| 65 | + sandbox.config.script |
0 commit comments