nix.dev
nix.dev copied to clipboard
A collection "How do I ..." cookbook style recipes
For the task I am currently working on I really need to install https://github.com/aurora/rmate on my NixOS server. It's a simple bash script so I can just wget and chmod +x it, but that feels icky. I want to have it in my configuration.nix so I can use it in the future too.
After considerable Googling I didn't find a tutorial on how to "package a bash script from the Internet". Here it is, this is what you dump into configuration.nix:
{ config, pkgs, ... }:
let
rmate_src = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/aurora/rmate/master/rmate";
sha256 = "152z31xhdq9w0mn9ibv9jsnc2k1p36yr23waa6376d8m05hpmaln";
executable = true;
};
rmate = pkgs.writeShellScriptBin "rmate" ''${rmate_src} "$@"'';
in
{
...
environment.systemPackages = [ rmate ];
}
It would be nice if nix.dev had a section where we could collect quick recipes like this one.
I also have this need when working with nix. This sounds like a more in depth example of https://github.com/nix-dot-dev/nix.dev/issues/146.