Configuring nix package by using nixos modules on non-NixOs system

I am very new to nix.

I want to build nginx, then apply some settings, and then copy the whole runtime closure to remote machine. What is an idiomatic way to do this?

I run arch Linux and installed Nix package manager.

So, I installed nginx using nix. But then how do I apply some configuration to it?

I figured out that I can create my own derivation for this (or maybe create an overlay?). The derivation would depend on upstream nginx package and then simply put some related text inside nginx.conf file. Is it a good approach?

Then I found that NixOS has a very versatile module system. I think it would be very convenient to configure the package as described in the wiki Nginx - NixOS Wiki . So is there a way to use NixOS modules on a non-NixOS system?

A talk by Rickard Nilsson suggests that this is possible. Though there aren’t much details about it, except of mentioning nixpkgs.lib.evalModules function.

Thank you!

4 Likes