1
0
mirror of https://github.com/kmein/niveum synced 2026-03-17 02:31:09 +01:00

chore: format with alejandra

This commit is contained in:
2022-03-10 21:52:12 +01:00
parent 13727abfd6
commit d37e90cb97
159 changed files with 4239 additions and 3405 deletions

View File

@@ -1,50 +1,69 @@
# https://github.com/jmackie/nixos-networkmanager-profiles/
{ lib, config, ... }:
with lib;
let
{
lib,
config,
...
}:
with lib; let
nm = config.networking.networkmanager;
mkProfile = profileAttrs:
if !(isAttrs profileAttrs) then
throw "error 1"
if !(isAttrs profileAttrs)
then throw "error 1"
else {
enable = true;
mode = "0400"; # readonly (user)
text = (foldlAttrs (accum:
{ name, value }: ''
text =
(foldlAttrs (accum: {
name,
value,
}: ''
${accum}
[${name}] ${mkProfileEntry value}'')
"# Generated by nixos-networkmanager-profiles" profileAttrs) + "\n";
"# Generated by nixos-networkmanager-profiles"
profileAttrs)
+ "\n";
};
mkProfileEntry = entryAttrs:
if !(isAttrs entryAttrs) then
throw "error 2"
if !(isAttrs entryAttrs)
then throw "error 2"
else
foldlAttrs (accum:
{ name, value }: ''
${accum}
${name}=${toString value}'') "" entryAttrs;
foldlAttrs (accum: {
name,
value,
}: ''
${accum}
${name}=${toString value}'') ""
entryAttrs;
foldlAttrs = op: nul: attrs:
foldl (accum: { fst, snd }: op accum (nameValuePair fst snd)) nul
foldl (accum: {
fst,
snd,
}:
op accum (nameValuePair fst snd))
nul
(lists.zipLists (attrNames attrs) (attrValues attrs));
attrLength = attrs: length (attrValues attrs);
in {
options.networking.networkmanager.profiles = mkOption {
type = types.attrs;
default = { };
default = {};
};
config = mkIf (attrLength nm.profiles > 0) {
environment.etc = (foldlAttrs (accum:
{ name, value }:
accum // {
environment.etc = foldlAttrs (accum: {
name,
value,
}:
accum
// {
"NetworkManager/system-connections/${name}.nmconnection" =
mkProfile value;
}) { } nm.profiles);
}) {}
nm.profiles;
};
}