Self-Contained and Reproducible Scripts Using the Nix Shebang

In a previous Nix post I mentioned how you can run once-off commands with Nix without polluting your system environment. In this post, I want to demonstrate how you can create self-contained and reproducible scripts using the Nix shebang. Simple cowsay script Using the interactive nix-shell To start, imagine a scenario where you want a cow to “moo” using cowsay. The bash script moo.sh would contain. #!/usr/bin/env bash cowsay "moo" To obtain the cowsay binary without polluting your system environment you would first generate a temporary environment....

August 8, 2024 · 2 min · 261 words · Rameez Khan

Colima as a Docker Desktop Replacement?

An attempt at finding a drop-in replacement for Docker Desktop on macOS. Why a replacement? Docker Desktop has been the gold standard for building and running containers on macOS. But what is it? Is it just a fancy container GUI? Well, no. The single, downloadable package comes built-in with everything you need to build and run Docker images on your machine. Besides running a VM in the background as a daemon, Docker Desktop provides seamless plumbing into the host machine with sane and secure defaults 1....

October 28, 2022 · 3 min · 571 words · Rameez Khan

Once-off Commands with Nix

No need to pollute your system environment In the last post we discussed why it might not be wise to pollute your system (or global) environment by installing programs you’ll only run once. Often, these programs are installed and then forgotten about causing unnecessary bloat. A pristine system is easily maintained. When to use nix-shell or nix run We also showed in the last post how we could use nix-shell to temporarily bring programs into our path....

May 10, 2021 · 2 min · 217 words · Rameez Khan

Per Project Packages using Nix and direnv

Why have project specific packages? There are a few reasons why you would want to have project specific packages. Different package versions per project e.g. you are maintaining a project that uses an old version of Node.js (like this blog, I’m lazy), but use a newer version globally on your system. You don’t want to pollute your global environment with packages you’ll only use in an isolated project e.g. nixfmt to format *....

May 3, 2021 · 3 min · 492 words · Rameez Khan

Emacs Native-Comp on WSL2 with Nix

Update: As of 2021-04-25 GCC/Native-Comp has been merged into master. I’m sure package managers will be updated soon. What is Emacs Native-Comp? Emacs Native-Comp refers a to the feature/native-comp branch of Emacs. It adds support for compiling EmacsLisp to native code using libgccjit. This provides a notable performance improvement right out of the box. See here for more details. Installing using Nix on WSL2 Note: All instructions below are sourced from this gist....

April 26, 2021 · 2 min · 262 words · Rameez Khan