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, including scopes, barrels, stocks, and more. For guns the Gun Nut perk is required, while Science! is required to modify energy weapons and advanced modifications for guns, and Blacksmith is required for most melee weapons mods.

Perks and weapon mods
Most pistols and rifles offer the option to customize grip/stock, receiver and sights, changing which perks affect the weapon.
 * A pistol or rifle with an automatic receiver gets bonuses from the Commando perk.
 * Pistols with non-automatic receivers get bonuses from the Gunslinger perk.
 * Rifles with non-automatic receivers get bonuses from the Rifleman perk.
 * The Sniper perk only works on non-automatic rifles with scopes which use the "hold breath" mechanic.

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