Do you know how to send a configuration file with NixOps ?
I thought that in the deployment section I could write something like
environment.etc.<path>.source = <local_path>
Do you know how to send a configuration file with NixOps ?
I thought that in the deployment section I could write something like
environment.etc.<path>.source = <local_path>
I tried
{
network.description = "foo network";
...
# first EC2 instance
ecc1 { resources, pkgs, ... }:
{
let
customFile = pkgs.writeTextFile {
name = "custom.conf";
text = "foo";
executable = true;
destination = "/custom.conf";
};
in
...
environment.systemPackages = [
...
customFile
];
};
}
It kind of work at first sight, since nixops deploy
runs without error, but impossible to find the file in the remote machine (ecc1).
Found a solution using activationScripts
to perform a copy when the new remote nixos system is activated
system.activationScripts = {
mnt = {
text = "cp ${customFile}/direvent.conf /direvent.conf";
deps = [];
};
};
It is a bit ugly, but it works.
Just for info, adding customFile
to the list of systemPackages
was completely useless. The corresponding path was not uploaded. It must be a lazy mechanism I guess.
Your first one was correct:
{ config, pkgs, ... }:
{
...
config.environment.etc."demo.test".source = ./factorio.nix;
}
$ ls -l /nix/store/hmzzs4b71l91y2rhw4r237zk4wf91yf1-etc/etc/demo.test
lrwxrwxrwx 2 root root 56 Jan 1 1970 /nix/store/hmzzs4b71l91y2rhw4r237zk4wf91yf1-etc/etc/demo.test -> /nix/store/qajrsljnjpkanycrmz9bcjjjcmq9yzjm-factorio.nix
environment.systemPackages
will not change /etc, it’s basically changing the PATH of the system and a couple of other things as well.
Thanks, I ended with this
{
network.description = "foo network";
...
# first EC2 instance
ecc1 { resources, pkgs, ... }:
{
environment.etc."direvent.conf".source = ./direvent.conf;
...
};
}
JFYI, trying to deploy
ecc1{ config, resources, pkgs, ... }:{
config.environment.etc.".direvent.conf".source = direvent.conf;
...
...
returns the following error
This is caused by introducing a top-level `config' or `options' attribute. Add configuration attributes immediately on the top level instead, or move all of them (namely: deployment environment networking security services system systemd) into the explicit `config' attribute.
I’m doing some “dirty” tricks with config, that’s probably why I have to use it. So it’s fine if you just use environment.etc...
.