Skip to content

implement basic filesystem sandbox #1783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,7 @@ EOF
files = "docs/assets/extra.css";
};
};
enterShell = ''
ls ~/.ssh
'';
}
2 changes: 2 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ inputs:
url: github:domenkozar/nix/devenv-2.24
devenv:
url: path:.?dir=src/modules

experimentalSandbox: false
2 changes: 2 additions & 0 deletions devenv/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ pub struct Config {
pub clean: Option<Clean>,
#[serde(skip_serializing_if = "is_false", default = "false_default")]
pub impure: bool,
#[serde(skip_serializing_if = "is_false", default = "false_default")]
pub experimental_sandbox: bool,
}

// TODO: https://github.com/moonrepo/schematic/issues/105
Expand Down
2 changes: 2 additions & 0 deletions devenv/src/devenv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ impl Devenv {
let vars = indoc::formatdoc!(
"version = \"{}\";
system = \"{}\";
devenv_experimental_sandbox = {};
devenv_root = \"{}\";
devenv_dotfile = ./{};
devenv_dotfile_string = \"{}\";
Expand All @@ -852,6 +853,7 @@ impl Devenv {
",
crate_version!(),
self.global_options.system,
self.config.experimental_sandbox,
self.devenv_root.display(),
self.devenv_dotfile.file_name().unwrap().to_str().unwrap(),
self.devenv_dotfile.file_name().unwrap().to_str().unwrap(),
Expand Down
1 change: 1 addition & 0 deletions devenv/src/flake.tmpl.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
devenv.cliVersion = version;
devenv.root = devenv_root;
devenv.dotfile = devenv_root + "/" + devenv_dotfile_string;
devenv.experimental_sandbox = devenv_experimental_sandbox;
}
(pkgs.lib.optionalAttrs (inputs.devenv.isTmpDir or false) {
devenv.tmpdir = devenv_tmpdir;
Expand Down
3 changes: 3 additions & 0 deletions docs/devenv.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
}
]
},
"experimentalSandbox": {
"type": "boolean"
},
"imports": {
"type": "array",
"items": {
Expand Down
33 changes: 27 additions & 6 deletions docs/reference/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,27 @@ boolean



## devenv.experimental_sandbox



Enable the experimental sandbox



*Type:*
boolean



*Default:*
` false `

*Declared by:*
- [https://github.com/cachix/devenv/blob/main/src/modules/top-level.nix](https://github.com/cachix/devenv/blob/main/src/modules/top-level.nix)



## devenv.flakesIntegration


Expand Down Expand Up @@ -2182,8 +2203,6 @@ submodule

## git-hooks.enabledPackages



All packages provided by hooks that are enabled.

Useful for including into the developer environment.
Expand Down Expand Up @@ -2322,6 +2341,8 @@ list of (one of “commit-msg”, “post-checkout”, “post-commit”, “pos

## git-hooks.excludes



Exclude files that were matched by these patterns.


Expand Down Expand Up @@ -5138,8 +5159,6 @@ attribute set of unspecified value

## git-hooks.hooks.autoflake.require_serial



if true this hook will execute using a single process instead of in parallel.


Expand All @@ -5159,6 +5178,8 @@ boolean

## git-hooks.hooks.autoflake.settings.binPath



Path to autoflake binary.


Expand Down Expand Up @@ -7011,8 +7032,6 @@ boolean

## git-hooks.hooks.clippy.package



An optional package that provides the hook.


Expand All @@ -7032,6 +7051,8 @@ null or package

## git-hooks.hooks.clippy.packageOverrides.cargo



The cargo package to use


Expand Down
8 changes: 4 additions & 4 deletions src/modules/processes.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, options, lib, pkgs, ... }:
{ config, options, lib, pkgs, sandbox, ... }:
let
types = lib.types;

Expand Down Expand Up @@ -145,17 +145,17 @@ in
pkgs.writeText "procfile-env" (lib.concatStringsSep "\n" envList);

procfileScript = pkgs.writeShellScript "devenv-up" ''
${config.process.manager.before}
${sandbox} ${config.process.manager.before}

${config.process.manager.command}
${sandbox} ${config.process.manager.command}

backgroundPID=$!

down() {
echo "Stopping processes..."
kill -TERM $backgroundPID
wait $backgroundPID
${config.process.manager.after}
${sandbox} ${config.process.manager.after}
echo "Processes stopped."
}

Expand Down
Loading