<commit_before># Management of static files in /etc.

{ config, pkgs, ... }:

with pkgs.lib;

let

  etc' = attrValues config.environment.etc;

  etc = pkgs.stdenv.mkDerivation {
    name = "etc";

    builder = ./make-etc.sh;

    preferLocalBuild = true;

    /* !!! Use toXML. */
    sources = map (x: x.source) etc';
    targets = map (x: x.target) etc';
    modes = map (x: x.mode) etc';
  };

in

{

  ###### interface

  options = {

    environment.etc = mkOption {
      type = types.loaOf types.optionSet;
      default = {};
      example =
        { hosts =
            { source = "/nix/store/.../etc/dir/file.conf.example";
              mode = "0440";
            };
          "default/useradd".text = "GROUP=100 ...";
        };
      description = ''
        Set of files that have to be linked in <filename>/etc</filename>.
      '';

      options = singleton ({ name, config, ... }:
        { options = {

            target = mkOption {
              description = ''
                Name of symlink (relative to
                <filename>/etc</filename>).  Defaults to the attribute
                name.
              '';
            };

            text = mkOption {
              default = null;
              type = types.nullOr types.string;
              description = "Text of the file.";
            };

            source = mkOption {
              types = types.path;
              description = "Path of the source file.";
            };

            mode = mkOption {
              default = "symlink";<commit_msg>Selectively allow /etc files to be disabled<commit_after># Management of static files in /etc.

{ config, pkgs, ... }:

with pkgs.lib;

let

  etc' = filter (f: f.enable) (attrValues config.environment.etc);

  etc = pkgs.stdenv.mkDerivation {
    name = "etc";

    builder = ./make-etc.sh;

    preferLocalBuild = true;

    /* !!! Use toXML. */
    sources = map (x: x.source) etc';
    targets = map (x: x.target) etc';
    modes = map (x: x.mode) etc';
  };

in

{

  ###### interface

  options = {

    environment.etc = mkOption {
      type = types.loaOf types.optionSet;
      default = {};
      example =
        { hosts =
            { source = "/nix/store/.../etc/dir/file.conf.example";
              mode = "0440";
            };
          "default/useradd".text = "GROUP=100 ...";
        };
      description = ''
        Set of files that have to be linked in <filename>/etc</filename>.
      '';

      options = singleton ({ name, config, ... }:
        { options = {

            enable = mkOption {
              type = types.bool;
              default = true;
              description = ''
                Whether this /etc file should be generated.  This
                option allows specific /etc files to be disabled.
              '';
            };

            target = mkOption {
              description = ''
                Name of symlink (relative to
                <filename>/etc</filename>).  Defaults to the attribute
                name.
              '';
            };

            text = mkOption {
              default = null;
              type = types.nullOr types.string;
              description = "Text of the file.";
            };

            source = mkOption {
              types = types.path;
              description = "Path of the source file.";
            };

            mode = mkOption {
              default = "symlink";
{'fraction_non_alphanumeric': 0.127362605408549, 'fraction_numerical': 0.004070950857807502, 'mean_word_length': 1.3465211459754434, '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': '2853774', 'n_tokens_mistral': 984, 'n_tokens_neox': 931, 'n_words': 257}