Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added draft of Coder and Nix article #10

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

unforswearing
Copy link

@unforswearing unforswearing commented Mar 30, 2023

Submitting the first draft of the article. I am going to do a quick review to check for minor changes this evening and push a new draft if any corrections are required.

closes: coder/coder#6447

@unforswearing
Copy link
Author

Updated to include content fixes and remove header content.

Copy link
Member

@bpmct bpmct left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start! I'm curious to what extent we can use images/diagrams to break these sections out. Also - left some feedback on the Nix + Coder stuff.

posts/coder-and-nix/index.md Outdated Show resolved Hide resolved
posts/coder-and-nix/index.md Show resolved Hide resolved
posts/coder-and-nix/index.md Outdated Show resolved Hide resolved

Nix is a very robust, and at times complicated, platform. This article will attempt to describe how to use Nix with Coder at a high level. For additional information about Nix, please visit [https://nixos.org/](https://nixos.org/).

### Benefits to using Nix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish there were some diagrams we could use to break up these sections, but I couldn't find anything particularly simple. Any ideas?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can come up with some diagrams over the weekend and will add them to the article by Monday.

posts/coder-and-nix/index.md Outdated Show resolved Hide resolved
posts/coder-and-nix/index.md Outdated Show resolved Hide resolved
Comment on lines 91 to 93
## Using Nix with Coder

Now that you have your NodeJS environment and custom toolchain setup in `shell.nix`, lets add Coder to your environment. Coder is available as a nix package and can be added to your config as the same way you have added your custom software in your tool chain. You can do so by modifying your `shell.nix` file to include the Coder package, like in the example code below:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's take another direction with this section. Instead of showing how to install the Coder CLI locally, let's provide an example template in Coder that users can choose to create remote workspaces that contain the nix shell. These workspaces could be provisioned on AWS, Docker, or Kubernetes. I have no preference, but we could show each 🤷🏼

Then, each developer could spin up a workspace and use nix to get the tools they need for their workspace inside the home directory. If it'd be helpful, I can set you up with a Coder workspace and we can work through this template.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that works for me. I initially had a section discussing templates but I wasn't sure how to connect it to the rest of the article.

It would be helpful to work through the template together so I can get an idea of how it all works. Thanks!


### Bring Your Tools with Nix

As a developer using Nix as part of a project, you can bring your own tools by using Nix shell. By default, Docker does not allow you to bring your own custom configuration to the development environment. For example, say you have spent some time configuring your shell environment with themes and plugins. To use these tools with Docker you would have to add the shell configuration files to your Docker image, and everyone else on your team would need to use the same shell configuration. This becomes an issue if your teammates don't use the same tools and plugins. In order for you to use your own configuration you would have to maintain your own separate container containing your personal configuration and if that container fails, you are responsible for troubleshooting and fixing everything in order to continue development on your app.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's mention dotfiles as an option to customize your shell, even with Docker. A lot of our users use this, but it does require extra work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dotfiles link you included resolves to a 404, but I did find this discussion. Is it related?


However mixing this infrastructure with the development environment can sometimes limit the developers ability to use the tools they are comfortable with. Developers must give up their preferred shell configuration and tooling in favor of a base set of tools and settings determined by the infrastructure. Many developers can pick up new tooling without much difficulty, but having a top-down approach to the development environment means not only are these tools fixed for the project, they may eventually break if the resources in the dockerfile become outdated.

Additionally, Docker requires that your team understands Docker and how it works to some degree. This is particularly important if something does happen to break within Docker -- your development team has to know how to troubleshoot the issue before they can resolve it. This is particularly difficult since Docker works differently between platforms. An issue one team member may have on Windows can be vastly different from issues MacOS based developers may face. There is a potential for a huge amount of lost productivity when these issues come up, both in time and brainpower spent trying to fix the issue. And when its only your setup that doesn't work with Docker you find yourself facing the [it works on my machine](https://coder.com/blog/it-s-works-on-my-machine-explained) problem.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great paragraph. Let's specifically mention that there have historically been various issues running Docker on the m1.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I was wondering how many platform-specific issues to include, and I'll defintely add info about using M1 machines.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a sentence to mention issues with the M1 chip, including links to more info.

@unforswearing
Copy link
Author

Great start! I'm curious to what extent we can use images/diagrams to break these sections out. Also - left some feedback on the Nix + Coder stuff.

I mentioned this in another comment, but can definitely get some images and diagrams together for this article. I'll start putting those together today, and will add those in by Monday.

@bpmct bpmct mentioned this pull request Apr 4, 2023
2 tasks

To use this `shell.nix` file you can run `nix-shell` without any arguments. The `nix-shell` tool will look for this file by default.

### Adding Your Tools to A Shared `shell.nix` Configuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super solid, let's explain how this shell.nix can be used inside a Coder workspace in the next section

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this under the "NixOS, Docker, and nix-shell" section


Now running the `nix-shell` command will create an environment containing the shared NodeJS nix configuration and your custom toolchain.

## Using Nix with Coder
Copy link
Member

@bpmct bpmct Apr 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's replace with:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added instructions for this process, let me know if they need any adjusting. I ran into an issue buidling the todomvc-nix project so I'm currently looking for replacement.

@matifali matifali requested a review from bpmct May 22, 2023 16:01
@ghuntley
Copy link

recommend nudging folks to https://devenv.sh (which is chrome over nix) than directly to nix btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coder with Nix workspaces
3 participants