igel
September 11, 2022, 11:43am
1
device_P340 = "P340" ;
imports =
[
./config/z_device_P340.nix # works but isn't proper as it contains a variable as fix string
"./config/z_device_${device}.nix" # issue
];
error: string './config/z_device_P340.nix' doesn't represent an absolute path
builtins.asPath does not change it
What is the current correct way in nixos?
TLATER
September 11, 2022, 11:56am
2
device_P340 = "P340" ;
imports =
[
./config/z_device_${device}.nix
];
Probably. Imports expect actual paths, not strings. No, paths are just resolved to be absolute at runtime. Interpolation works on those too, afaik.
Edit: yes, and it’s apparently called anti-quotation: Data Types
NobbZ
September 11, 2022, 12:03pm
3
Path interpolation is a recent thing.
If path interpolation is not available in OPs version, then building a path programatically is like ./config + "/z_device_${device}.nix"
1 Like
igel
September 11, 2022, 12:22pm
4
- system: `"x86_64-linux"`
- host os: `Linux 5.15.64, NixOS, 22.05 (Quokka), 22.05.2992.45b56b5321a`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.8.1`
- channels(root): `"home-manager-22.05.tar.gz, nixos-22.05"`
- channels(a): `""`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
building Nix...
error: syntax error, unexpected '+'
igel
September 11, 2022, 1:32pm
6
NobbZ:
parenthesis
thanks, looks to work as well