Skip to content

Latest commit

 

History

History
13 lines (9 loc) · 1.35 KB

README.md

File metadata and controls

13 lines (9 loc) · 1.35 KB

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"