[Nix-dev] Insert a ${} literally

Eike eike at eknet.org
Wed Nov 19 10:00:15 CET 2014


Hi all,

Sorry, if I'm missing something obvious here, but I can't figure it out.
I'm trying to make exim service work and I followed a pattern I saw on
many other nix files:

    let
      cfg = config.services.exim;
      configfile = ''
        the config file
        with ${cfg.bla}
        things in it
      '';

    ...

Exim has its own string expansion mechanism and it uses the same
dollar-curly syntax as everyone else. And I cannot make it happen to
insert the following string literally:

    ${lookup{$local_part}lsearch{/var/exim-4.84/etc/aliases}}

I tried many things like escaping using a backslash or more desparate
things like trying to concatenate a "$" to the rest. But I failed so
far. I'm creating this file in the preStart hook of jobs.exim using cat
and redirection:

    cat > /var/exim-4.84/etc/exim.conf << EOF
    ${eximConfig}
    EOF

There probably is a better way to create this file?

The closest I could achieve is this:

    "{lookup{\\$local_part}lsearch{/var/exim-4.84/etc/aliases}}" or
    ''{lookup{\$local_part}lsearch{/var/exim-4.84/etc/aliases}}''

There still needs to be a "$" in front of that :)

Thanks for your time and help
Eike


More information about the nix-dev mailing list