Libraries Use Code Already...
I should probably start by saying that libraries of all stripes, sorts, and sizes use a significant amount of open source code in our daily operations already. Many of the vendors that we use also have open source libraries or build on those libraries to deliver products and services to their library clients. It's not a wasteland of proprietary software everywhere, even though there's still a lot of that going around.
For example, Foss4Lib tries to provide a directory of some open source applications and (software) libraries used in various types of (people) libraries. And the Libraries Sharing Code list tries to collect all the institituional code repositories that it is aware of.
Apache Solr, for example, can be dropped in as an indexer for records generated by a library using any one of many libraries and programs used to create Machine Readable Cataloging records. Blacklight places a discovery layer on top of the records indexed and searchable by Solr so as to make the searching much more human-friendly. Or one can add a plug-in to many other languages and applications and grab Solr that way.
For a more complete idea, both Evergreen and Koha offer a full integrated library system - Koha uses modules run in web browsers for all of its functions, along with the Koha servers at an institution, Evergreen has client programs and server programs for various operating systems.
The Library Freedom Project wants every public library to function as a Tor exit node, an idea that they were able to obtain funding from the Knight Foundation to try and produce, along with several excellent privacy toolkits and workshops. Because librarians try to respect your privacy against intrusion both from governments and corporations...although the latter is a bit more difficult when we're beholden to them for access to items our users need to do their work. (For more on that, go see last year's presentation, The Public Library Is An (Almost) Open Source Institution).
There's a lot of open source software underpinning a lot of what we do in libraries, whether it's explicitly mentioned or as part of the frameworks that we use to talk across machines and accomplish our work. Setting up infrastructure and making decisions about what software to run is really about choosing from a series of good products to find the one that works best for our applications and users. Where the problems start are twofold - having staff who are experts enough in the chosen solution that they can build and support it, and when we want to take the data that we're generating and to start turning it into useful applications for front-line staff and librarians to put to use.