Using Nix to create reproducible Go development environments

Nix the package manager has gained a lot of popularity in the last 18 months or so. I would love to be able to show other Gophers, how they can leverage Nix and its ecosystem to improve their development environments.

Including how we can use it to create more consistent development environments, between different devices and other engineers. So we get the same development environment and tooling as each other. Then how can we use it in CI, Go have essentially the same local development environment and CI development environment. Avoiding the dreaded “it works on my machine” meme.

Go is the perfect language to pair with Nix because of how simple it is to set up with Nix. Due to it having some great tooling already. We will see, we can replace some of our existing tooling to manage developer environments with Nix.

LEVEL: Intermediate

Place
GoLab Deep
Length
40 min
When
November 13th, 2024
10:00

Abstract

## Background

Creating consistent environments has been something that most engineering teams strive for. The closer you can get your development environment, to your CI environment, to your production environment, the more likely you are to catch bugs.

At the same time, we want to onboard developers fast and get them started as soon as possible, reducing friction when starting to code on a new project.

Like many developers, I have been leverage containers to help with this. Containers are a fantastic tool to have and provide main benefits. However, many containers/images have issues with being reproducible.

I would like to show a package manager called Nix and show how we can use that to have more reproducible and consistent. We will take an existing Go project and see how we can make some development tools easily accessible, without the need for a `tools.go` file, for tools like mockgen.

## Content

In this talk, we will briefly introduce Nix, and then we will talk about what Nix flakes are and how we can use them. Then we will create a development environment for an existing Go project using Nix flakes. The next part will compare it against Docker, particularly against Docker dev containers.

In the final part of the talk, I will show a quick example of how we can look to extend what we have done into our CI environment, to have a more consistent development and CI environment. We will again take an existing Go CI pipeline using GitLab CI, "nixify" and see what benefits it can provide.

## Contents of talks

We will cover the following topics (in this rough order):

- What is Nix?
- Why use Nix with Go?
- How to create a Go development environment with Nix
- A quick demo
- Compare it against Docker
- How to use Nix in CI?


## Slides on the Author's website
https://haseebmajid.dev/slides/go-lab-reproducible-envs-with-nix/#/

Slides

Video

GoLab is a conference made by Develer.
Develer is a company based in Campi Bisenzio, near Florence. Our motto is : "Technology to give life to your products". We produce hardware and software to create exceptional products and to improve industrial processes and people's well being.
In Develer we have passion for the new technologies and we offer our clients effective solutions that are also efficient, simple and safe for the end users. We also believe in a friendly and welcoming environment where anybody can give their contribution. This passion and this vision are what we've been driven to organize our conference "made by developers for developers".


Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2024 GoLab | The international conference on Go in Florence-Design & devCantiere Creativo-Made withDatoCMS