TIL: How to Use Clipboard Data as File Input in Bash

TIL: How to Use Clipboard Data as File Input in Bash Recently, I wanted to run a bash script where it needed to receive a JSON file as input. However, the JSON I had was taken from somewhere on the internet. In this case, it was taking a JSON blob and converting it to a nix attribute set. However, I didn’t want to save the contents to a file beforehand. ...

 2023-11-01 129 words 1 min

How to Setup a Go Development Shell With Nix Flakes

As you may know, I have been using Nix/NixOS for the last few months. I finally started doing some development, after spending lots and lots and lots of time tweaking my setup (and neovim). As part of starting to do some real development work, I am now trying to leverage devshells with Nix flakes. I like the concept of Nix devshells, I have tried using Docker dev containers in the past, but the issue I had with those was adding my tools such as shell (fish) or cli tools was not easy. ...

Part 2: How to Setup Nixos as Part of Your Development Workflow

Premable In this second part of the series, we will look at how we can not set up NixOS past installation. How we can install software and various other tools. After part 1 we should have NixOS installed, mind you since I’ve written that blog post I found a way to create a custom ISO image from my Nix config. This ISO contains a custom install script, the main advantage being able to use a tool called disko to partition our disks. ...

TIL: How to Fix Networking Issues in a Libvirt VM and Mullvad VPN

TIL: How to Fix Networking Issues in a Libvirt VM and Mullvad VPN Recently, I was trying to run a libvirt virtual machine, created using virt-manager. The VM was running NixOS and somehow no matter what I did it would not connect to the internet. I was running Mullvad as my VPN, and it turned out this was the app causing issues, I had to turn on Local network share 1. ...

TIL: How to Disable Linters in Golangci Lint for Test Files

TIL: How to Disable Linters in Golangci Lint for Test Files Today (for once), I ran golangci-lint run and it failed on CI with the following error: internal/options/parser_test.go:13: Function 'TestParse' is too long (69 > 60) (funlen) func TestParse(t *testing.T) { task: Failed to run task "lint": exit status 1 Where my .golangci.yml file looked like this: run: timeout: 5m skip-dirs: - direnv linters: enable: - bodyclose - dogsled - dupl - errcheck - exportloopref - funlen - gochecknoinits - goconst - gocritic - gocyclo - gofmt - goimports - gomnd - goprintffuncname - gosec - gosimple - govet - ineffassign - lll - misspell - nakedret - noctx - nolintlint - revive - staticcheck - stylecheck - typecheck - unconvert - unparam - unused - whitespace So basically we want the ability to turn off funlen for our tests (and other linters). ...

How to Create Systemd Services in Nix Home Manager

I recently learnt in home-manager (Nix) you can run systemd services as your own user. This is nice because we don’t need “sudo” permissions to do so. I also prefer to have as much of my config as possible in home-manager, again I don’t need to run “sudo”. Which is probably safer running apps in the least privileged mode. In my case, I wanted to run an attic, a binary cache, watch store command which uploads any changes to /nix/store to my binary cache. ...

TIL: How to Colour Dap Breakpointed Line in Neovim

TIL: How to Colour Dap Breakpointed Line in Neovim I wanted to change the background colour of the line when it was stopped during debugging using DAP with neovim. To make it easier to see where we are currently breakpointed. We already have a highlight group called DapStopped. Which in my case is defined as: DapStopped = { bg = C.grey }. Then we need to assign the custom highlight group, the key bit being linehl for our use case. ...

TIL: How to Fix Package Binary Collisions on Nix

TIL: How to Fix Package Binary Collisions on Nix Recently I wanted to use GNU parallel, a nifty little tool we can use to run tasks in parallel, shock horror I know. I already have the moreutils package installed using nix (home-manager). So I added this: home.packages = with pkgs; [ parallel moreutils ] Then I ran the home manager switch like usual, I got the following error. error: builder for '/nix/store/vh6i81xhf6pvybdpall8z8l8y0i6mr8p-home-manager-path. ...

 2023-10-02 181 words 1 min

Setup Ventoy on Nixos

Introduction Typically when we want to install a new OS we use an ISO to create a bootable USB drive. We can then plug this into our device, say laptop, and boot from that USB and install our OS. However, typically you can only put a single ISO on a USB. So what if wanted a USB with say Window, Arch Linux, TailsOS and NixOS how could we do that? ...

TIL: How to Use fzf.fish History Search

TIL: How to Use fzf.fish History Search I use Fish Shell with fzf and fish fzf plugin. I installed fzf using nix and home-manager: { programs.fzf = { enable = true; enableFishIntegration = false; }; } It adds fzf-history-widget script, which is bound to ctrl+r, shell reverse history search. Which we can see when we run this: bind | grep -e fzf-history-widget -e fzf-file-widget Whereas I wanted to use the _fzf_search_history which is made available by that fish fzf plugin. ...

My NixOS Dotfiles Explained

In this post, we will just go over the basics of how we can configure our setup using a git repo, nix flakes and home-manager. I will go over how I structured my nix config. Not an in-depth tutorial Note this will not be an in-depth guide into NixOS/Home Manager itself. That could well be a series on its own. We will just go over the main ways I configure NixOS/Nix and why I do it the way I do. ...

TIL: How to Check if Another Option Is Set in Home Manager (Nix)

TIL: How to Check if Another Option Is Set in Home Manager (Nix) Recently I was adding sway to my nix config (setup via home-manager). I already had Hyprland config, I wanted both sway and Hyprland to use my waybar config with some slight differences. So basically I want to check if the current host machine is using Sway or Hyprland (I am assuming we will only use one). The main reason for using Sway is my work laptop uses Ubuntu 22. ...

TIL: How to Access System in Home Manager Using Flakes

TIL: How to Access System in Home Manager Using Flakes Recently I needed to install devenv using flakes in home-manager. One of the things I needed to pass to was the type of system to install on i.e. "x86_64-linux". So as I temp hack I had something like: inputs.devenv.packages."x86_64-linux".devenv. However I was able to access the system using the pkgs attribute like so: { inputs, pkgs, ... }: { home.packages = [ inputs. ...

TIL: How to Fix tmux-resurrect on NixOS

TIL: How to Fix tmux-resurrect on NixOS When I moved to NixOS I noticed that tmux-resurrect stop restoring some applications such as man and nvim. Like it used to on my Arch machine. I recently found a solution to my problem (thanks to a lovely chap on the nixos discourse). By adding the following lines to our tmux config: resurrect_dir="$HOME/.tmux/resurrect" set -g @resurrect-dir $resurrect_dir set -g @resurrect-hook-post-save-all 'target=$(readlink -f $resurrect_dir/last); sed "s| --cmd . ...

 2023-09-01 225 words 2 min

How to Use Cachix Devenv to Setup Developer Environments

In this post, I will go over how you can use Cachix’s devenv tool to help create/set up consistent repeatable developer environments. You could use nix flakes if you wanted to as well, without needing another tool. However, I like how devenv provides a few other “tools” within that we can set up from a single devenv.nix file. Such as pre-commit hooks, container support etc. This blog leverages devenv to create/set up its developer environment. ...

TIL: How to Colour Neovim Line Numbers

TIL: How to Colour Neovim Line Numbers Recently I was trying to configure my own neovim config. I wanted the current line I was onto be coloured slighty differently and also the line number to be white. So it’s easier to see the line number and which line I was on. It was not immediately obvious how to do this and took me long to work out than I’d like to admit 😅. ...

 2023-08-24 142 words 1 min

How To Self Host Your Own Atuin Server

In this article, we will go over how we can self-host our instance of Atuin. A tool we can use to sync our shell history across multiple devices. In the previous article, I showed how you can use the official server. However you may want to run your self-hosted one, so no one can access even the encrypted version of your shell history. We will deploy our instance to fly.io. Why fly. ...

How Sync Your Shell History With Atuin in Nix

Atuin is a great tool I recently discovered that can be used to sync our shell history across multiple machines. We can either self-host this or use the “officially” hosted one. In a future article, I will show you how you can self-host your version of Atuin on fly.io. But for this article, I will assume you have a server setup. Your history is end-to-end encrypted so the official server is safe to use and store your history on. ...

TIL: How to Setup Neovim for Nixlang

TIL: How to Setup Neovim for Nixlang I have been recently using NixOS/home-manager and I have been writing a lot of nixlang. To have my system state declaratively set up. I have been doing most of this editing in neovim. It took me a bit of time to work out how to get it set up so there is some basic LSP support and auto-formatting. I created a file called nix. ...

TIL: How to Fix VIA Permission Issues on Linux

TIL: How to Fix VIA Permission Issues on Linux Recently I have been trying to configure my newish Keychron keyboard using VIA. To add a key to be able to take print screens, making use of the layers provided, as my Keychron Q1 PRO doesn’t have a dedicated print key 😓. However, when I opened the app or the website, I would get the following error. If we go to chrome://device-log you should be able to see something like this: Failed to open '/dev/hidraw9': FILE_ERROR_ACCESS_DENIED. ...

 2023-08-02 151 words 1 min

How to Use Neotest Dap With Lazyvim for Golang Development

In this blog post, I will show you how you can easily setup Neotest to make testing easier in neovim and DAP to make debugging your tests is a lot easier. I am using the LazyVim neovim distribution, where these two come as easily installed extra plugins. However, it should be easy enough for you to copy the config over to your neovim lua config. LazyVim even has the config available on its website, you don’t even need to deep dive into the code 😄. ...

TIL: How to get Kanshi to work on NixOS and Hyprland

TIL: How to get Kanshi to work on NixOS and Hyprland I have been using Kanshi to setup my monitor setups automagically depending on which monitors are plugged i.e. if my laptop is docked or not. If it is docked I want my laptop display to be off, when not docked I want it to be on. So my kanshi config file ~/.config/kanshi/config to look something like: I use the name of my monitors as the ports they are plugged into my vary. ...

Part 1: NixOS as part of your Development Workflow

Introduction Dev Machine My main machine for development at the moment is a 12th Generation Intel Framework Laptop. This series has been inspired by Dev Workflow Intro by Josh Medeski. In this series of posts, I will go over how I have set up my developer workflow and explain why I have made certain decisions and why I use certain tools. This series aim to make it less daunting for you to start your journey on improving your developer workflow. ...

Part 0: Hardware as Part of Your Development Workflow

This series has been inspired by Dev Workflow Intro by Josh Medeski. This is sort of a precursor to my series about how I have set up my development workflow. Hopefully, you will be able to pick a few tips and tricks you can add to your development workflow to make it more efficient. Or even give me tips on how I can make my workflow more efficient. In this post we will go over arguably the least important, but at the same time quite important, part of our workflow. ...

My Dotfiles III

My latest iteration of my dotfiles, where I am now using a Laptop as my main development machine (Framework). I’m also using Hyprland as my window manager. Most importantly using NixOS and home-manager to declaratively define the state of my machine i.e. what packages to install, dotfiles. CURRENTLY A WIP 🏠 My dotfiles repo, setup using nixos/home-manager Install 🔥 I wouldn’t recommend just blinding using my dotfiles. They are setup for my specific use-case. ...