oliverdavies.uk/source/_daily_emails/2024-12-15.md

57 lines
1.7 KiB
Markdown
Raw Normal View History

---
title: Notes on Nix
date: 2024-12-15
permalink: daily/2024/12/15/notes-on-nix
tags:
- software-development
- nix
- nixos
cta: ~
snippet: |
I wrote a simple Nix derivation to add Nick Janetakis' notes application to my computers.
---
After writing about [making notes in text files][0], I came across [a video by Nick Janetakis][1] (previous [Beyond Blocks podcast guest][2]), showing a simple Bash application he'd written to manage his own plain text notes.
I thought I'd try it, but it wasn't available in the nixpkgs store so I wasn't able to install it.
Some of the Vim and Neovim plugins I use also aren't available and I've added those to my configuration myself and wanted to do the same for this.
Here's the Nix derivation I wrote:
```nix
{ pkgs, ... }:
pkgs.stdenv.mkDerivation rec {
pname = "notes";
version = "0.3.0";
src = pkgs.fetchFromGitHub {
owner = "nickjj";
repo = "notes";
rev = "v${version}";
sha256 = "gyrsTWPT8w4DsRim3jlbjvpXwX/y+7SwLaM+3LVOJdU=";
};
buildInputs = with pkgs; [ bash ];
installPhase = ''
mkdir -p $out/bin
cp $src/notes $out/bin/notes
chmod +x $out/bin/notes
'';
}
```
I defined the GitHub repository name and owner, the version number and the required installation steps, and was able to add it to my configuration for use in NixOS and Home Manager.
Now, I can type `notes` and easily capture whatever I wanted to document in the appropriate text file..
---
FYI, there is an existing `notes` program in nixpkgs, but I overwrote it with Nick's, which is another great thing about using Nix!
[0]: {{site.url}}/daily/2024/11/10/write-plain-text-files
[1]: https://youtu.be/NasPBjSev88?si=nSaCxdtXuznQ_YYb
[2]: {{site.url}}/podcast/12-nick-janetakis-docker