Fallout 4 weapon mods

Overview
Weapon mods can be built from raw materials and attached to weapons at weapons workbenches. There are over 700 mods, generally including sights, barrels, stocks, receivers, magazines, and more. The Gun Nut perk is required to create better modifications for guns. The Science! perk is used to create better modifications for energy weapons and create advanced modifications for bullet based firearms. The Blacksmith perk is used to create better modifications for melee weapons.

Perks and weapon mods
Most firearms, including energy weapons, offer the option to customize the grip/stock, receiver and sight, changing which perks affect the weapon.
 * A firearm with an automatic receiver gets bonuses from the Commando perk.
 * A firearm with a non-automatic receiver and pistol grip get bonuses from the Gunslinger perk.
 * A firearm with a non-automatic receiver and a stock mod get bonuses from the Rifleman perk.
 * The Sniper perk only works with a non-automatic firearm with a scope, which use the "hold breath" mechanic.

Grip mods create pistol weapons, while stock mods create rifle weapons. This allows for almost any ranged firearm to be customized to fit the player's character build.