!wfudwzqQUiJYJnqfSY:nixos.org

NixOS Module System

143 Members
28 Servers

Load older messages


SenderMessageTime
16 Dec 2025
@n4ch7:n3831.netn4ch723hr3r (putting stuff in your name is cringe) joined the room.04:30:36
@n4ch723hr3r:nope.chatMOVED TO n4ch7@n3831.net left the room.04:30:46
19 Dec 2025
@zsuperx:matrix.orgzsuper joined the room.02:37:47
@zsuperx:matrix.orgzsuperim writing a NixOS module for the bore TCP tunnel service. So far I have a working version in my own flake that im using in a few of my servers right now: https://github.com/zSuperx/nix-bore. But I was thinking that this could be nice to have within nixpkgs itself as a builtin module, so I'm going through the contributing guide for modules and editing some of the types and whatnot. These are the questions I have right now: Since the module im writing has options for setting ports, im assuming i should be using type = lib.types.port whenever possible? Likewise, I'm adding a secretFile option so the systemd service reads the secret from a file rather than plaintext. Should I be using type = lib.types.path for this option? I see a few path options in the type definitions file for nixpkgs, so just wanted to double check. When actually evaluating and creating the systemd service file, since the set options values are being processed and interpolated into the serviceConfig.ExecStart bash script, when should I be using lib.escapeShellArg(s)? and last thing (for now) that im unsure about is the use of lib.literalExpression. I see it show up in a few modules I've been reading here and there, but I don't know what the actual use-case is or when it's preferred over a string. sorry if this is a lot of text to send at once. I had originally asked someone via the NixOS discord, and they directed me here. Let me know if I should post this in a different channel or something.02:40:31
@zsuperx:matrix.orgzsuper *

im writing a NixOS module for the bore TCP tunnel service. So far I have a working version in my own flake that im using in a few of my servers right now: https://github.com/zSuperx/nix-bore. But I was thinking that this could be nice to have within nixpkgs itself as a builtin module, so I'm going through the contributing guide for modules and editing some of the types and whatnot. These are the questions I have right now:

Since the module im writing has options for setting ports, im assuming i should be using type = lib.types.port whenever possible?

Likewise, I'm adding a secretFile option so the systemd service reads the secret from a file rather than plaintext. Should I be using type = lib.types.path for this option? or just lib.types.str? I see a few path options in the type definitions file for nixpkgs, so just wanted to double check.

When actually evaluating and creating the systemd service file, since the set options values are being processed and interpolated into the serviceConfig.ExecStart bash script, when should I be using lib.escapeShellArg(s), if at all?

and last thing (for now) that im unsure about is the use of lib.literalExpression. I see it show up in a few modules I've been reading here and there, but I don't know what the actual use-case is or when it's preferred over a string for an option's description.

sorry if this is a lot of text to send at once. I had originally asked someone via the NixOS discord, and they directed me here. Let me know if I should post this in a different channel or something.

02:42:43
@zsuperx:matrix.orgzsuper *

im writing a NixOS module for the bore TCP tunnel service. So far I have a working version in my own flake that im using in a few of my servers right now: https://github.com/zSuperx/nix-bore. But I was thinking that this could be nice to have within nixpkgs itself as a builtin module, so I'm going through the contributing guide for modules and editing some of the types and whatnot. These are the questions I have right now:

Since the module im writing has options for setting ports, im assuming i should be using type = lib.types.port whenever possible?

Likewise, I'm adding a secretFile option so the systemd service reads the secret from a file rather than plaintext. Should I be using type = lib.types.path for this option? or just lib.types.str? I see a few path options in the type definitions file for nixpkgs, so just wanted to double check.

When actually evaluating and creating the systemd service file, since the set options values are being processed and interpolated into the serviceConfig.ExecStart bash script, when should I be using lib.escapeShellArg(s), if at all?

and last thing (for now) that im unsure about is the use of lib.literalExpression. I see it show up in a few modules I've been reading here and there, but I don't know what the actual use-case is or when it's preferred over a string for an option's description.

sorry if this is a lot of text to send at once. I had originally asked someone via the NixOS discord, and they directed me here. Let me know if I should post this in a different channel or something. And thanks in advance!

02:43:26
@hexa:lossy.networkhexayes, lib.types.port02:49:24
@hexa:lossy.networkhexafor secrets either lib.types.str, because paths could leak into the store, which is world-readable02:49:50
@hexa:lossy.networkhexa alternatively lib.types.pathWith { inStore = false; } 02:50:07
@hexa:lossy.networkhexabut that might make it hard to test02:50:11
@hexa:lossy.networkhexaescapeShellArgs makes sense when there is user input, that needs escaping02:51:18
@hexa:lossy.networkhexathere is also utils.escapeSystemdExecArgs, which is more suited to systemd units02:51:35
@zsuperx:matrix.orgzsuperokay, i have the raw secret option as str, but you're saying make the secretFile option also just a str?02:51:36
@hexa:lossy.networkhexathe nixos config being built might also end up in the nix store, so plain text secret string options are also a bad idea02:52:27
@hexa:lossy.networkhexaI would also recommend to construct ExecStart from a list for proper tokenization02:52:47
@hexa:lossy.networkhexaso escapeShellArgs or escapeSystemdExecArgs, the plural versions02:53:00
@hexa:lossy.networkhexa literalExpression gets used in e.g. defaultText or exampleText to render the string as nix code without evaluating it 02:53:37
@hexa:lossy.networkhexait gets rendered in place of the actual default or example value02:53:49
@hexa:lossy.networkhexawhich might be a reference to something else02:54:06
@zsuperx:matrix.orgzsuper regarding this, my plan is to create a raw secret option as well as a secretFile option (where the latter takes precedence), just to keep options open for users. But I'll use a regular str for both to avoid secret paths getting copied to the store. 02:57:58
@hexa:lossy.networkhexathe raw secret string option is a bad idea02:58:32
@zsuperx:matrix.orgzsuperbut it's fine if used with sopsnix right?02:58:59
@hexa:lossy.networkhexathey pass files02:59:24
@hexa:lossy.networkhexanot strings02:59:25
@zsuperx:matrix.orgzsuperi have not yet setup/learned how sopsnix works, so I am unsure tbh02:59:31
@hexa:lossy.networkhexaagenix/sopsnix encrypt and pass files02:59:42
@zsuperx:matrix.orgzsuperi see, okay thanks02:59:57
@zsuperx:matrix.orgzsuperthen ill re-evaluate how i go about this. but thanks for the advice regardless!03:00:17
@bonjour:bonjour.zone班泽 💕 joined the room.08:08:40
@bonjour:bonjour.zone班泽 💕 left the room.08:25:17

There are no newer messages yet.


Back to Room ListRoom Version: 10