Create a very simple package?

Hello!

I’d like to create a NixOS “flake” that makes sure that a file exists.

If it exists, it doesn’t do anything.

If it does not exist, it downloads Monocraft.ttc (a cool minecraft font) into the ~/.local/share/fonts/ folder.

From GitHub - IdreesInc/Monocraft: A monospaced programming font inspired by the Minecraft typeface

How can I accomplish this? Thanks so much :smiley:

1 Like

Hello,

Nix alone won’t be able to do that since it can only write in /nix/store/.

If you want to achieve such a thing, you could:

We have monocraft as a package, so I think you’d simply put this into configuration.nix:

  fonts.packages = [ pkgs.monocraft ];

By the way: XY problem - Wikipedia

I mean, I assume you want to have the font available and aren’t so particular about the way of achieving it. As with NixOS you’d surely prefer what I posted to messing with ~/.local/share/fonts

3 Likes

@drupol That’s fascinating! I’m going to try out “Home Manager” and home.file. @drupol , do you know how I should best version my home.file and configuration.nix in Git? Is there an optimal workflow? I’d love to auto-download my favorite backgrounds to my ~/Pictures every time I pull my dotfiles from Git.

@vcunat , thank you for letting me know about the font packages! That’s much simpler. I’d rather not reinvent the wheel.

I will strongly suggest storing your files in a VCS of your choice, this way you can manage versionning.

Auto-downloading your favorite backgrounds could be possible (e.g., fetchurl), there are many ways to do that so, I think it is better if you experiment a bit by yourself.

Btw, yes, Nix is fascinating :slight_smile: