let
swayConfig = pkgs.writeText "greetd-sway-config" ''
< CODE >
'';
in {
services.greetd.settings.command = "${pkgs.sway}/bin/sway --config ${swayConfig}";
...
}
but since <CODE> consists of many line I rather prefer to have them in a file under /etc/nixos.
The following does not work:
let
mySwayConfig = builtins.readFile config/greetd_sway.conf;
swayConfig = pkgs.writeTextFile {
name = "greetd-sway-config";
text = mySwayConfig;
};
in { ...
Yea, @markuskowa is right that you just had the syntax for a relative path literal a little wrong; need that leading ./ in there.
But, the way you have that written, anywhere you would use that swaConfig variable, it’s very likely equivalent to just putting ./config/greetd_swa.conf directly anyway. Whenever you use a path literal like that, nix will automatically copy the file into the store and substitute the resulting path into the nix evaluation.