You have some issues to address:
If your tech is limited to travel <= horse, then gunpowder and a few variants are your best bet. Batteries of reasonable power density are non-trival to make, as are solar cells. Neither last forever. Current Li-Ion batteries are good for about 500 cycles. Solar cells typically degrade about 20% over the 25 year projected life. Not clear if not using them extends their life.
A rail gun is also non trivial and depends on the electrical properties of the projectile. You will get different results between a nail and a screw. You could get around this by using non-conductive ammo and a shuttle in the rail gun. The shuttle is stopped and reused. Railguns generally use really large capacitors instead of batteries to get the currents necessary.
A square foot of 20% efficient solar cell can generate about 16W when supported at right angles to the sun near noon on a clear day. A kW of solar cell generates from 800 kWh (Germany -- rainy climate) to 1400 kWh (American Southwest) of energy per year.
A .303 has about 2400 ft-lbs energy. Converting to joules you get about 3300 J or not quite 1 watt hour. So if you had a way to efficiently turn battery energy into projectile energy it would be reasonable to carry. Your solar cell would store about 16 rounds per hour. Call it 10 to allow for inefficiencies.
Note that sending a heavier projectile at a lower speed delivers the same momentum (impact) with lower energy requirements.
In a watermill, 1800 level tech world, it may be reasonable to make the equivalent of a civil war mini-ball rifle. This still requires 'factories' (A place where a bunch of people work at various stages of production.) You still need decent steel produced in significant quantities. You won't make rifle barrels out of salvaged rebar.
Give consideration to non-firearms.
Bow & Arrow. Takes a long time to learn, and needs practice to keep up. You need to be quite fit to fire off 12 arrows a minute with a 100 lb bow. Bows are sensitive to moisture, and arrows are time consuming to make. https://en.wikipedia.org/wiki/Archery
Crossbow. Easier to learn. Slower in use. Bolts are less fussy to make. https://en.wikipedia.org/wiki/Crossbow
Atlatl. In effect an extension of the arm, used to hurl what amounts to a large arrow or a small spear. Because of the large motion involved, it is not a sneaky weapon. https://en.wikipedia.org/wiki/Spear-thrower
Sling. This is another one that takes a fair amount of practice to get good. However a sling is the lightest weapon in this list, and the ammunition (stones) is common. In particular the staff sling has advantages in a general battle. Slings are less subject to damage from moisture compared to bows.