Install config fileset from Github to \var

I have applications that need a set of configuration files - e.g. nodeRed. I
can’t easily put those configuration files directly into configuration.nix -
they’re a bit big.

I want to put the configuration files in my own Github, then install them
to \var\nodered, and then tell node-read to use that as it’s config directory

I can see examples using fetchGit and fetchGitHub, but these tend to download
and build the files. I just want to copy them to /var.

Can anyone suggest how to do this?


Martin Green

To do literally what you ask, I think you would need to use system.activationScripts. You’d use that to copy the script you got from fetchGithub to /var at system activation time.

However, there is almost definitely a better way. How do you instruct nodered to use a specific configuration file? If it can take a command line argument, you could point it directly to a file in the nix store, either through a wrapper or a systemd service. How do you currently install/execute nodered?

Thanks for replying. Currently Node-red is running as docker on another machine, with a data directory and a config directory. My task is to convert that to NixOS. NodeRed is an interactive programming system - so it needs a place to store the scripts that a user creates. Node-red is a nixos package
but the main option is just a folder where the configurations live.


The directory to store all user data, such as flow and credential files and all library data. If left as the default value this directory will automatically be created before the node-red service starts, otherwise the sysadmin is responsible for ensuring the directory exists with appropriate ownership and permissions.

The default config is pretty long, and I’m not 100% sure it can be read-only, because I think
the node-red GUI can modify it. There’s also one or two other configuration files, one of which
definitely can’t be read-only.

Moreover, one of these configuration files is essentially my scripts - and I really want these in Git.
There is an option in the latest node-red to use Git directly, but last time I tried it, things broke

Anyway - this is really part of a bigger learning exercise. I love NixOS, but as a new user (with many years tech experience) there are gaps I’m struggling to understand.

For example, I want to install some shell scripts on a machine from git during build. I see people
inserting text into configuration.nix to write a small script, but I’m not sure how you’d get a larger script
copied - can configuration.nix read local files next to it?

Would you mind sketching out how you’d connect the output of fetchgit to a CP command to copy it to /var/node-red? I think the output of any derviation is a path - but I don’t see how it connects?

Thanks very much!


Ah! My bad, I was looking for a package named nodered :slight_smile:

Yes! It’s one of the basic value types: Values

The nixos module also has services.node-red.configFile. You can use that to import your file via a path, if I’m not mistaken:

services.node-red.configFile = ./settings.js

I’ll find a moment to sketch out a handful of proper solutions here eventually, been a busy few weeks :slight_smile: But in a nutshell, the “best” solution will probably be to defer to the node-red manual to see how they handle read-only config files; the nixos module passes the config file via one of their CLI arguments, so they presumably handle this in some useful fashion :wink:

Keeping these files in git shouldn’t be an issue either, since you can just keep them with your nixos config (which should absolutely be in a git repo; it’s possible to keep it in a non-root-owned directory if that’s a problem for you).

I might have been mistaken about the configFile - maybe that can be read-only. But it
references the flows file and that cannot be read-only, because it’s where the flows the
users create are stored.

I’m still absolutely sure that I need a read-write directory which I can initialise with one or
more files from github. I’ll want to push the modified files back too… but that could be
a second step.

If you get chance to give me some examples, that would be great :slight_smile: