<commit_before>{ config, lib, ... }:

with lib;
let cfg = config.nix.sshServe;
    command =
      if cfg.protocol == "ssh"
        then "nix-store --serve"
      else "nix-daemon --stdio";
in {
  options = {

    nix.sshServe = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable serving the Nix store as a remote store via SSH.";
      };

      keys = mkOption {
        type = types.listOf types.str;
        default = [];
        example = [ "ssh-dss AAAAB3NzaC1k... <EMAIL>" ];
        description = "A list of SSH public keys allowed to access the binary cache via SSH.";
      };

      protocol = mkOption {
        type = types.enum [ "ssh" "ssh-ng" ];
        default = "ssh";
        description = "The specific Nix-over-SSH protocol to use.";
      };

    };

  };

  config = mkIf cfg.enable {

    users.users.nix-ssh = {
      description = "Nix SSH store user";
      uid = config.ids.uids.nix-ssh;
      useDefaultShell = true;
    };

    services.openssh.enable = true;

    services.openssh.extraConfig = ''
      Match User nix-ssh
        AllowAgentForwarding no
        AllowTcpForwarding no
        PermitTTY no
        PermitTunnel no
        X11Forwarding no
        ForceCommand ${config.nix.package.out}/bin/${command}
      Match All
    '';

    users.users.nix-ssh.openssh.authorizedKeys.keys = cfg.keys;

  };
}
<commit_msg>nixos: nix.sshServe: add write option<commit_after>{ config, lib, ... }:

with lib;
let cfg = config.nix.sshServe;
    command =
      if cfg.protocol == "ssh"
        then "nix-store --serve ${lib.optionalString cfg.write "--write"}"
      else "nix-daemon --stdio";
in {
  options = {

    nix.sshServe = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable serving the Nix store as a remote store via SSH.";
      };

      write = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable writing to the Nix store as a remote store via SSH. Note: the sshServe user is named nix-ssh and is not a trusted-user. nix-ssh should be added to the nix.trustedUsers option in most use cases, such as allowing remote building of derivations.";
      };

      keys = mkOption {
        type = types.listOf types.str;
        default = [];
        example = [ "ssh-dss AAAAB3NzaC1k... <EMAIL>" ];
        description = "A list of SSH public keys allowed to access the binary cache via SSH.";
      };

      protocol = mkOption {
        type = types.enum [ "ssh" "ssh-ng" ];
        default = "ssh";
        description = "The specific Nix-over-SSH protocol to use.";
      };

    };

  };

  config = mkIf cfg.enable {

    users.users.nix-ssh = {
      description = "Nix SSH store user";
      uid = config.ids.uids.nix-ssh;
      useDefaultShell = true;
    };

    services.openssh.enable = true;

    services.openssh.extraConfig = ''
      Match User nix-ssh
        AllowAgentForwarding no
        AllowTcpForwarding no
        PermitTTY no
        PermitTunnel no
        X11Forwarding no
        ForceCommand ${config.nix.package.out}/bin/${command}
      Match All
    '';

    users.users.nix-ssh.openssh.authorizedKeys.keys = cfg.keys;

  };
}

{'fraction_non_alphanumeric': 0.11289833080424887, 'fraction_numerical': 0.0024279210925644916, 'mean_word_length': 2.0072992700729926, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4431932', 'n_tokens_mistral': 1072, 'n_tokens_neox': 989, 'n_words': 291}