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

with pkgs.lib;

let

  cfg = config.nix;

  inherit (config.environment) nix;

  makeNixBuildUser = nr:
    { name = "nixbld${toString nr}";
      description = "Nix build user ${toString nr}";

      /* For consistency with the setgid(2), setuid(2), and setgroups(2)
         calls in `libstore/build.cc', don't add any supplementary group
         here except "nixbld".  */
      uid = builtins.add config.ids.uids.nixbld nr;
      group = "nixbld";
      extraGroups = [ "nixbld" ];
    };

  nixConf =
    let
      # Tricky: if we're using a chroot for builds, then we need
      # /bin/sh in the chroot (our own compromise to purity).
      # However, since /bin/sh is a symlink to some path in the
      # Nix store, which furthermore has runtime dependencies on
      # other paths in the store, we need the closure of /bin/sh
      # in `build-chroot-dirs' - otherwise any builder that uses
      # /bin/sh won't work.
      binshDeps = pkgs.writeReferencesToFile config.system.build.binsh;
    in
      pkgs.runCommand "nix.conf" {extraOptions = cfg.extraOptions; } ''
        extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done)
        cat > $out <<END
        # WARNING: this file is generated.
        build-users-group = nixbld
        build-max-jobs = ${toString (cfg.maxJobs)}
        build-use-chroot = ${if cfg.useChroot then "true" else "false"}
        build-chroot-dirs = ${toString cfg.chrootDirs} $(echo $extraPaths)
        binary-caches = ${toString cfg.binaryCaches}
        trusted-binary-caches = ${toString cfg.trustedBinaryCaches}
        $extraOptions<commit_msg>Describe where /etc/nix/nix.conf settings come from<commit_after>{ config, pkgs, ... }:

with pkgs.lib;

let

  cfg = config.nix;

  inherit (config.environment) nix;

  makeNixBuildUser = nr:
    { name = "nixbld${toString nr}";
      description = "Nix build user ${toString nr}";

      /* For consistency with the setgid(2), setuid(2), and setgroups(2)
         calls in `libstore/build.cc', don't add any supplementary group
         here except "nixbld".  */
      uid = builtins.add config.ids.uids.nixbld nr;
      group = "nixbld";
      extraGroups = [ "nixbld" ];
    };

  nixConf =
    let
      # Tricky: if we're using a chroot for builds, then we need
      # /bin/sh in the chroot (our own compromise to purity).
      # However, since /bin/sh is a symlink to some path in the
      # Nix store, which furthermore has runtime dependencies on
      # other paths in the store, we need the closure of /bin/sh
      # in `build-chroot-dirs' - otherwise any builder that uses
      # /bin/sh won't work.
      binshDeps = pkgs.writeReferencesToFile config.system.build.binsh;
    in
      pkgs.runCommand "nix.conf" {extraOptions = cfg.extraOptions; } ''
        extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done)
        cat > $out <<END
        # WARNING: this file is generated from the nix.* entries in
        # ${maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"}
        build-users-group = nixbld
        build-max-jobs = ${toString (cfg.maxJobs)}
        build-use-chroot = ${if cfg.useChroot then "true" else "false"}
        build-chroot-dirs = ${toString cfg.chrootDirs} $(echo $extraPaths)
        binary-caches = ${toString cfg.binaryCaches}
        trusted-binary-caches = ${toString cfg.trustedBinaryCaches}
        $extraOptions
{'fraction_non_alphanumeric': 0.11868322263933007, 'fraction_numerical': 0.0017326017903551833, 'mean_word_length': 2.5822130299896586, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6421731', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1096, 'n_words': 344}