Making a binary file in a NixOS configuration

I want to link some .icm color profile files into my home directory with home-manager, but I’m not sure how to get those files into the Nix store in the first place.

Is there something like writeTextFile for binary data? Perhaps that turns a base64 string into a binary file in the Nix store?

Try this:

home.file."path/to/whatever.icm".source = ./whatever.icm

where the path is relative to the Nix source file that this snippet is in

1 Like

Oh I thought writeTextFile { name ="x"; text = builtins.readFile ./yourfile.icm;} would also work for binary data. Have you tried? Also you should be able to use runCommand "bla" { file =./bla.icm; } "cp $file $out" to simply copy your file in the output derivation (not tested, I’m on the phone).

Edit: or even simpler if you do myfile = ./yourfile.icm then your file should be copied to the store and myfile will contains its path.

1 Like