Context. Little is known about the stellar environment and the genealogy of our solar system. Short-lived radionuclides (SLRs, mean lifetime τ shorter than 100 Myr) that were present in the solar protoplanetary disk 4.56 Gyr ago could potentially provide insight into that key aspect of our history, were their origin understood. Aims. Previous models failed to provide a reasonable explanation of the abundance of two key SLRs, 26 Al (τ 26 = 1.1 Myr) and 60 Fe (τ 60 = 3.7 Myr), at the birth of the solar system by requiring unlikely astrophysical conditions. Our aim is to propose a coherent and generic solution based on the most recent understanding of star-forming mechanisms. Methods. Iron-60 in the nascent solar system is shown to have been produced by a diversity of supernovae belonging to a first generation of stars in a giant molecular cloud. Aluminum-26 is delivered into a dense collected shell by a single massive star wind belonging to a second star generation. The Sun formed in the collected shell as part of a third stellar generation. Aluminum-26 yields used in our calculation are based on new rotating stellar models in which 26 Al is present in stellar winds during the star main sequence rather than during the Wolf-Rayet phase alone. Our scenario eventually constrains the time sequence of the formation of the two stellar generations that just preceded the solar system formation, along with the number of stars born in these two generations. Results. We propose a generic explanation for the past presence of SLRs in the nascent solar system, based on a collect-injection-andcollapse mechanism, occurring on a diversity of spatial/temporal scales. In that model, the presence of SLRs with a diversity of mean lifetimes in the solar protoplanetary disk is simply the fossilized record of sequential star formation within a hierarchical interstellar medium. We identify the genealogy of our solar system's three star generations earlier. In particular, we show that our Sun was born together with a few hundred stars in a dense collected shell situated at a distance of 5−10 pc from a parent massive star having a mass greater than about 30 solar masses and belonging to a cluster containing ∼1200 stars.