diff --git a/lib/combinators.nix b/lib/combinators.nix index 459eadf..b01850d 100644 --- a/lib/combinators.nix +++ b/lib/combinators.nix @@ -634,6 +634,7 @@ in rec { include-once "bind-nix-store-runtime-closure" (defer (state: let runtimeClosure = pkgs.writeText "${state.name}-runtime-closure" '' + ${pkgs.lib.concatStringsSep "\n" state.additionalRuntimeClosures} ${pkgs.lib.concatStringsSep "\n" state.path} ${state.argv} ${state.entry} @@ -872,7 +873,10 @@ in rec { ``` ''; __functor = _: - path: pkg: ro-bind (toString pkg) path + path: pkg: compose [ + (ro-bind (toString pkg) path) + (state: state // { additionalRuntimeClosures = state.additionalRuntimeClosures ++ [ pkg ]; }) + ] ; }; diff --git a/lib/jail.nix b/lib/jail.nix index 8007f85..f2ed8af 100644 --- a/lib/jail.nix +++ b/lib/jail.nix @@ -34,6 +34,7 @@ in { includedOnce = []; # See include-once combinator cleanup = []; # See cleanup combinator deferredPermissions = []; # See defer combinator + additionalRuntimeClosures = []; # See bind-nix-store-runtime-closure }; in lib.pipe initialState ( # Permissions shared by all invocations of jail diff --git a/tests/test-cases.nix b/tests/test-cases.nix index 15f57bb..25f79a4 100644 --- a/tests/test-cases.nix +++ b/tests/test-cases.nix @@ -26,6 +26,7 @@ in { argv = mkDep "argv"; entry = mkDep "entry"; unrelated = sh "echo this dep is unrelated"; + write-text = mkDep "write-text"; }; checkExists = jail "check-exists" @@ -40,6 +41,7 @@ in { (c: [ (c.add-pkg-deps [ deps.add-pkg-deps.parent ]) (c.set-argv [ (c.noescape "\"$1\"") deps.argv.parent ]) + (c.write-text "/write/text/with/runtime/dep" "${deps.write-text.parent}") ]); in # Dependencies that should be in the jail @@ -47,6 +49,7 @@ in { deps.add-pkg-deps.runtime deps.argv.runtime deps.entry.runtime + deps.write-text.runtime ] ++ # Dependencies that shouldn't be in the jail @@ -55,6 +58,7 @@ in { deps.argv.buildtime deps.entry.buildtime deps.unrelated + deps.write-text.buildtime ]; "it allows overriding base permissions shared across all jails" = let