Nix + autofs on non-nixos

I have followed the instructions here Introduction and have installed multi user nix on redhat. I’m new to nix and have been doing some reading/experimenting to understand it better.

[root@rh1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.5 (Maipo)
[root@rh1 ~]# nix --version
nix (Nix) 2.1.1

I wonder if it’s possible to use autofs through nix without using nixos. I want to be able to manage the autofs configuration (and binary) through nix and be able to rollback to an old version if a change doesn’t work. Is this possible without using nixos? If it is possible, can somebody help point me to what I can read about or some example to follow to get this working? I’m confused if I need to create my own package or derivation that combines autofs + the configuration I want for it, or is this something that would be handled by a nix-profile, or something else entirely.

I have followed through the first 10 nix pill blogs and they’ve been very helpful. I will continue them but just wanted to get some immediate feedback on if I’m thinking about nix the right way.

Autofs consists of the kernel module and the userspace daemon. You could build the userspace daemon from nixpkgs even without NixOS, but the kernel module would have to come from your own distribution. It may or may not be compatible. I would assume they could be made to work together, if the kernel module exists.

You would have to install and customize the configuration file and the init script manually. I don’t know what kind of init system Red Hat uses.

You can check if you have the kernel module installed: modinfo autofs4.

If you are not on NixOS you can only use packages from nixpkgs. You will be not able to use the modules provided by NixOS in your distribution for configuration. You can still rollback package upgrades. There are projects like GitHub - nix-community/home-manager: Manage a user environment using Nix [maintainer=@rycee] and that provide modules for user profiles and other operating systems.