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

with pkgs.lib;
with import ../boot/systemd-unit-options.nix { inherit config pkgs; };

let

  userExists = u:
    (u == "") || any (uu: uu.name == u) (attrValues config.users.extraUsers);

  groupExists = g:
    (g == "") || any (gg: gg.name == g) (attrValues config.users.extraGroups);

  makeJobScript = name: content: "${pkgs.writeScriptBin name content}/bin/${name}";

  # From a job description, generate an systemd unit file.
  makeUnit = job:

    let
      hasMain = job.script != "" || job.exec != "";

      env = config.system.upstartEnvironment // job.environment;

      preStartScript = makeJobScript "${job.name}-pre-start.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${job.preStart}
        '';

      startScript = makeJobScript "${job.name}-start.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${if job.script != "" then job.script else ''
            exec ${job.exec}
          ''}
        '';

      postStartScript = makeJobScript "${job.name}-post-start.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${job.postStart}
        '';

      preStopScript = makeJobScript "${job.name}-pre-stop.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${job.preStop}
        '';

      postStopScript = makeJobScript "${job.name}-post-stop.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${job.postStop}
        '';
    in {

      inherit (job) description requires wants before environment path;

      after =
        (if job.startOn == "stopped udevtrigger" then [ "systemd-udev-settle.service" ] else
         if job.startOn == "started udev" then [ "systemd-udev.service" ] else
         []) ++ job.after;

      wantedBy =<commit_msg>Warn about Upstart modules with an unknown startOn condition<commit_after>{ config, pkgs, ... }:

with pkgs.lib;
with import ../boot/systemd-unit-options.nix { inherit config pkgs; };

let

  userExists = u:
    (u == "") || any (uu: uu.name == u) (attrValues config.users.extraUsers);

  groupExists = g:
    (g == "") || any (gg: gg.name == g) (attrValues config.users.extraGroups);

  makeJobScript = name: content: "${pkgs.writeScriptBin name content}/bin/${name}";

  # From a job description, generate an systemd unit file.
  makeUnit = job:

    let
      hasMain = job.script != "" || job.exec != "";

      env = config.system.upstartEnvironment // job.environment;

      preStartScript = makeJobScript "${job.name}-pre-start.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${job.preStart}
        '';

      startScript = makeJobScript "${job.name}-start.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${if job.script != "" then job.script else ''
            exec ${job.exec}
          ''}
        '';

      postStartScript = makeJobScript "${job.name}-post-start.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${job.postStart}
        '';

      preStopScript = makeJobScript "${job.name}-pre-stop.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${job.preStop}
        '';

      postStopScript = makeJobScript "${job.name}-post-stop.sh"
        ''
          #! ${pkgs.stdenv.shell} -e
          ${job.postStop}
        '';
    in {

      inherit (job) description requires wants before environment path;

      after =
        (if job.startOn == "stopped udevtrigger" then [ "systemd-udev-settle.service" ] else
         if job.startOn == "started udev" then [ "systemd-udev.service" ] else
         if job.startOn == "" || job.startOn == "startup" then [ ] else
         builtins.trace "Warning: job ‘${job.name}’ has unknown startOn value ‘${job.startOn}’." []
        ) ++ job.after;

      wantedBy =
{'fraction_non_alphanumeric': 0.16390374331550803, 'fraction_numerical': 0.0, 'mean_word_length': 2.0714285714285716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '801131', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1194, 'n_words': 255}