Janik-Haag / nm2nix

Converts .nmconnection files into nix code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NetworkManager to Nix

This is a dumb script that converts every .nmconnection file in the current directory to the nix code that is expected by networking.networkmanager.ensureProfiles.profiles which was introduced in NixOS/nixpkgs/#254647 You want to pipe the output of this program through some formatter, for example nixfmt

You probably want to run this script in /etc/NetworkManager/system-connections/ (default profile storage) or /run/NetworkManager/system-connections (temporary profile storage) both folders are only readable by the root user, so you need to execute the script with root permissions aka sudo. For more details about the locations feel free to read redhat's docs

The code gets outputted as one line of nix, so you probably want to run it through a formatter like nixfmt (which the example below does).

If you just want to run the script do:

sudo su -c "cd /etc/NetworkManager/system-connections && nix --extra-experimental-features 'nix-command flakes' run github:Janik-Haag/nm2nix | nix --extra-experimental-features 'nix-command flakes' run nixpkgs#nixfmt-rfc-style"

About

Converts .nmconnection files into nix code

License:MIT License


Languages

Language:Python 70.1%Language:Nix 29.9%