<commit_before>{
    pkgs ? import <nixpkgs> {}
  , spectrumPkgs ? import <nixpkgs-spectrum-os> {}
  , nixos ? import <nixpkgs/nixos>
  , lang-os ? ../lang-os
  , rootfs ? import ./rootfs.nix {
    inherit pkgs nixos;
  }
}:
pkgs.lib.makeExtensible (self: with self; {
  inherit pkgs nixos rootfs;

  rust-9p = pkgs.unpfs;
  mktuntap = spectrumPkgs.mktuntap;
  crosvm = pkgs.crosvm;

  lispClientBin = pkgs.runCommand "lisp-request-client" {}
    ''
      export PATH="$PATH:${pkgs.sbcl}/bin:${pkgs.lispPackages.clwrapper}/bin"
      export USER_LISP_SHELL_RC=${./minimal-rc.lisp}
      export LISP_OS_HELPERS_PACKAGE=${(import "${lang-os}/local/test-system.nix" {}).lispOsHelpers}
      export HOME="$PWD"
      ${lang-os}/run-user-shell.sh --non-interactive \
        --eval "(build-shell \"$out\")"
    '';

  escapeLispString = s: ''"'' + (pkgs.lib.escape [''"'' ''\''] (builtins.toString s)) + ''"'';
  escapeLispStrings = pkgs.lib.concatMapStringsSep " " escapeLispString;
  inherit (pkgs.lib) escapeShellArg escapeShellArgs;

  lispRequest = code: ''
    ${lispClientBin} --non-interactive --eval ${escapeShellArg code}
  '';

  socket-9p-dir = ''tmp/9p-sockets'';
  socket-9p-dir-internal = ''/9p-sockets'';
  ensureSocketDir = ''
    mkdir -p "$HOME"/${escapeShellArg socket-9p-dir}
    ${lispRequest ''(ask-with-auth ()
         `(chown-subuser ,(~ ${escapeLispString socket-9p-dir}) "" t))''}
  '';

  store-9p-command = socket: path:
    ["${rust-9p}/bin/unpfs" "unix!${socket-9p-dir-internal}/${socket}!0" path];
  store-9p-prepare = socket: path: ''
    ${pkgs.socat}/bin/socat stdio \
       unix-connect:"$HOME"/${escapeShellArg socket-9p-dir}/${escapeShellArg socket}'\:0' \
       &> /dev/null < /dev/null ||
    {
    rm "$HOME"/${escapeShellArg socket-9p-dir}/${escapeShellArg socket}':0'
    ${lispRequest ''
         (subuser-nsjail-x-application
            `(${escapeLispStrings (store-9p-command socket "/data")})
            :grant `(,(~ ${escapeLispString socket-9p-dir}))
            :mounts `((:b ,(~ ${escapeLispString socket-9p-dir}) ${escapeLispString socket-9p-dir-internal})
                      (:b ${escapeLispString path} "/data"))
            :wait nil
            )
    ''}
    }
    while ! test -e "$HOME"/${escapeShellArg socket-9p-dir}/${escapeShellArg socket}:0; do
      sleep 0.1
    done
  '';
  store-9p-export = ''
    ${ensureSocketDir}
    ${store-9p-prepare "store" "/nix/store"}
    mkdir -p /tmp/crosvm-test
    ${store-9p-prepare "tmp" "/tmp/crosvm-test"}<commit_msg>Syncing from Monotone at 20200618-140923. Last commit message was Ensure permissions<commit_after>{
    pkgs ? import <nixpkgs> {}
  , spectrumPkgs ? import <nixpkgs-spectrum-os> {}
  , nixos ? import <nixpkgs/nixos>
  , lang-os ? ../lang-os
  , rootfs ? import ./rootfs.nix {
    inherit pkgs nixos;
  }
}:
pkgs.lib.makeExtensible (self: with self; {
  inherit pkgs nixos rootfs;

  rust-9p = pkgs.unpfs;
  mktuntap = spectrumPkgs.mktuntap;
  crosvm = pkgs.crosvm;

  lispClientBin = pkgs.runCommand "lisp-request-client" {}
    ''
      export PATH="$PATH:${pkgs.sbcl}/bin:${pkgs.lispPackages.clwrapper}/bin"
      export USER_LISP_SHELL_RC=${./minimal-rc.lisp}
      export LISP_OS_HELPERS_PACKAGE=${(import "${lang-os}/local/test-system.nix" {}).lispOsHelpers}
      export HOME="$PWD"
      ${lang-os}/run-user-shell.sh --non-interactive \
        --eval "(build-shell \"$out\")"
    '';

  escapeLispString = s: ''"'' + (pkgs.lib.escape [''"'' ''\''] (builtins.toString s)) + ''"'';
  escapeLispStrings = pkgs.lib.concatMapStringsSep " " escapeLispString;
  inherit (pkgs.lib) escapeShellArg escapeShellArgs;

  lispRequest = code: ''
    ${lispClientBin} --non-interactive --eval ${escapeShellArg code}
  '';

  socket-9p-dir = ''tmp/9p-sockets'';
  socket-9p-dir-internal = ''/9p-sockets'';
  ensureSocketDir = ''
    mkdir -p "$HOME"/${escapeShellArg socket-9p-dir}
    ${lispRequest ''(ask-with-auth ()
         `(chown-subuser ,(~ ${escapeLispString socket-9p-dir}) "" t))''}
  '';

  store-9p-command = socket: path:
    ["${rust-9p}/bin/unpfs" "unix!${socket-9p-dir-internal}/${socket}!0" path];
  store-9p-prepare = socket: path: ''
    ${pkgs.socat}/bin/socat stdio \
       unix-connect:"$HOME"/${escapeShellArg socket-9p-dir}/${escapeShellArg socket}'\:0' \
       &> /dev/null < /dev/null ||
    {
    rm "$HOME"/${escapeShellArg socket-9p-dir}/${escapeShellArg socket}':0'
    ${lispRequest ''
         (subuser-nsjail-x-application
            `(${escapeLispStrings (store-9p-command socket "/data")})
            :grant `(,(~ ${escapeLispString socket-9p-dir}))
            :mounts `((:b ,(~ ${escapeLispString socket-9p-dir}) ${escapeLispString socket-9p-dir-internal})
                      (:b ${escapeLispString path} "/data"))
            :wait nil
            )
    ''}
    }
    while ! test -e "$HOME"/${escapeShellArg socket-9p-dir}/${escapeShellArg socket}:0; do
      sleep 0.1
    done
  '';
  store-9p-export = ''
    ${ensureSocketDir}
    ${store-9p-prepare "store" "/nix/store"}
    mkdir -p /tmp/crosvm-test
    chmod a+rwxt /tmp/crosvm-test
    ${store-9p-prepare "tmp" "/tmp/crosvm-test"}
{'fraction_non_alphanumeric': 0.18947777130654242, 'fraction_numerical': 0.013201320132013201, 'mean_word_length': 2.9418515684774293, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3360757', 'n_tokens_mistral': 1994, 'n_tokens_neox': 1921, 'n_words': 304}