We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Using Nix to build development environments as you always wanted

00:00

Formal Metadata

Title
Using Nix to build development environments as you always wanted
Title of Series
Number of Parts
266
Author
License
CC Attribution 3.0 Germany:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
This talk is going to reveal the secret of building and running development or user environments as you always wanted. Each of your projects can run in isolated, fully self contained environment, using the latest, or really old, or heavily customized geospatial packages regardless of Linux distro or Mac version you use. You can have as many environments as you want, and the environment will change as you change between your projects, branches or commits.
Projective planeSlide ruleComputer animation
Open sourceFreewareSoftwareMultiplication signSoftwareStapeldateiComputer animation
Core dumpOrder (biology)Raster graphicsGraphical user interfaceGrass (card game)Library (computing)Web applicationProcess (computing)Different (Kate Ryan album)Projective planeOcean currentMathematicsMemory managementRevision controlSoftwareSoftware bugState of matterCASE <Informatik>Cartesian coordinate systemMultiplication signCore dumpLevel (video gaming)File formatGeometryVideo gameTransformation (genetics)DatabaseCycle (graph theory)Computer animation
Graph (mathematics)SoftwareCodeService (economics)Library (computing)Different (Kate Ryan album)Mixed realityMedical imagingSoftwareSource codeCore dumpDigitizingSoftware repositoryComputer animationLecture/Conference
SoftwareUbuntu <Programm>Library (computing)Electronic data processingVirtualizationSource codeDefault (computer science)Web serviceCore dumpComputer animationLecture/Conference
Computing platformRevision controlRevision controlLibrary (computing)Different (Kate Ryan album)SoftwareProjective planeFingerprintComputing platformNeuroinformatikCurvatureComputer animationLecture/Conference
NeuroinformatikSoftware1 (number)Connectivity (graph theory)Data managementComputer animation
Uniqueness quantificationComputing platformGastropod shellRevision controlSingle-precision floating-point formatInstallation artOcean currentCartesian coordinate systemFerry CorstenGastropod shellBitQuantum gravityComputer configurationSoftwareProfil (magazine)MultiplicationMobile appData managementMehrplatzsystemSoftware repositoryInternetworkingRevision controlRepository (publishing)Medical imagingCompilation albumDifferent (Kate Ryan album)Thermodynamisches SystemBuildingWordWindowDistribution (mathematics)Connectivity (graph theory)Function (mathematics)Electronic data processingComputer animation
Formal languageFunction (mathematics)Source codeRevision controlHash functionKey (cryptography)Endliche ModelltheorieFunctional (mathematics)NumberGeometryWritingSpecial unitary groupBuildingFormal languageConfiguration spaceSource codeContent (media)Parameter (computer programming)Module (mathematics)Core dumpHash functionFunctional programmingInternetworkingRevision controlComputer animationLecture/Conference
SoftwareNetwork topologyHill differential equationCore dumpConnectivity (graph theory)Memory managementDistribution (mathematics)SoftwareDifferent (Kate Ryan album)NumberFree variables and bound variablesRepository (publishing)Computing platformGraph (mathematics)BuildingFreewareComputer animation
Thermodynamisches SystemModul <Datentyp>SoftwareConfiguration spaceModule (mathematics)Declarative programmingService (economics)Server (computing)DatabaseOperating systemConnectivity (graph theory)Thermodynamisches SystemArithmetic progressionService (economics)NeuroinformatikDatabaseSoftwareOpen setUniqueness quantificationModulare ProgrammierungBackupComputer animationLecture/Conference
Source codeThermodynamisches SystemTwitterSoftwareMemory managementTouch typingInternetworkingRevision controlTerm (mathematics)CurveNumberRandomizationStatement (computer science)Video game consoleAuthorizationComputer animationLecture/Conference
Thermodynamisches SystemHypothesisModule (mathematics)EmailComputerData modelSoftwareFunctional (mathematics)BitVirtual machineComputer programmingModulare ProgrammierungHypothesisThermodynamisches SystemComputer animationLecture/Conference
Derivation (linguistics)Function (mathematics)outputProcess (computing)Hash functionInternetworkingRevision controlFile formatDirectory serviceContent (media)Algebraic closureBinary fileCache (computing)Local ringVirtual machineSoftwareIntegrated development environmentSuite (music)Point (geometry)Validity (statistics)outputDirectory serviceInternetworkingData structureHash functionLibrary (computing)DialectMultiplicationMultiplication signData storage deviceSoftwareFunction (mathematics)Natural numberSuite (music)Thermodynamisches SystemRevision controlService (economics)Software testingCache (computing)Graphics tabletCryptographyContent (media)CurvatureConfiguration spaceMemory managementVirtual machineBitCASE <Informatik>Integrated development environmentKey (cryptography)Different (Kate Ryan album)Flash memoryComputer animationLecture/Conference
System programmingDemonDefault (computer science)Installation artThermodynamisches SystemComputer animationLecture/Conference
Software repositoryComputing platformThermodynamisches SystemRevision controlGraphical user interfaceComputerSoftware repositoryMathematicsVirtual machineProjective planeMultiplication signPatch (Unix)Rollback (data management)Configuration spaceThermodynamisches SystemControl flowSlide ruleMoving averageWeb pageComputer animation
BuildingIntegrated development environmentProof theoryThermodynamisches SystemProjective planePoint (geometry)Service (economics)BuildingProof theoryIntegrated development environmentMedical imagingVirtualizationSoftwareWindowDistribution (mathematics)Presentation of a groupFunctional (mathematics)Computer animationLecture/Conference
Computer fileInteractive televisionGastropod shellDefault (computer science)Projective planeCommon Language InfrastructureCellular automatonConfiguration spaceComputer fileThermodynamisches SystemService (economics)Form (programming)Default (computer science)Functional (mathematics)Gastropod shellDifferent (Kate Ryan album)Computer animation
Integrated development environmentGraphical user interfaceThermodynamisches SystemCommon Language InfrastructureSoftwareGastropod shellDirectory serviceThermodynamisches SystemDefault (computer science)Projective planeDirectory serviceRootComputer animationLecture/Conference
Gastropod shellInteractive televisionDefault (computer science)HookingThermodynamisches SystemLevel (video gaming)Gastropod shellFunctional (mathematics)Cellular automatonServer (computing)Parameter (computer programming)Default (computer science)Web 2.0Directory serviceClient (computing)Configuration spaceDatabaseRevision controlWeb serviceSoftware developerMessage passingComputer animation
Process (computing)Gastropod shellData managementService (economics)Integrated development environmentService (economics)Process (computing)LoginComputer animation
Patch (Unix)Revision controlLetterpress printingOptical character recognitionRevision controlSoftwareCellular automatonProjective planeWeb pageConfiguration spaceMathematicsThermodynamisches SystemIntegrated development environmentPatch (Unix)Gastropod shellComputer animationLecture/Conference
outputRevision controlSimilarity (geometry)GeometryComputer animation
Service (economics)Configuration spaceService (economics)Memory managementModulare ProgrammierungSimilarity (geometry)Programming languageCuboidComputer animationLecture/Conference
Thermodynamisches SystemData managementConfiguration spaceModul <Datentyp>Declarative programmingModulare ProgrammierungConfiguration managementDeclarative programmingIntegrated development environmentConfiguration spaceLecture/ConferenceComputer animation
Uniform resource locatorIntegrated development environmentNetwork topologyComputer animation
Transcript: English(auto-generated)
Hi, I'm Ivan Mencik. I'm from Slovakia. I came to tell you something about Nix technology and ecosystem and How to use it for your geospatial project. It's a huge topic. I have 100 slides. I need to be
really quick Yeah, like I'm a long-term Linux user Geospatial software user I started contributing to Nix in 2021 and this year I started Nix packages or Nix
geospatial Team. Yeah, and if you want to know more about Nix, I have a specially customized badge This is how you can recognize me. This is Nick's logo. Just like come to me. There will be probably no time for questions Yeah, so like what's the problem with it's not the problem but this is the current state of geospatial software we have
multi level dependencies in our software stack we have core libraries which Don't depend on anything geospatial usually which is like pros and geos and then we have another level of core libraries
Which depend on those libraries and then we have a Python libraries which depend on what's below On those core libraries and then we have another level of Python libraries Which depend on those Python libraries and they depend on this and then on top of that we have databases which depend on Anything below and we have web applications. We have desktop applications
We have like AI applications and they depend on on whole stack and we totally depend on those core libraries to provide us access to To formats to transformations to
Some processing Processing pipelines and we are extremely happy if like new new format is added to to GL or Some bug is fixed but like the lower the change happens The bigger is the impact on anything which is On top of those libraries. So many times there's a bug fixed and we want to
Apply this straight away to whole our stack, but there are situations when even if it's a bug and we have a bug fix it's going to break our processing pipeline because our processing pipeline works that way and the Fix is going to break so we don't want to apply
immediately and like sometimes we can't even work with the latest version because it doesn't work for our use case and usually we have Heaps of projects we don't have a one project and all those projects have like different Requirements and different life cycle and different
Age so this is how many dependencies are coming to play to Python Fiona Library, this is the core C library and this is all of those dependencies you need to successfully run
Run Fiona, basically, it's really really a lot So like how we install our software, sometimes we compile from source code. Sometimes we get it from Linux Linux This repos we get it from PPAs ours flat pegs snap images container images and
Anything else so like it's a huge mix of software and different kinds of software come from different vendors and different different sources, so this is a typical Example you have been to Linux you install g.js approach like core libraries from Ubuntu GIS
Then for some kind of data processing you install a Fiona to your Python virtual and by the way Fiona comes with GDAL again It's optional but this is the default. This is the default you can turn it off but it comes with
GDAL bundled in the wheel for data processing We install a QGIS using flat pack and then we have some web service installed to our Alpine container So typical problems, which we usually have like Because everything comes from different vendors. We have totally inconsistent
libraries like we can have like five different gdals easily on our Computer one from flat peg one in From pypi and and so on we have a we are going to have a problems to replicate it on different
platforms like bunted gis doesn't usually work with arch Linux doesn't work with Mac OS we might have a huge problems to reproduce it in a next after five years from now and like The biggest problem is how to support like really dozens projects of different age and
with different requirement different software version different customizations So next really can solve that this is One of the main purpose why it was designed to really like Correctly run software on our computer. So what is next there are like
Many components of basic next ecosystem going to talk about the main ones for the main one one of the like the first thing is nix as a package manager the first component it is really
not Using these words for no purpose. It is really the most unique and Advanced package manager it is cross-platform Which means it runs on any Linux distribution it runs on Mac. It can run on Windows WSL 2 and
Outputs of nix are bit-to-bit Reproducible this is reproducibility is big topic more on that later So it can run multiple versions of software without dependency conflict. This is not very common Think nix doesn't conflict with other package managers or software on your whole system
So you can run your Ubuntu and up and you can still run nix easily and it has very strong cross compilation Capabilities it can build Container images it can build Data processing pipelines it can build operating system. It can build whatever
Basically you want so this is the example of single application Installation like traditional way traditionally looking way how to install software so next profile install GDAL from somewhere so this will install GDAL for the user executing the command
You can have multiple profiles multiple users with different things, but this is not the best way how to do is just like Example you can create some temporary on-demand Environments using different command called nix shell this will install GDAL as well
You can play with that do your work if you do exit you don't have GDAL Anymore you can run software from any arbitrary internet Repository using another command nix run There's a github repo my github repo and it's running qg's a long-term release
Just with option to print the version You see before I was not able to access after I was not able to access qg's So it's just like example of just running software without without Anything else? This is the example using old
old command line interface how to run on Current one two words and how to run GDAL 1.7. No problem to do it so to Describe
to write build Instructions and Everything at nix we are using nix language. It is pure lazy evaluate the functional language this means something I'm not going to dig into it too much We use it to write build instructions, which means packages modules functions
And you can think about it as a JSON with functions. It is really like a good mental model for starting this is the example of of Basic build instructions for for geo so we have We have a function which takes
Few arguments like the name version and then we have another function with download the source code from from internet it has exact hash of the content of the source code and then we have Q Key dependencies you make and Nix will automatically build GDAL from from this instruction
It's not going to be like the best possible build configuration under the sun, but this is the basic Example of it. So another core component of nix ecosystem is nix packages Nix packages is really the largest and most up-to-date collection of packages on our planet
We build packages for Linux and makes or make OS on different platforms Nix packages contains free and non free software a lot of non free software, which is not built but But you can use nix install this Non free software just just to be compliant with licenses
It already already contains heaps of geospatial software. We have 12,000 github stars 10,000 forts Usually we have like 5,000 open PR Like in one month we can merge 5,000 of them open like 1,000 more easily
so this is the graph showing amount of packages and their state of Like their freshness. So this is amount of packages. This is freshness of those packages. So here are Linux distributions Debian and Ubuntu and everything else here is nix. So nix has dead more
Amount of packages which is only comparable to arch Linux I think it's even more currently but like art art. This is not official art repository, this is art user repository which contains like everything and
Our packages are more up-to-date even that Even comparing to art user repository So number of contributors is really growing each year as you can see we have now like around
1,000 contributors the problems Are always present currently we can build QGs on Mac because there is like not enough Make Knowledge I guess so another Component is nix operating system another very unique
operating system It is declaratively configured which means like you say what you want not how to get there I won't progress well, and it will give you a postgres quell It is configured using a module system software comes from nix packages to releases per year and dozens of another
very unique Features this is example of configuring nix OS so like Here you can see I said I want service open SSH Running on this port. I want postgres quell. I want these two databases to be present I want them to be backed up so service postgres quell backup, and I want to back up these databases
And I want to XFCE Desktop available in my computer. This is enough to to get full Operating system running Database and desktop so next community provides another heaps of other
software tools For for nix So what are the other thing about nix so I picked up a famous example from Mitchell Hashimoto Who is really like not? Some random person from internet
He's really a very smart IT person out or a vagrant packer console terraform walled nomad and heaps of other things he's saying that The next learning curve is like a sheer cliff hardest learning curve of probably in tech I ever learned and this is from person who knows really everything so it's quote from
2021 in 2022 he's saying is that He is you still using nix and the problem with nix is how quickly you lose touch with a reality or Reality of others in terms of managing dependency versions So so he forgot that there are some dependency health in another
world so Very positive quote and in 2023. He said I still stand by Nix is that number one most positively impactful technology. I've learned in recent years. So this is like really bold statement
So some a little bit of history, this is the guy who started whole thing in 2026 writing his famous PhD thesis alco dolstra Then there was another guy doing master thesis which kicked off nix OS operating system in
2008 we Got a module system powering nix OS in in 2015 there was a first nixcon alco is still like Very active in the next community. I met him one one month ago at the meetup So this is the first sentence of his master thesis
This thesis is about getting computer programs from one machine to another and having them still work when they get there. So it's still a valid point basic examples, I'm really Going to simplify that The biggest topic is reproducibility, which means the same out inputs
And as exactly same outputs bit to bit or back to back To achieve that everything is built in like very strongly isolated environment from host internet and with heaps of Configurations which guarantees that it's always ends up exactly like that
Whatever next builds it ends up in next door, which is special directory next flash Store and ends up in the subdirectory which is called store part, which is which is Named using unique cryptographic hash based on inputs of what you are building
Same inputs always end up in same hash and vice versa So this is the example of next on directory. I built G doll I build another G doll another G doll built QG. So if you see this is the same version of
Yeah, the the structure is has package name and version. This is the structure for packages We can build different other things. But this is example for packages. So we see we have The same version of G doll multiple times, which means that I build the G doll probably with different page or different build
configuration Here and I can run them. This is the content of the directory familiar directory structure of G doll nothing extremely special there and The key
Key Concept is that the software can't just run like the package just can't run by itself It always needs to run with all dependencies including basic C library and all those dependencies must be exactly those which That package is intended to use with exact hash
Which Belongs to that package and there's another Yeah, okay, so yeah, this is the example if you want to run G doll it needs all this software
down to glibc exactly with those hashes guarantees which guarantees the exact build and if one package needs Equally same dependencies as another package. They are nicely reused between those Package this is the very big big big advantage over flat back. For example, so you share what you want
What you can because it's reproducible if I built software on my machine It doesn't need to build to be built anymore. It is stored In cache. We have a local case on our machine. We have official next packages cache. We can have
another third party or By us built cache services and We can forever use once built Package or any kind of output so why reproducibility is important
We can have exactly bit to bit same environment for dev test UAT CI production environments we Run and build we can run at the same Software built once We need to run a test to it only once if it's
running against reproducible Software so for example for science it is even more visible you can You can share your environments with your experiment for others to reproduce that There's a famous article about the reproducibility crisis in nature magazine
2016 which is saying really fun, I mean which is Which is saying that 70% of researchers have tried and failed to reproduce another scientists experiments and even more have failed to reproduce Another so how to install the two installers of next currently both are
Good and some of them enable some features some of them Not by default there's an installation so how to use next for geospatial environment So this is a typical
Typical Project setup and the requirements I want to pick up my machine Initialize git repo and get project dependencies and start basically working I don't want to blow up my system and break other projects and over the time
I want to update my dependencies with configure and configuration rollback my changes customized with packages with patches and Yeah, I want to skip some other slides, so how to How to use
Sorry, okay So what is Geonics as a point of this presentation. It's my proof of project proof of concept Project which is building pet project development environments for geospatial Projects It provides the latest geospatial packages like one to GIS but for all Linux distributions and Mac and Windows
WSL it provides isolated project environments like Python virtual and but for all software It provides some functions for For running geospatial services like PostgreSQL and others it can build container images
So how to how to? Start a Unix project. There's a command Unix CLI in it, and it will give you two files One of them is a configuration file where you configure your
Project in the in a form that you create Some kind of shell environment so here I'm creating two shell environments one for packages one for services default is for packages PostgreSQL is for Services there are different function functions, which allow me to do so so
Now how to launch those Environments so everything I need to do in my root directory of my project is to say next develop and name of the of the Environment so if I do next develop default. I have all packages coming from default
Environment so I specified Gdell there, so I have a Gdell if I do next develop PostgreSQL I have Nicely running PostgreSQL running under my user in my project Directory if I want to add more stuff to my shell environment I
Just add them to extra packages parameter of the function there are other Parameters or arguments of the function As well, so this is extended. I added few packages and calls a message to my environment
If I want to develop Python there's another function make Python their shell Which turns my environment to Python environment? I can specify version I can specify my dependencies for example Fiona. I can have some non Python packages there, so if I re-enter my shell environment and say next develop default I have
Python prepared Environment so I can for example Try Fiona if it works it works. I can even use poetry to install additional dependencies, so I installed flask From PyPy and it works nicely with what comes from Nix. I can extend
PostgreSQL by just like saying I want PostgreSQL 12 and PG routing To be present I can add more And not of another environment for example some client environment Which allows me to easily to connect to my PostgreSQL, and I just made one more
mock web Environment just running Python server. I checked if I haven't done any mistake in my configuration these are Environments which I created immediately available for Darwin which is Mac and for for
Linux thank you and You see I'm running PostgreSQL. I can connect to database This is my web service if I don't want to Run all those services by by hand I can use process compose where I just list all my
My services in one file, and if I run process compose I have a nice UI which starts all services gives me a logs like Docker compose for example, there's even a way how to This is killer another killer features how to how to patch
Packages for example in this example. I try to create the patch which is Just like overwriting the version of gdal to something else I just use that page in my project Configuration like this and I just re-entered my
development environment and Next evaluated my change and rebuilt everything which was needed so it's not me knowing what needs to be rebuilt, but next exactly knows what to rebuild and I just Re-entered my shell environment and everything was done so so you see here all software is now using that
Custom gdal version revision 19.9. It's kirgis. It's Fiona. It's post GIS Doing that there's a way how to log packages to certain version how to update them
How to roll back to previous version you can do You can compare different comments using different dependencies And find if they break something And you access yeah So there are other similar tools like geo nix
There's a devent which is done by really like nix gurus and veterans And it has another heaps of features how to enable 50 more most now famous Programming languages using module system similar to nix OS you can start services
But just like saying I want to have PostgreSQL. I want to have some kind of containers There are other tools as well dev box It has this kind of configuration all of them are using nix so like last three sentences my conclusion
Really like after a couple of years using nix is that containers were really the best development environment until I discovered nix and Ansible Ansible was really the best configuration management until I discovered nix OS declarative module system configuration yeah, so if you are interested just come to me and
Thank you very much