  The production of the W$^\pm$ bosons measured in p$-$Pb collisions at a
centre-of-mass energy per nucleon$-$nucleon collision $\sqrt{s_{NN}} = 8.16$
TeV and Pb$-$Pb collisions at $\sqrt{s_{NN}} = 5.02$ TeV with ALICE at the LHC
is presented. The W$^\pm$ bosons are measured via their muonic decay channel,
with the muon reconstructed in the pseudorapidity region $-4 < \eta^\mu_{\rm
lab} < -2.5$ with transverse momentum $p_{\rm T}^\mu > 10$ GeV/$c$. While in
Pb$-$Pb collisions the measurements are performed in the forward ($2.5 <
y^\mu_{\rm cms} < 4$) rapidity region, in p$-$Pb collisions, where the
centre-of-mass frame is boosted with respect to the laboratory frame, the
measurements are performed in the backward ($-4.46 < y^\mu_{\rm cms} < -2.96$)
and forward ($2.03 < y^\mu_{\rm cms} < 3.53$) rapidity regions. The W$^{-}$ and
W$^{+}$ production cross sections, lepton-charge asymmetry, and nuclear
modification factors are evaluated as a function of the muon rapidity. In order
to study the production as a function of the p$-$Pb collision centrality, the
production cross sections of the W$^{-}$ and W$^{+}$ bosons are combined and
normalised to the average number of binary nucleon$-$nucleon collision $\langle
N_\mathrm{coll} \rangle$. In Pb$-$Pb collisions, the same measurements are
presented as a function of the collision centrality. Study of the binary
scaling of the W$^\pm$-boson cross sections in p$-$Pb and Pb$-$Pb collisions is
also reported. The results are compared with perturbative QCD (pQCD)
calculations, with and without nuclear modifications of the Parton Distribution
Functions (PDFs), as well as with available data at the LHC. Significant
deviations from the theory expectations are found in the two collision systems,
indicating that the measurements can provide additional constraints for the
determination of nuclear PDF (nPDFs) and in particular of the light-quark
distributions.
