This sounds great. I assume there's some way to tie a cvar to a buff, and to do a drain over time? I'll need to do some research on this. Any chance you could point me to a mod that does something similar so I could learn by example?
I don't recommend using this mod as a good tutorial as its a bit convoluted AND the "infection" system in the game seems "special" to me in how its set up, BUT it does hook into the existing cvars for infection, which naturally "counts up":
Doughs-Buff-Infection
Anyway, this mod hooks into the "buffInfectionMain" buff system of the vanilla game ( search for this in the games buffs.xml file) and its a bit convoluted to work out how it works, as the infection logic/buffs/etc is a bit special. So don't look at it and get too overwhelmed
So: the game has a main buff handler buff called "buffStatusCheck01",which I would also look into. its probably where you want to hook into... maybe for handling the "constant, slow countdown". Maybe. I'm not an expert on buffs and tricks so I can be wrong about this.
Additionally: I would also look into the games buffs.xml files at the candies (like "buffDrugFortBites") and of course food ("buffShamChowder", etc) as they're all similar and show how to use a basic buff that just "counts down and works on its own". They all have their own cvars and tie to items so you can see how the items hook to buffs, and also how to display the item status for nutrients. Example:
item: in items.xml, lets look at "foodCanSham":
<item name="foodCanSham">
<property name="Extends" value="foodCanBeef"/>
<property name="UnlockedBy" value="foodCanShamSchematic"/>
<effect_group tiered="false" name="Food Tier 0">
<triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar="$foodAmountAdd" operation="add" value="15"/>
<triggered_effect trigger="onSelfPrimaryActionEnd" action="ModifyCVar" cvar="foodHealthAmount" operation="add" value="7"/>
<triggered_effect trigger="onSelfPrimaryActionEnd" action="AddBuff" buff="buffProcessConsumables"/>
</effect_group>
</item>
Here we see it's extending (building off of) the "foodCanBeef" item, and triggers "buffProcessConsumeables". Look at "foodCanBeef" and see it contains a lot more properties, all of which are shared by "foodCanSham" (because of the "extends" property in "foodCanSham") *except* those used in "foodCanSham" itself, these properties/effect_group's are special to "foodCanSham". The main point to this is: foods are all processed through the main ""buffProcessConsumeables" buff. look at that buff to see how hey handle eating/drinking an item for health./stamina stats as you're likely going to have to add your own "stats upkeep" here to at least "add nutrients" when an item is eaten, likely by adding to your own cvars you have defined for the nutrients. this brings us back to the "buffStatusCheck01" buff... check it out again o see how they use this to "add more buffs" when health/hunger/thirst is getting low
For "how to show nutrient stats", look into the ui_display.xml file. Search for "foodShamChowder" (for example). This shows:
<item_display_info display_type="foodShamChowder" display_group="groupConsumables">
<display_entry name="$foodAmountAdd" title_key="statFoodAmount"/>
<display_entry name="foodHealthAmount" title_key="statHealthAmount"/>
<display_entry name=".foodStaminaBonusAdd" title_key="statFoodStaminaBonus"/>
<display_entry name="dFortitude" title_key="statShowFortitude" display_leading_plus="true"/>
<display_entry name="dDuration" title_key="statDuration" display_type="Time"/>
</item_display_info>
which are the cvars/variables that are displayed when you inspect the "foodShamChowder" item stats in the game. I'm not super knowledgeable on how all of the data here is determined/used/defined, just "item display stuff is in this file". Also: Some of these are "generic" display info, like this one:
<item_display_info display_type="food" display_group="groupConsumables">
<display_entry name="$foodAmountAdd" title_key="statFoodAmount"/>
<display_entry name="foodHealthAmount" title_key="statHealthAmount"/>
<display_entry name=".foodStaminaBonusAdd" title_key="statFoodStaminaBonus"/>
</item_display_info>
which is for "food". I believe? this is used for something that is tagged as "food" in the item IF there is not a more specialized/literal display definition for the item itself (like "foodShamChowder")... for example... "foodCanBeef" (which "foodSmahChowder" extends from has this tag "food" , which is also shared (I think?, some properties do not extend!) by "foodCanShamChowder:"
<item name="foodCanBeef">
<property name="Tags" value="food"/>
...
... rest of XML here
</item>
so basically: the display for "foodCanBeef" will use the "food" display in ui_display.xml UNLESS there's a specific "foodCanBeef" defined in ui_display.xml
SO: Hopefully this can get you started a bit into seeing how things hook together, generally. but BEWARE! you are wanting to make a mod I'm not sure anyone else has made, so it may be a bit rough to make it all work as you can't easily copy/borrow from someone else's' mod. It might be quite a bit of trial and error to get something to work, but if you persist (and hopefully others can help if you run into issues) it seem do-able.
This is just a general overview of what to look into. What I haven't covered is how to define/handle/manage your own cvars, which I'm not very knowledgeable on (sorry) so I've left this out as I don't want to make up too many wrong things. Something else not covered is "how to ad all of this to the existing games food/drink". You might find its worth to not define nutrition info for every thing in the game, but instead to try to make a few "basic XPATH rules to add your nutrients to all edible items in thw game" (like :" add 5% nutrient x, y to all things with food in the name", "add 5% nutrient y and z to all things with drink in the name" to just give most things some low nutrients, then go in and hand select items you feel should have "lots more" of a certain nutrient(s). this way by default all items give nutrients, but only what you bother making exceptions for have "more" or "special ones". This way if the game adds/removes food/drink, your mod likely won't need to change, as well as it might add the basic/default low level nutrients to all items from other peoples food/drink mods.
Also: First I would try to get this to work with a SINGLE food item and a SINGLE nutrient. Something very simple and basic like "foodCanBeef". Once you can get it all worked out for this, it will be much easier to add more, but I would then do a SINGLE drink item. Get all the nutrient "counting/adding/subtracting" and effects (stamina debuffs, etc) and display information looking good first. I've spent a lot of time futzing around on my own mods trying to add too much at once and just burning time

Even thoen I still don't follow my own advice and regret it later!
The Tutorials forum section has a lot of good XPATH info, and likely have some cvar stuff in there as well:
https://community.7daystodie.com/forum/39-tutorials-guides/
Good Luck!