How to Wrap NixGL Around Package in Home Manager

I use Nix mainly with home manager on my Ubuntu laptop, and for the most part, it works fine. However, some apps installed using Nix, need to use nixGL. A wrapper tool for OpenGL, allowing Nix installed tooling to use the system’s OpenGL and Vulkan APIs. Some apps including kitty and Firefox (mainly for Google Meet). There is currently a branch in home-manager we can pull into our config, which provides a convenient way to wrap these apps in nixGL rather than needing to specify say nixGLIntel kitty in our terminal or say Hyprland config (key bindings). ...

How to Set up Cloudflare Tunnels With Traefik (In NixOS)

Recently, I was setting up Navidrome, kind of like a self-hosted Spotify, in my home lab and I wanted to set it up to use proxy auth in Authentik. But to do this I needed to use with a reverse proxy, i.e. Traefik. In this article I will show you how to you can point your Cloudflare tunnel to Traefik and have that forward the request to the service. Prerequisite In this article, I assume you are already familiar with Cloudflare Tunnels and Traefik. ...

TIL: How to Cancel Stale Pipelines in GitLab CI

TIL: How to Cancel Stale Pipelines in GitLab CI Today I learnt that we can cancel old pipelines in MRs. For example, you push a new commit, and you don’t care about the old pipeline running any more. You want to cancel them to save CI minutes etc. Here is an example, you can see the 2nd pipeline is cancelled: We need to add this to our .gitlab-ci.yml file. Where the default.interruptible marks every job as it can be cancelled 1. ...

TIL: How to Get Shell Completions in Nix Shell With Direnv

TIL: How to Get Shell Completions in Nix Shell With Direnv When shell completions don’t work with direnv, you may need to use nix develop to load the shell manually. Background I am using nix-direnv, with nix devshell to autoload into my development environments. I changed the directory and the devshell is automagically loaded without me doing anything, which is great. Provides me with a bunch of tools specific for that project. With all the benefits of Nix, mainly reproducibility. ...

How to Set up Authentik Forward Auth With Traefik on NixOS

In this post, I will show you how you can set up forward auth for a single host in Authentik, with Traefik as our reverse proxy on NixOS. This is particularly useful way to protect apps that don’t have any built in auth. Authentik is a great app which can handle authentication for almost all of our home lab. So we only need to log in with Authentik, to log in to any of our apps. Rather than needing separate passwords and usernames for each app. ...

Setup TLS Certificate With Traefik & Tailscale on NixOS

Recently I have been playing around with running a homelab directly on a NixOS machine without kubernetes. I didn’t want to bother to have to setup certificates using Traefik (DNS challenge) and Cloudflare. I wanted to use the certificate that comes with Tailscale (wireguard VPN I use to connect to my home lab). In this post I will show you how I set this up as a Nix module. Nix Let us look at the relevant Nix code. ...

How to Configure Kitty on Nix to Show Emojis

Recently, I was trying to configure the terminal emulator Kitty with Nix and Stylix, and I was having issues with it showing emojis. It took me a lot longer to figure out than I would like to admit. So I decided to write a blog post, showing you how I did it and perhaps saving you some time. I did this in my home-manger config. First we install the Symbols Nerd Font, there are two ways we can normally add nerd fonts. Either patch our font, which I had already done with my font Mono Lisa or use this font (symbols), alongside your font (as a fallback). I haven’t fully managed to get that to work on my system, so I have both normal Mono Lisa and Nerd Font variants on my system at the moment. Else other apps besides Kitty break. Anyway, tangent aside, you can install like this: ...

How I Set up BTRFS and LUKS on NixOS Using Disko

In this post, I will show you how you can declaratively partition our drives using Nix(OS). TL;DR; We can use a tool called disko to partition our drives declaratively and combine it with NixOS anywhere for a remote install. Showing an example setting up LUKS encryption with BTRFS file system. Background If you’re like me, then when you started playing with NixOS, You found yourself constantly reinstalling it and starting again. Either setting up new machines. Playing around with it in a VM or even realising how to set up LUKS and hibernate properly. Or even when setting up impermanence. ...

How I Configured Zellij Status Bar

As some of you may know, I moved to Zellij a few months ago from tmux. In this post, I will show you have I configured the zellij status bar in nix. So it acts more like how my config did in tmux. My current Zellij status bar. (Optional) Background A bit of background, which you can skip if you’d like. What is zellij? Some of you may be wondering what is zellij/tmux. They are what we call multiplexers. Essentially, our terminals now can have a client server architecture. So we can kill our terminal but, our session will still be alive. Which makes it great for jumping between projects if you are using say Neovim. When I first moved to tmux, I found it is great because now I don’t need 4/5 VS Code instances open. Instead, I could use a script to jump between my projects, and tmux would keep the session alive, so just how I left the project. Zellij does basically the same thing for me. ...

Part 6: Fish Shell as Part of Your Development Workflow

After a long break, I am again writing about my workflow. The big issue I have with this series is that my workflow is kind of always in flux and changing. Which maybe is a bad thing. I just need to pick some tools and stick to it. Rather than trying four different terminal emulators, i.e. alacritty, kitty, foot and wezterm. However, over the last ~5ish years, one thing that has remained pretty constant is my use of fish shell. In this post, I will go over why I stick with fish, and how I have set it up for my own use case. ...

Rewriting a Python script as a Bash one-liner

In this post, I will describe how I went about replacing a Python with a bash liner and how it decreased the runtime from 30 seconds to 1 second Background For this blog, I used to have a Python script which I would use to generate open graph images. These are images you sometimes see in apps when you share a link. For example: Essentially, what it would do is go through every post in my blog repository. Then run a go program to generate the open graph images based on the markdown front matter. ...

Migrating My Homelab to Flux

Background This series is a continuation of the other series. I have since updated my home lab, removing the RPIs and replacing them with some mini pcs. As part of this change I am now using deploy-rs instead of colmena. As its easier to integrate into my own flake, and it won’t roll out the change if breaks the networking, i.e. you cannot ssh to the machine. Why move away from Pulumi? As per the title of this post of the most significant changes I have made it moving my Kubernetes config from Pulumi to fluxcd. Pulumi I suspect is great for deploying infrastructure but became painful for managing the YAML config for the k3s cluster. ...

TIL: How to Fix Did No Resolve Alias Errors in Podman

TIL: How to Fix Did No Resolve Alias Errors in Podman Recently, I was trying to pull docker images using podman, on an Ubuntu laptop and was getting an error which looked something like: Error: error creating build container: short-name "node:18.17" did not resolve to an alias and no unqualified-search registries are defined in "/etc/containers/registries.conf" This is because Podman doesn’t allow us to use short names, by default we need to specify the registry i.e. docker.io/node:18.17. But for existing docker-compose.yml files, this would be a pain to edit. Especially because most people use Docker not Podman. So, in the end, you can edit a config file in home directory to enable the old way of pulling images. ...

TIL: How to Fix DNS Resolution Issues in K3s Related to Flannel Networking

TIL: How to Fix DNS Resolution Issues in K3s Related to Flannel Networking Recently, I was trying to set up the kubernetes-dashboard, to make it easier to monitor my k8s cluster. I however noticed I was getting the following error: … > add-kubernetes-dashboard via 🐹 v1.22.2 via  via ❄ impure (nix-shell-env) k$ kubectl logs -n monitoring kubernetes-dashboard-kong-75bb76dd5f-b27ll 2024/05/05 20:55:21 [error] 1319#0: *274054 [lua] init.lua:371: execute(): DNS resolution failed: failed to receive reply from UDP server 10.43.0.10:53: timeout. Tried: nil, client: 127.0.0.1, server: kong, request: "GET / HTTP/2.0", host: "localhost:8443", request_id: "af30b3162db70e2de8f1073a40f7d865" Weird the DNS resolution seems to be failing, so I decided to follow the Kubernetes guide to try to debug issues. ...

How I Fixed Hibernate on My NixOS Machine

tl:dr; Wi-Fi drivers were stopping the PC from suspending. I am using an Ethernet cable to connect my PC. So didn’t need the Wi-Fi drivers. By adding them to a blocklist. I think you only need the 2nd one in the list. { boot.blacklistedKernelModules = [ "ath12k_pci" "ath12k" ]; } Recently, I upgraded my PC to an am5 machine with an X670E Gigabyte motherboard. However, when I did this hibernate was left broken, alongside suspend. This gave me an idea, it wasn’t to do with my hibernate setup being broken by something else going on. ...

How to Add reveal-hugo to a Hugo Site

What we are trying to achieve hosting RevealJS slides on our Hugo blog like so. The markdown that the slides are built from It can be found here Background Recently, I did a talk at the Conf42 conference shameless plug here. At the time I was working on the slides using Reveal.js, as I did for all of my slides as I can create a slideshow using just plain markdown. I hosted all of my talks in a separate repository. Which published to a simple site. ...

How to Deploy Kubernetes Dashboard Using Pulumi to a K3s Cluster

Kubernetes Knowledge I don’t know a ton about Kubernetes. I am still learning, hence this home-lab project. So there may be better ways to do stuff that I have described below. If that is the case, please let me know! Just take what I say with a pinch of salt. It’s been a while since I made an update about my home lab, also an aside, I should’ve given this series a better name. So recently, I finally went back to my PI cluster and started to actually setup properly. The first thing I decided to put on it was the Kubernetes dashboard. I could get a nice GUI look into what is happening with my cluster at a glance. It also looked simple to deploy. ...

How to Use Env Variables With Viper Config Library in Go

This is part of a series of where I am going to blog about issues I had building my CLI tool OptiNix and documenting how I resolved those issues. Most will be random things not specifically related to building CLI tools. In this example, we will use the viper library. Mainly because I am already using cobra, the library to help us make CLI tools. From the same author and wanted to see how well they integrated. The Viper config library is probably over kill in my case. ...

TIL: How to Pull Submodules in a Nix Derivation

TIL: How to Pull Submodules in a Nix Derivation Recently, I was trying to create a derivation which needed to pull git submodules as well. I was getting an error which look something like this: data/meson.build:76:0: ERROR: Nonexistent build file 'data/submodules/meson.build' It was coming from this derivation https://gitlab.com/hmajid2301/dotfiles/-/blob/c153de146a3bf9339cbef013ac65bc32e6305c8e/packages/gradience/default.nix for building the latest version of gradience. It turns out when we do a fetchFromGitHub we need to explicitly tell it to also pull submodules, which makes sense. So I was able to fix this. I had to add the fetchSubmodules argument: ...

 2024-05-12 142 words 1 min

Part 5B: Installing Our Nix Configuration (NixOS Anywhere) as Part of Your Workflow

I wanted to do a short article showing you how you can use your Nix config to install NixOS on a new device. Have your device setup with NixOS in a few commands with all the packages and tooling you want. Previously I was creating my own ISO and then burning that to a USB and using that USB as live media to install my config. I had a custom script nix_installer, which would run automatically when you loaded into the gnome shell. ...

Part 5: Nix as Part of Your Development Workflow

My original plan for this article was to discuss my shell and how I configure it. But I have made some significant changes, to how I structure my Nix configuration and I wanted to go over Why I did that. I mean, likely this will probably happen a lot, as my configuration changes more often than it should 🙈. Anyway, into the main topic. My dotfiles Snowfall what? I recently ported my Nix configuration (dotfiles), to use the snowfall-lib to structure my Nix config. ...

Part 4b Foot Terminal as Part of Your Development Workflow

Earlier this year I spoke about using Wezterm as my terminal of choice, however since then, I have swapped back to the foot terminal emulator. I also have kitty available on my system. However, I don’t use it much. In this article, I want to add a quick addendum to why I moved away from Wezterm. Note as per that post, this is again not a super important decision, almost any full colour supported terminal will basically like every other. So if one work for you, feel free to stick to it. ...

TIL: How to Fix Neorg Metadata Treesitter Issues With Nixvim

TIL: How to Fix Neorg Metadata Tree Sitter Issues With NixVim If you are like me, you may be configuring your Neovim configuration using NixVim. Which is a “framework” making it easier to configure Neovim using mostly Nix configuration. Allowing us to keep most of our config in one language, at least in my case. I started using Neorg to manage my notes and to-do lists in my “second-brain”, but noticed that the metadata part was not being highlighted as I expected. ...

My Favourite Neovim Plugins

In this post, I will go over some of my Neovim plugins I really like that aren’t as well known. So I won’t really be talking about telescope, LSP or nvim-cmp. As most users know about these plugins and use them extensively in their configuration. oil.nvim Link: https://github.com/stevearc/oil.nvim oil.nvim creates a file explorer but as a true vim buffer, so it’s effortless to create new files and folders. We can also move files easily. Again, using all of our normal key bindings we use in Nix. ...

TIL: How to Set up Layouts in Zellij That Use Direnv and Nix

TIL: How to Set up Layouts in Zellij That Use Direnv and Nix I have been using Zellij for a while now. I tried to set up layouts for one of my personal projects. So that we could have tests and linting running and any other tasks we may want whilst doing development 1. However, I had an issue working out how to call commands that required direnv and nix to set up development environments. In my case, my nix dev shell installed the go-task tool to run tasks such as task lint or task tests. However the shell that zellij was running the commands in for the layout did not load my Nix dev shell, so the go-task binary was not available. ...