Showcase: nixpkgs network library

Hi, all.

I want you to share what I’m currently doing with my mentor @Janik as part of the Google Summer of Code.
Our task is to add a network library to the nixpkgs.
We decided to start with IPv6 because IPv4 is already partialy implemented already (there is an open PR). Right now there are two PRs:

I’d like to invite you to re/view these RPs and give your feedback before it will be merged into master. Especially I want you to share whether the API is easy and understandable to use. Because if we mess up with it on the beginning it will be hard to fix later.

From my point of view I expect network library API to consist of a single function fromString that takes ipv6 string and returns attrset (IPv6 type that I’ll add soon) with different data: firstAddress, nextAddress, etc.

Cheers.

10 Likes

Thanks for your efforts here! I think this will help me a lot to ensure more correctness and help to remove some hardcoded values in my nixos-based router and vpn configurations.

Is there any plan to leverage this to create some type definitions for use in module options, or maybe at least expose some validation functions (e.g. something like lib.network.ipv6.isValidAddress :: String -> Bool) so that custom types could be defined more easily?

It would be nice for some of my custom modules (and eventually for refactoring modules in nixpkgs too probably) to have something like lib.types.network.ipv6.address and lib.types.network.ipv6.addressWithSubnetMask (these names aren’t suggestions, just wanted clear examples).

Totally understandable if these are out of scope, or complicate the API too much, just thinking out loud.

Thanks for the feedback.

Defining types for use in modules is actually my next thing I’m going to implement. There were also plans to refactor one/two existing modules with this API to serve as an example for future users.

I’m also wondering what you would prefer two types ipv6.address and ipv6.addressCidr or just one type like ipv6.address which optionally takes the length of the subnet prefix and defaults to 128 (it works like this now, but we can change it until it is used)?

Thinking about it more, I think a ipv6.addressCidr type probably isn’t needed, since a module could just accept a ipv6.address and use fromString to get the address out regardless of the format.

2 Likes