Skip to content

Commit

Permalink
nixos/networkd: add CAN options
Browse files Browse the repository at this point in the history
  • Loading branch information
apfelkuchen6 committed Mar 16, 2023
1 parent a7724b8 commit df14953
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions nixos/modules/system/boot/networkd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,65 @@ let
"MUDURL"
])
];

sectionCAN = checkUnitConfig "CAN" [
(assertOnlyFields [
"BitRate"
"SamplePoint"
"TimeQuantaNSec"
"PropagationSegment"
"PhaseBufferSegment1"
"PhaseBufferSegment2"
"SyncJumpWidth"
"DataBitRate"
"DataSamplePoint"
"DataTimeQuantaNSec"
"DataPropagationSegment"
"DataPhaseBufferSegment1"
"DataPhaseBufferSegment2"
"DataSyncJumpWidth"
"FDMode"
"FDNonISO"
"RestartSec"
"Termination"
"TripleSampling"
"BusErrorReporting"
"ListenOnly"
"Loopback"
"OneShot"
"PresumeAck"
"ClassicDataLengthCode"
])
(assertInt "TimeQuantaNSec" )
(assertRange "TimeQuantaNSec" 0 4294967295 )
(assertInt "PropagationSegment" )
(assertRange "PropagationSegment" 0 4294967295 )
(assertInt "PhaseBufferSegment1" )
(assertRange "PhaseBufferSegment1" 0 4294967295 )
(assertInt "PhaseBufferSegment2" )
(assertRange "PhaseBufferSegment2" 0 4294967295 )
(assertInt "SyncJumpWidth" )
(assertRange "SyncJumpWidth" 0 4294967295 )
(assertInt "DataTimeQuantaNSec" )
(assertRange "DataTimeQuantaNSec" 0 4294967295 )
(assertInt "DataPropagationSegment" )
(assertRange "DataPropagationSegment" 0 4294967295 )
(assertInt "DataPhaseBufferSegment1" )
(assertRange "DataPhaseBufferSegment1" 0 4294967295 )
(assertInt "DataPhaseBufferSegment2" )
(assertRange "DataPhaseBufferSegment2" 0 4294967295 )
(assertInt "DataSyncJumpWidth" )
(assertRange "DataSyncJumpWidth" 0 4294967295 )
(assertValueOneOf "FDMode" boolValues)
(assertValueOneOf "FDNonISO" boolValues)
(assertValueOneOf "TripleSampling" boolValues)
(assertValueOneOf "BusErrorReporting" boolValues)
(assertValueOneOf "ListenOnly" boolValues)
(assertValueOneOf "Loopback" boolValues)
(assertValueOneOf "OneShot" boolValues)
(assertValueOneOf "PresumeAck" boolValues)
(assertValueOneOf "ClassicDataLengthCode" boolValues)
];
};
};

Expand Down Expand Up @@ -1675,6 +1734,17 @@ let
'';
};

canConfig = mkOption {
default = {};
example = { };
type = types.addCheck (types.attrsOf unitOption) check.network.sectionCAN;
description = lib.mdDoc ''
Each attribute in this set specifies an option in the
`[CAN]` section of the unit. See
{manpage}`systemd.network(5)` for details.
'';
};

name = mkOption {
type = types.nullOr types.str;
default = null;
Expand Down Expand Up @@ -2098,6 +2168,10 @@ let
[LLDP]
${attrsToSection def.lldpConfig}
''
+ optionalString (def.canConfig != { }) ''
[CAN]
${attrsToSection def.canConfig}
''
+ def.extraConfig;
};

Expand Down

0 comments on commit df14953

Please sign in to comment.