Nixos: best system wide development practices?

After using Nixos for over a year as a primary OS on all machines, sometimes it still feels like I’m doing a few things wrong. One of these is: I don’t have any programming lang environment installed system wide (no ruby, no python, no golang, etc). For every small thing I want to work on, after creating a new directory, I need to copy/paste a flake.nix from another project and tweak it.

The benefit of this is that everything is isolated and self contained. The downside is that it feels a bit cumbersome to quickly write a python script, interact with sqlite, etc.

So the question is - how many of you are doing it this way, and is anyone having a system-wide install of a few environments they often use for small things? Any downside I’m missing?

I don’t have any development environment installed globally. For quickly hacking a script together i use nix-shell -p ... (the only non-nix command I use regularly).

For actual projects I copy a flake.nix from an existing project and modify that. Flakes have a template system with nix flake init, but I haven’t gotten around to setting up my templates.

Edit: I should add that I have code editors installed globally (in my case, JetBrains stuff and Neovim). My Neovim is configured to always have access to rust-analyzer and clangd.)

1 Like

I handle my projects similarly, keeping a shell.nix file around defining the runtime/dev environment. I try to mitigate the pain of new project setup by keeping a few template projects around I can base things off of. This also has other benefits like setting up common project tooling.

I also keep a system-wide install of my most frequently-used runtimes so I can quickly test stuff out.

Like @raphi , I also make good use of nix-shell -p ... for one-offs.

Something I’ve been thinking to do is a kind of hacking profile, which would have many tools, interpreters, compilers, … but that is not enabled by default, not in my PATH.
And I’d need to enable it in my current shell in some way to become active to I can quickly hack on stuff. (with a section of my shell prompt stating the hacking profile is active, so I don’t forget about it).
(maybe even a hacking profile per tech/language?)

When I’m starting to make proper things / files / ci / dev env for a particular project, I’m thinking of making my own template flake like GitHub - NixOS/templates: Flake templates named tpl for example, so I can quickly do a:
nix flake init -t tpl#some-tech
To bootstrap a good project structure

Hosted by Flying Circus.