0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Merge staging-next into staging

This commit is contained in:
github-actions[bot] 2024-08-29 00:13:35 +00:00 committed by GitHub
commit 3a4a3e98a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 5858 additions and 3435 deletions

View file

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.postfix; cfg = config.services.postfix;
@ -17,32 +14,32 @@ let
haveLocalRecipients = cfg.localRecipients != null; haveLocalRecipients = cfg.localRecipients != null;
clientAccess = clientAccess =
optional (cfg.dnsBlacklistOverrides != "") lib.optional (cfg.dnsBlacklistOverrides != "")
"check_client_access hash:/etc/postfix/client_access"; "check_client_access hash:/etc/postfix/client_access";
dnsBl = dnsBl =
optionals (cfg.dnsBlacklists != []) lib.optionals (cfg.dnsBlacklists != [])
(map (s: "reject_rbl_client " + s) cfg.dnsBlacklists); (map (s: "reject_rbl_client " + s) cfg.dnsBlacklists);
clientRestrictions = concatStringsSep ", " (clientAccess ++ dnsBl); clientRestrictions = lib.concatStringsSep ", " (clientAccess ++ dnsBl);
mainCf = let mainCf = let
escape = replaceStrings ["$"] ["$$"]; escape = lib.replaceStrings ["$"] ["$$"];
mkList = items: "\n " + concatStringsSep ",\n " items; mkList = items: "\n " + lib.concatStringsSep ",\n " items;
mkVal = value: mkVal = value:
if isList value then mkList value if lib.isList value then mkList value
else " " + (if value == true then "yes" else " " + (if value == true then "yes"
else if value == false then "no" else if value == false then "no"
else toString value); else toString value);
mkEntry = name: value: "${escape name} =${mkVal value}"; mkEntry = name: value: "${escape name} =${mkVal value}";
in in
concatStringsSep "\n" (mapAttrsToList mkEntry cfg.config) lib.concatStringsSep "\n" (lib.mapAttrsToList mkEntry cfg.config)
+ "\n" + cfg.extraConfig; + "\n" + cfg.extraConfig;
masterCfOptions = { options, config, name, ... }: { masterCfOptions = { options, config, name, ... }: {
options = { options = {
name = mkOption { name = lib.mkOption {
type = types.str; type = lib.types.str;
default = name; default = name;
example = "smtp"; example = "smtp";
description = '' description = ''
@ -50,15 +47,15 @@ let
''; '';
}; };
type = mkOption { type = lib.mkOption {
type = types.enum [ "inet" "unix" "unix-dgram" "fifo" "pass" ]; type = lib.types.enum [ "inet" "unix" "unix-dgram" "fifo" "pass" ];
default = "unix"; default = "unix";
example = "inet"; example = "inet";
description = "The type of the service"; description = "The type of the service";
}; };
private = mkOption { private = lib.mkOption {
type = types.bool; type = lib.types.bool;
example = false; example = false;
description = '' description = ''
Whether the service's sockets and storage directory is restricted to Whether the service's sockets and storage directory is restricted to
@ -67,14 +64,14 @@ let
''; '';
}; };
privileged = mkOption { privileged = lib.mkOption {
type = types.bool; type = lib.types.bool;
example = true; example = true;
description = ""; description = "";
}; };
chroot = mkOption { chroot = lib.mkOption {
type = types.bool; type = lib.types.bool;
example = true; example = true;
description = '' description = ''
Whether the service is chrooted to have only access to the Whether the service is chrooted to have only access to the
@ -83,8 +80,8 @@ let
''; '';
}; };
wakeup = mkOption { wakeup = lib.mkOption {
type = types.int; type = lib.types.int;
example = 60; example = 60;
description = '' description = ''
Automatically wake up the service after the specified number of Automatically wake up the service after the specified number of
@ -93,8 +90,8 @@ let
''; '';
}; };
wakeupUnusedComponent = mkOption { wakeupUnusedComponent = lib.mkOption {
type = types.bool; type = lib.types.bool;
example = false; example = false;
description = '' description = ''
If set to `false` the component will only be woken If set to `false` the component will only be woken
@ -104,8 +101,8 @@ let
''; '';
}; };
maxproc = mkOption { maxproc = lib.mkOption {
type = types.int; type = lib.types.int;
example = 1; example = 1;
description = '' description = ''
The maximum number of processes to spawn for this service. If the The maximum number of processes to spawn for this service. If the
@ -115,8 +112,8 @@ let
''; '';
}; };
command = mkOption { command = lib.mkOption {
type = types.str; type = lib.types.str;
default = name; default = name;
example = "smtpd"; example = "smtpd";
description = '' description = ''
@ -125,8 +122,8 @@ let
''; '';
}; };
args = mkOption { args = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
example = [ "-o" "smtp_helo_timeout=5" ]; example = [ "-o" "smtp_helo_timeout=5" ];
description = '' description = ''
@ -136,8 +133,8 @@ let
''; '';
}; };
rawEntry = mkOption { rawEntry = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
internal = true; internal = true;
description = '' description = ''
@ -148,7 +145,7 @@ let
config.rawEntry = let config.rawEntry = let
mkBool = bool: if bool then "y" else "n"; mkBool = bool: if bool then "y" else "n";
mkArg = arg: "${optionalString (hasPrefix "-" arg) "\n "}${arg}"; mkArg = arg: "${lib.optionalString (lib.hasPrefix "-" arg) "\n "}${arg}";
maybeOption = fun: option: maybeOption = fun: option:
if options.${option}.isDefined then fun config.${option} else "-"; if options.${option}.isDefined then fun config.${option} else "-";
@ -158,7 +155,7 @@ let
wakeupDefined = options.wakeup.isDefined; wakeupDefined = options.wakeup.isDefined;
wakeupUCDefined = options.wakeupUnusedComponent.isDefined; wakeupUCDefined = options.wakeupUnusedComponent.isDefined;
finalValue = toString config.wakeup finalValue = toString config.wakeup
+ optionalString (wakeupUCDefined && !config.wakeupUnusedComponent) "?"; + lib.optionalString (wakeupUCDefined && !config.wakeupUnusedComponent) "?";
in if wakeupDefined then finalValue else "-"; in if wakeupDefined then finalValue else "-";
in [ in [
@ -169,7 +166,7 @@ let
(maybeOption mkBool "chroot") (maybeOption mkBool "chroot")
wakeup wakeup
(maybeOption toString "maxproc") (maybeOption toString "maxproc")
(config.command + " " + concatMapStringsSep " " mkArg config.args) (config.command + " " + lib.concatMapStringsSep " " mkArg config.args)
]; ];
}; };
@ -184,47 +181,47 @@ let
"# " "" "(yes)" "(yes)" "(no)" "(never)" "(100)" "" "" "# " "" "(yes)" "(yes)" "(no)" "(never)" "(100)" "" ""
]; ];
masterCf = mapAttrsToList (const (getAttr "rawEntry")) cfg.masterConfig; masterCf = lib.mapAttrsToList (lib.const (lib.getAttr "rawEntry")) cfg.masterConfig;
# A list of the maximum width of the columns across all lines and labels # A list of the maximum width of the columns across all lines and labels
maxWidths = let maxWidths = let
foldLine = line: acc: let foldLine = line: acc: let
columnLengths = map stringLength line; columnLengths = map lib.stringLength line;
in zipListsWith max acc columnLengths; in lib.zipListsWith lib.max acc columnLengths;
# We need to handle the last column specially here, because it's # We need to handle the last column specially here, because it's
# open-ended (command + args). # open-ended (command + args).
lines = [ labels labelDefaults ] ++ (map (l: init l ++ [""]) masterCf); lines = [ labels labelDefaults ] ++ (map (l: lib.init l ++ [""]) masterCf);
in foldr foldLine (genList (const 0) (length labels)) lines; in lib.foldr foldLine (lib.genList (lib.const 0) (lib.length labels)) lines;
# Pad a string with spaces from the right (opposite of fixedWidthString). # Pad a string with spaces from the right (opposite of fixedWidthString).
pad = width: str: let pad = width: str: let
padWidth = width - stringLength str; padWidth = width - lib.stringLength str;
padding = concatStrings (genList (const " ") padWidth); padding = lib.concatStrings (lib.genList (lib.const " ") padWidth);
in str + optionalString (padWidth > 0) padding; in str + lib.optionalString (padWidth > 0) padding;
# It's + 2 here, because that's the amount of spacing between columns. # It's + 2 here, because that's the amount of spacing between columns.
fullWidth = foldr (width: acc: acc + width + 2) 0 maxWidths; fullWidth = lib.foldr (width: acc: acc + width + 2) 0 maxWidths;
formatLine = line: concatStringsSep " " (zipListsWith pad maxWidths line); formatLine = line: lib.concatStringsSep " " (lib.zipListsWith pad maxWidths line);
formattedLabels = let formattedLabels = let
sep = "# " + concatStrings (genList (const "=") (fullWidth + 5)); sep = "# " + lib.concatStrings (lib.genList (lib.const "=") (fullWidth + 5));
lines = [ sep (formatLine labels) (formatLine labelDefaults) sep ]; lines = [ sep (formatLine labels) (formatLine labelDefaults) sep ];
in concatStringsSep "\n" lines; in lib.concatStringsSep "\n" lines;
in formattedLabels + "\n" + concatMapStringsSep "\n" formatLine masterCf + "\n" + cfg.extraMasterConf; in formattedLabels + "\n" + lib.concatMapStringsSep "\n" formatLine masterCf + "\n" + cfg.extraMasterConf;
headerCheckOptions = { ... }: headerCheckOptions = { ... }:
{ {
options = { options = {
pattern = mkOption { pattern = lib.mkOption {
type = types.str; type = lib.types.str;
default = "/^.*/"; default = "/^.*/";
example = "/^X-Mailer:/"; example = "/^X-Mailer:/";
description = "A regexp pattern matching the header"; description = "A regexp pattern matching the header";
}; };
action = mkOption { action = lib.mkOption {
type = types.str; type = lib.types.str;
default = "DUNNO"; default = "DUNNO";
example = "BCC mail@example.com"; example = "BCC mail@example.com";
description = "The action to be executed when the pattern is matched"; description = "The action to be executed when the pattern is matched";
@ -232,13 +229,13 @@ let
}; };
}; };
headerChecks = concatStringsSep "\n" (map (x: "${x.pattern} ${x.action}") cfg.headerChecks) + cfg.extraHeaderChecks; headerChecks = lib.concatStringsSep "\n" (map (x: "${x.pattern} ${x.action}") cfg.headerChecks) + cfg.extraHeaderChecks;
aliases = let separator = optionalString (cfg.aliasMapType == "hash") ":"; in aliases = let separator = lib.optionalString (cfg.aliasMapType == "hash") ":"; in
optionalString (cfg.postmasterAlias != "") '' lib.optionalString (cfg.postmasterAlias != "") ''
postmaster${separator} ${cfg.postmasterAlias} postmaster${separator} ${cfg.postmasterAlias}
'' ''
+ optionalString (cfg.rootAlias != "") '' + lib.optionalString (cfg.rootAlias != "") ''
root${separator} ${cfg.rootAlias} root${separator} ${cfg.rootAlias}
'' ''
+ cfg.extraAliases + cfg.extraAliases
@ -247,7 +244,7 @@ let
aliasesFile = pkgs.writeText "postfix-aliases" aliases; aliasesFile = pkgs.writeText "postfix-aliases" aliases;
canonicalFile = pkgs.writeText "postfix-canonical" cfg.canonical; canonicalFile = pkgs.writeText "postfix-canonical" cfg.canonical;
virtualFile = pkgs.writeText "postfix-virtual" cfg.virtual; virtualFile = pkgs.writeText "postfix-virtual" cfg.virtual;
localRecipientMapFile = pkgs.writeText "postfix-local-recipient-map" (concatMapStrings (x: x + " ACCEPT\n") cfg.localRecipients); localRecipientMapFile = pkgs.writeText "postfix-local-recipient-map" (lib.concatMapStrings (x: x + " ACCEPT\n") cfg.localRecipients);
checkClientAccessFile = pkgs.writeText "postfix-check-client-access" cfg.dnsBlacklistOverrides; checkClientAccessFile = pkgs.writeText "postfix-check-client-access" cfg.dnsBlacklistOverrides;
mainCfFile = pkgs.writeText "postfix-main.cf" mainCf; mainCfFile = pkgs.writeText "postfix-main.cf" mainCf;
masterCfFile = pkgs.writeText "postfix-master.cf" masterCfContent; masterCfFile = pkgs.writeText "postfix-master.cf" masterCfContent;
@ -264,26 +261,26 @@ in
services.postfix = { services.postfix = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Whether to run the Postfix mail server."; description = "Whether to run the Postfix mail server.";
}; };
enableSmtp = mkOption { enableSmtp = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Whether to enable smtp in master.cf."; description = "Whether to enable smtp in master.cf.";
}; };
enableSubmission = mkOption { enableSubmission = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Whether to enable smtp submission."; description = "Whether to enable smtp submission.";
}; };
enableSubmissions = mkOption { enableSubmissions = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable smtp submission via smtps. Whether to enable smtp submission via smtps.
@ -293,8 +290,8 @@ in
''; '';
}; };
submissionOptions = mkOption { submissionOptions = lib.mkOption {
type = with types; attrsOf str; type = with lib.types; attrsOf str;
default = { default = {
smtpd_tls_security_level = "encrypt"; smtpd_tls_security_level = "encrypt";
smtpd_sasl_auth_enable = "yes"; smtpd_sasl_auth_enable = "yes";
@ -311,8 +308,8 @@ in
description = "Options for the submission config in master.cf"; description = "Options for the submission config in master.cf";
}; };
submissionsOptions = mkOption { submissionsOptions = lib.mkOption {
type = with types; attrsOf str; type = with lib.types; attrsOf str;
default = { default = {
smtpd_sasl_auth_enable = "yes"; smtpd_sasl_auth_enable = "yes";
smtpd_client_restrictions = "permit_sasl_authenticated,reject"; smtpd_client_restrictions = "permit_sasl_authenticated,reject";
@ -334,26 +331,26 @@ in
''; '';
}; };
setSendmail = mkOption { setSendmail = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Whether to set the system sendmail to postfix's."; description = "Whether to set the system sendmail to postfix's.";
}; };
user = mkOption { user = lib.mkOption {
type = types.str; type = lib.types.str;
default = "postfix"; default = "postfix";
description = "What to call the Postfix user (must be used only for postfix)."; description = "What to call the Postfix user (must be used only for postfix).";
}; };
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "postfix"; default = "postfix";
description = "What to call the Postfix group (must be used only for postfix)."; description = "What to call the Postfix group (must be used only for postfix).";
}; };
setgidGroup = mkOption { setgidGroup = lib.mkOption {
type = types.str; type = lib.types.str;
default = "postdrop"; default = "postdrop";
description = '' description = ''
How to call postfix setgid group (for postdrop). Should How to call postfix setgid group (for postdrop). Should
@ -361,8 +358,8 @@ in
''; '';
}; };
networks = mkOption { networks = lib.mkOption {
type = types.nullOr (types.listOf types.str); type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null; default = null;
example = ["192.168.0.1/24"]; example = ["192.168.0.1/24"];
description = '' description = ''
@ -372,8 +369,8 @@ in
''; '';
}; };
networksStyle = mkOption { networksStyle = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = '' description = ''
Name of standard way of trusted network specification to use, Name of standard way of trusted network specification to use,
@ -382,8 +379,8 @@ in
''; '';
}; };
hostname = mkOption { hostname = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = '' description = ''
Hostname to use. Leave blank to use just the hostname of machine. Hostname to use. Leave blank to use just the hostname of machine.
@ -391,24 +388,24 @@ in
''; '';
}; };
domain = mkOption { domain = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = '' description = ''
Domain to use. Leave blank to use hostname minus first component. Domain to use. Leave blank to use hostname minus first component.
''; '';
}; };
origin = mkOption { origin = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = '' description = ''
Origin to use in outgoing e-mail. Leave blank to use hostname. Origin to use in outgoing e-mail. Leave blank to use hostname.
''; '';
}; };
destination = mkOption { destination = lib.mkOption {
type = types.nullOr (types.listOf types.str); type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null; default = null;
example = ["localhost"]; example = ["localhost"];
description = '' description = ''
@ -417,8 +414,8 @@ in
''; '';
}; };
relayDomains = mkOption { relayDomains = lib.mkOption {
type = types.nullOr (types.listOf types.str); type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null; default = null;
example = ["localdomain"]; example = ["localdomain"];
description = '' description = ''
@ -426,32 +423,32 @@ in
''; '';
}; };
relayHost = mkOption { relayHost = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = '' description = ''
Mail relay for outbound mail. Mail relay for outbound mail.
''; '';
}; };
relayPort = mkOption { relayPort = lib.mkOption {
type = types.int; type = lib.types.int;
default = 25; default = 25;
description = '' description = ''
SMTP port for relay mail relay. SMTP port for relay mail relay.
''; '';
}; };
lookupMX = mkOption { lookupMX = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether relay specified is just domain whose MX must be used. Whether relay specified is just domain whose MX must be used.
''; '';
}; };
postmasterAlias = mkOption { postmasterAlias = lib.mkOption {
type = types.str; type = lib.types.str;
default = "root"; default = "root";
description = '' description = ''
Who should receive postmaster e-mail. Multiple values can be added by Who should receive postmaster e-mail. Multiple values can be added by
@ -459,8 +456,8 @@ in
''; '';
}; };
rootAlias = mkOption { rootAlias = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = '' description = ''
Who should receive root e-mail. Blank for no redirection. Who should receive root e-mail. Blank for no redirection.
@ -468,23 +465,23 @@ in
''; '';
}; };
extraAliases = mkOption { extraAliases = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = '' description = ''
Additional entries to put verbatim into aliases file, cf. man-page aliases(8). Additional entries to put verbatim into aliases file, cf. man-page aliases(8).
''; '';
}; };
aliasMapType = mkOption { aliasMapType = lib.mkOption {
type = with types; enum [ "hash" "regexp" "pcre" ]; type = with lib.types; enum [ "hash" "regexp" "pcre" ];
default = "hash"; default = "hash";
example = "regexp"; example = "regexp";
description = "The format the alias map should have. Use regexp if you want to use regular expressions."; description = "The format the alias map should have. Use regexp if you want to use regular expressions.";
}; };
config = mkOption { config = lib.mkOption {
type = with types; attrsOf (oneOf [ bool int str (listOf str) ]); type = with lib.types; attrsOf (oneOf [ bool int str (listOf str) ]);
description = '' description = ''
The main.cf configuration file as key value set. The main.cf configuration file as key value set.
''; '';
@ -494,37 +491,37 @@ in
}; };
}; };
extraConfig = mkOption { extraConfig = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = '' description = ''
Extra lines to be added verbatim to the main.cf configuration file. Extra lines to be added verbatim to the main.cf configuration file.
''; '';
}; };
tlsTrustedAuthorities = mkOption { tlsTrustedAuthorities = lib.mkOption {
type = types.str; type = lib.types.str;
default = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; default = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
defaultText = literalExpression ''"''${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"''; defaultText = lib.literalExpression ''"''${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"'';
description = '' description = ''
File containing trusted certification authorities (CA) to verify certificates of mailservers contacted for mail delivery. This basically sets smtp_tls_CAfile and enables opportunistic tls. Defaults to NixOS trusted certification authorities. File containing trusted certification authorities (CA) to verify certificates of mailservers contacted for mail delivery. This basically sets smtp_tls_CAfile and enables opportunistic tls. Defaults to NixOS trusted certification authorities.
''; '';
}; };
sslCert = mkOption { sslCert = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = "SSL certificate to use."; description = "SSL certificate to use.";
}; };
sslKey = mkOption { sslKey = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = "SSL key to use."; description = "SSL key to use.";
}; };
recipientDelimiter = mkOption { recipientDelimiter = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
example = "+"; example = "+";
description = '' description = ''
@ -532,32 +529,32 @@ in
''; '';
}; };
canonical = mkOption { canonical = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = '' description = ''
Entries for the {manpage}`canonical(5)` table. Entries for the {manpage}`canonical(5)` table.
''; '';
}; };
virtual = mkOption { virtual = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = '' description = ''
Entries for the virtual alias map, cf. man-page virtual(5). Entries for the virtual alias map, cf. man-page virtual(5).
''; '';
}; };
virtualMapType = mkOption { virtualMapType = lib.mkOption {
type = types.enum ["hash" "regexp" "pcre"]; type = lib.types.enum ["hash" "regexp" "pcre"];
default = "hash"; default = "hash";
description = '' description = ''
What type of virtual alias map file to use. Use `"regexp"` for regular expressions. What type of virtual alias map file to use. Use `"regexp"` for regular expressions.
''; '';
}; };
localRecipients = mkOption { localRecipients = lib.mkOption {
type = with types; nullOr (listOf str); type = with lib.types; nullOr (listOf str);
default = null; default = null;
description = '' description = ''
List of accepted local users. Specify a bare username, an List of accepted local users. Specify a bare username, an
@ -569,28 +566,28 @@ in
''; '';
}; };
transport = mkOption { transport = lib.mkOption {
default = ""; default = "";
type = types.lines; type = lib.types.lines;
description = '' description = ''
Entries for the transport map, cf. man-page transport(8). Entries for the transport map, cf. man-page transport(8).
''; '';
}; };
dnsBlacklists = mkOption { dnsBlacklists = lib.mkOption {
default = []; default = [];
type = with types; listOf str; type = with lib.types; listOf str;
description = "dns blacklist servers to use with smtpd_client_restrictions"; description = "dns blacklist servers to use with smtpd_client_restrictions";
}; };
dnsBlacklistOverrides = mkOption { dnsBlacklistOverrides = lib.mkOption {
default = ""; default = "";
type = types.lines; type = lib.types.lines;
description = "contents of check_client_access for overriding dnsBlacklists"; description = "contents of check_client_access for overriding dnsBlacklists";
}; };
masterConfig = mkOption { masterConfig = lib.mkOption {
type = types.attrsOf (types.submodule masterCfOptions); type = lib.types.attrsOf (lib.types.submodule masterCfOptions);
default = {}; default = {};
example = example =
{ submission = { { submission = {
@ -605,48 +602,48 @@ in
''; '';
}; };
extraMasterConf = mkOption { extraMasterConf = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
example = "submission inet n - n - - smtpd"; example = "submission inet n - n - - smtpd";
description = "Extra lines to append to the generated master.cf file."; description = "Extra lines to append to the generated master.cf file.";
}; };
enableHeaderChecks = mkOption { enableHeaderChecks = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
example = true; example = true;
description = "Whether to enable postfix header checks"; description = "Whether to enable postfix header checks";
}; };
headerChecks = mkOption { headerChecks = lib.mkOption {
type = types.listOf (types.submodule headerCheckOptions); type = lib.types.listOf (lib.types.submodule headerCheckOptions);
default = []; default = [];
example = [ { pattern = "/^X-Spam-Flag:/"; action = "REDIRECT spam@example.com"; } ]; example = [ { pattern = "/^X-Spam-Flag:/"; action = "REDIRECT spam@example.com"; } ];
description = "Postfix header checks."; description = "Postfix header checks.";
}; };
extraHeaderChecks = mkOption { extraHeaderChecks = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
example = "/^X-Spam-Flag:/ REDIRECT spam@example.com"; example = "/^X-Spam-Flag:/ REDIRECT spam@example.com";
description = "Extra lines to /etc/postfix/header_checks file."; description = "Extra lines to /etc/postfix/header_checks file.";
}; };
aliasFiles = mkOption { aliasFiles = lib.mkOption {
type = types.attrsOf types.path; type = lib.types.attrsOf lib.types.path;
default = {}; default = {};
description = "Aliases' tables to be compiled and placed into /var/lib/postfix/conf."; description = "Aliases' tables to be compiled and placed into /var/lib/postfix/conf.";
}; };
mapFiles = mkOption { mapFiles = lib.mkOption {
type = types.attrsOf types.path; type = lib.types.attrsOf lib.types.path;
default = {}; default = {};
description = "Maps to be compiled and placed into /var/lib/postfix/conf."; description = "Maps to be compiled and placed into /var/lib/postfix/conf.";
}; };
useSrs = mkOption { useSrs = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Whether to enable sender rewriting scheme"; description = "Whether to enable sender rewriting scheme";
}; };
@ -658,7 +655,7 @@ in
###### implementation ###### implementation
config = mkIf config.services.postfix.enable (mkMerge [ config = lib.mkIf config.services.postfix.enable (lib.mkMerge [
{ {
environment = { environment = {
@ -670,7 +667,7 @@ in
services.pfix-srsd.enable = config.services.postfix.useSrs; services.pfix-srsd.enable = config.services.postfix.useSrs;
services.mail.sendmailSetuidWrapper = mkIf config.services.postfix.setSendmail { services.mail.sendmailSetuidWrapper = lib.mkIf config.services.postfix.setSendmail {
program = "sendmail"; program = "sendmail";
source = "${pkgs.postfix}/bin/sendmail"; source = "${pkgs.postfix}/bin/sendmail";
owner = "root"; owner = "root";
@ -706,7 +703,7 @@ in
setgid = true; setgid = true;
}; };
users.users = optionalAttrs (user == "postfix") users.users = lib.optionalAttrs (user == "postfix")
{ postfix = { { postfix = {
description = "Postfix mail server user"; description = "Postfix mail server user";
uid = config.ids.uids.postfix; uid = config.ids.uids.postfix;
@ -715,10 +712,10 @@ in
}; };
users.groups = users.groups =
optionalAttrs (group == "postfix") lib.optionalAttrs (group == "postfix")
{ ${group}.gid = config.ids.gids.postfix; { ${group}.gid = config.ids.gids.postfix;
} }
// optionalAttrs (setgidGroup == "postdrop") // lib.optionalAttrs (setgidGroup == "postdrop")
{ ${setgidGroup}.gid = config.ids.gids.postdrop; { ${setgidGroup}.gid = config.ids.gids.postdrop;
}; };
@ -745,11 +742,11 @@ in
ln -sf ${mainCfFile} /var/lib/postfix/conf/main.cf ln -sf ${mainCfFile} /var/lib/postfix/conf/main.cf
ln -sf ${masterCfFile} /var/lib/postfix/conf/master.cf ln -sf ${masterCfFile} /var/lib/postfix/conf/master.cf
${concatStringsSep "\n" (mapAttrsToList (to: from: '' ${lib.concatStringsSep "\n" (lib.mapAttrsToList (to: from: ''
ln -sf ${from} /var/lib/postfix/conf/${to} ln -sf ${from} /var/lib/postfix/conf/${to}
${pkgs.postfix}/bin/postalias -o -p /var/lib/postfix/conf/${to} ${pkgs.postfix}/bin/postalias -o -p /var/lib/postfix/conf/${to}
'') cfg.aliasFiles)} '') cfg.aliasFiles)}
${concatStringsSep "\n" (mapAttrsToList (to: from: '' ${lib.concatStringsSep "\n" (lib.mapAttrsToList (to: from: ''
ln -sf ${from} /var/lib/postfix/conf/${to} ln -sf ${from} /var/lib/postfix/conf/${to}
${pkgs.postfix}/bin/postmap /var/lib/postfix/conf/${to} ${pkgs.postfix}/bin/postmap /var/lib/postfix/conf/${to}
'') cfg.mapFiles)} '') cfg.mapFiles)}
@ -795,7 +792,7 @@ in
}; };
}; };
services.postfix.config = (mapAttrs (_: v: mkDefault v) { services.postfix.config = (lib.mapAttrs (_: v: lib.mkDefault v) {
compatibility_level = pkgs.postfix.version; compatibility_level = pkgs.postfix.version;
mail_owner = cfg.user; mail_owner = cfg.user;
default_privs = "nobody"; default_privs = "nobody";
@ -819,39 +816,39 @@ in
mail_spool_directory = "/var/spool/mail/"; mail_spool_directory = "/var/spool/mail/";
setgid_group = cfg.setgidGroup; setgid_group = cfg.setgidGroup;
}) })
// optionalAttrs (cfg.relayHost != "") { relayhost = if cfg.lookupMX // lib.optionalAttrs (cfg.relayHost != "") { relayhost = if cfg.lookupMX
then "${cfg.relayHost}:${toString cfg.relayPort}" then "${cfg.relayHost}:${toString cfg.relayPort}"
else "[${cfg.relayHost}]:${toString cfg.relayPort}"; } else "[${cfg.relayHost}]:${toString cfg.relayPort}"; }
// optionalAttrs (!config.networking.enableIPv6) { inet_protocols = mkDefault "ipv4"; } // lib.optionalAttrs (!config.networking.enableIPv6) { inet_protocols = lib.mkDefault "ipv4"; }
// optionalAttrs (cfg.networks != null) { mynetworks = cfg.networks; } // lib.optionalAttrs (cfg.networks != null) { mynetworks = cfg.networks; }
// optionalAttrs (cfg.networksStyle != "") { mynetworks_style = cfg.networksStyle; } // lib.optionalAttrs (cfg.networksStyle != "") { mynetworks_style = cfg.networksStyle; }
// optionalAttrs (cfg.hostname != "") { myhostname = cfg.hostname; } // lib.optionalAttrs (cfg.hostname != "") { myhostname = cfg.hostname; }
// optionalAttrs (cfg.domain != "") { mydomain = cfg.domain; } // lib.optionalAttrs (cfg.domain != "") { mydomain = cfg.domain; }
// optionalAttrs (cfg.origin != "") { myorigin = cfg.origin; } // lib.optionalAttrs (cfg.origin != "") { myorigin = cfg.origin; }
// optionalAttrs (cfg.destination != null) { mydestination = cfg.destination; } // lib.optionalAttrs (cfg.destination != null) { mydestination = cfg.destination; }
// optionalAttrs (cfg.relayDomains != null) { relay_domains = cfg.relayDomains; } // lib.optionalAttrs (cfg.relayDomains != null) { relay_domains = cfg.relayDomains; }
// optionalAttrs (cfg.recipientDelimiter != "") { recipient_delimiter = cfg.recipientDelimiter; } // lib.optionalAttrs (cfg.recipientDelimiter != "") { recipient_delimiter = cfg.recipientDelimiter; }
// optionalAttrs haveAliases { alias_maps = [ "${cfg.aliasMapType}:/etc/postfix/aliases" ]; } // lib.optionalAttrs haveAliases { alias_maps = [ "${cfg.aliasMapType}:/etc/postfix/aliases" ]; }
// optionalAttrs haveTransport { transport_maps = [ "hash:/etc/postfix/transport" ]; } // lib.optionalAttrs haveTransport { transport_maps = [ "hash:/etc/postfix/transport" ]; }
// optionalAttrs haveVirtual { virtual_alias_maps = [ "${cfg.virtualMapType}:/etc/postfix/virtual" ]; } // lib.optionalAttrs haveVirtual { virtual_alias_maps = [ "${cfg.virtualMapType}:/etc/postfix/virtual" ]; }
// optionalAttrs haveLocalRecipients { local_recipient_maps = [ "hash:/etc/postfix/local_recipients" ] ++ optional haveAliases "$alias_maps"; } // lib.optionalAttrs haveLocalRecipients { local_recipient_maps = [ "hash:/etc/postfix/local_recipients" ] ++ lib.optional haveAliases "$alias_maps"; }
// optionalAttrs (cfg.dnsBlacklists != []) { smtpd_client_restrictions = clientRestrictions; } // lib.optionalAttrs (cfg.dnsBlacklists != []) { smtpd_client_restrictions = clientRestrictions; }
// optionalAttrs cfg.useSrs { // lib.optionalAttrs cfg.useSrs {
sender_canonical_maps = [ "tcp:127.0.0.1:10001" ]; sender_canonical_maps = [ "tcp:127.0.0.1:10001" ];
sender_canonical_classes = [ "envelope_sender" ]; sender_canonical_classes = [ "envelope_sender" ];
recipient_canonical_maps = [ "tcp:127.0.0.1:10002" ]; recipient_canonical_maps = [ "tcp:127.0.0.1:10002" ];
recipient_canonical_classes = [ "envelope_recipient" ]; recipient_canonical_classes = [ "envelope_recipient" ];
} }
// optionalAttrs cfg.enableHeaderChecks { header_checks = [ "regexp:/etc/postfix/header_checks" ]; } // lib.optionalAttrs cfg.enableHeaderChecks { header_checks = [ "regexp:/etc/postfix/header_checks" ]; }
// optionalAttrs (cfg.tlsTrustedAuthorities != "") { // lib.optionalAttrs (cfg.tlsTrustedAuthorities != "") {
smtp_tls_CAfile = cfg.tlsTrustedAuthorities; smtp_tls_CAfile = cfg.tlsTrustedAuthorities;
smtp_tls_security_level = mkDefault "may"; smtp_tls_security_level = lib.mkDefault "may";
} }
// optionalAttrs (cfg.sslCert != "") { // lib.optionalAttrs (cfg.sslCert != "") {
smtp_tls_cert_file = cfg.sslCert; smtp_tls_cert_file = cfg.sslCert;
smtp_tls_key_file = cfg.sslKey; smtp_tls_key_file = cfg.sslKey;
smtp_tls_security_level = mkDefault "may"; smtp_tls_security_level = lib.mkDefault "may";
smtpd_tls_cert_file = cfg.sslCert; smtpd_tls_cert_file = cfg.sslCert;
smtpd_tls_key_file = cfg.sslKey; smtpd_tls_key_file = cfg.sslKey;
@ -931,16 +928,16 @@ in
scache = { scache = {
maxproc = 1; maxproc = 1;
}; };
} // optionalAttrs cfg.enableSubmission { } // lib.optionalAttrs cfg.enableSubmission {
submission = { submission = {
type = "inet"; type = "inet";
private = false; private = false;
command = "smtpd"; command = "smtpd";
args = let args = let
mkKeyVal = opt: val: [ "-o" (opt + "=" + val) ]; mkKeyVal = opt: val: [ "-o" (opt + "=" + val) ];
in concatLists (mapAttrsToList mkKeyVal cfg.submissionOptions); in lib.concatLists (lib.mapAttrsToList mkKeyVal cfg.submissionOptions);
}; };
} // optionalAttrs cfg.enableSmtp { } // lib.optionalAttrs cfg.enableSmtp {
smtp_inet = { smtp_inet = {
name = "smtp"; name = "smtp";
type = "inet"; type = "inet";
@ -952,7 +949,7 @@ in
command = "smtp"; command = "smtp";
args = [ "-o" "smtp_fallback_relay=" ]; args = [ "-o" "smtp_fallback_relay=" ];
}; };
} // optionalAttrs cfg.enableSubmissions { } // lib.optionalAttrs cfg.enableSubmissions {
submissions = { submissions = {
type = "inet"; type = "inet";
private = false; private = false;
@ -964,43 +961,43 @@ in
cfg.submissionsOptions.smtpd_tls_security_level == "may"; cfg.submissionsOptions.smtpd_tls_security_level == "may";
submissionsOptions = cfg.submissionsOptions // { submissionsOptions = cfg.submissionsOptions // {
smtpd_tls_wrappermode = "yes"; smtpd_tls_wrappermode = "yes";
} // optionalAttrs adjustSmtpTlsSecurityLevel { } // lib.optionalAttrs adjustSmtpTlsSecurityLevel {
smtpd_tls_security_level = "encrypt"; smtpd_tls_security_level = "encrypt";
}; };
in concatLists (mapAttrsToList mkKeyVal submissionsOptions); in lib.concatLists (lib.mapAttrsToList mkKeyVal submissionsOptions);
}; };
}; };
} }
(mkIf haveAliases { (lib.mkIf haveAliases {
services.postfix.aliasFiles.aliases = aliasesFile; services.postfix.aliasFiles.aliases = aliasesFile;
}) })
(mkIf haveCanonical { (lib.mkIf haveCanonical {
services.postfix.mapFiles.canonical = canonicalFile; services.postfix.mapFiles.canonical = canonicalFile;
}) })
(mkIf haveTransport { (lib.mkIf haveTransport {
services.postfix.mapFiles.transport = transportFile; services.postfix.mapFiles.transport = transportFile;
}) })
(mkIf haveVirtual { (lib.mkIf haveVirtual {
services.postfix.mapFiles.virtual = virtualFile; services.postfix.mapFiles.virtual = virtualFile;
}) })
(mkIf haveLocalRecipients { (lib.mkIf haveLocalRecipients {
services.postfix.mapFiles.local_recipients = localRecipientMapFile; services.postfix.mapFiles.local_recipients = localRecipientMapFile;
}) })
(mkIf cfg.enableHeaderChecks { (lib.mkIf cfg.enableHeaderChecks {
services.postfix.mapFiles.header_checks = headerChecksFile; services.postfix.mapFiles.header_checks = headerChecksFile;
}) })
(mkIf (cfg.dnsBlacklists != []) { (lib.mkIf (cfg.dnsBlacklists != []) {
services.postfix.mapFiles.client_access = checkClientAccessFile; services.postfix.mapFiles.client_access = checkClientAccessFile;
}) })
]); ]);
imports = [ imports = [
(mkRemovedOptionModule [ "services" "postfix" "sslCACert" ] (lib.mkRemovedOptionModule [ "services" "postfix" "sslCACert" ]
"services.postfix.sslCACert was replaced by services.postfix.tlsTrustedAuthorities. In case you intend that your server should validate requested client certificates use services.postfix.extraConfig.") "services.postfix.sslCACert was replaced by services.postfix.tlsTrustedAuthorities. In case you intend that your server should validate requested client certificates use services.postfix.extraConfig.")
(mkChangedOptionModule [ "services" "postfix" "useDane" ] (lib.mkChangedOptionModule [ "services" "postfix" "useDane" ]
[ "services" "postfix" "config" "smtp_tls_security_level" ] [ "services" "postfix" "config" "smtp_tls_security_level" ]
(config: mkIf config.services.postfix.useDane "dane")) (config: lib.mkIf config.services.postfix.useDane "dane"))
]; ];
} }

View file

@ -1,14 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.sympa; cfg = config.services.sympa;
dataDir = "/var/lib/sympa"; dataDir = "/var/lib/sympa";
user = "sympa"; user = "sympa";
group = "sympa"; group = "sympa";
pkg = pkgs.sympa; pkg = pkgs.sympa;
fqdns = attrNames cfg.domains; fqdns = lib.attrNames cfg.domains;
usingNginx = cfg.web.enable && cfg.web.server == "nginx"; usingNginx = cfg.web.enable && cfg.web.server == "nginx";
mysqlLocal = cfg.database.createLocally && cfg.database.type == "MySQL"; mysqlLocal = cfg.database.createLocally && cfg.database.type == "MySQL";
pgsqlLocal = cfg.database.createLocally && cfg.database.type == "PostgreSQL"; pgsqlLocal = cfg.database.createLocally && cfg.database.type == "PostgreSQL";
@ -42,15 +39,15 @@ let
} // commonServiceConfig; } // commonServiceConfig;
configVal = value: configVal = value:
if isBool value then if lib.isBool value then
if value then "on" else "off" if value then "on" else "off"
else toString value; else toString value;
configGenerator = c: concatStrings (flip mapAttrsToList c (key: val: "${key}\t${configVal val}\n")); configGenerator = c: lib.concatStrings (lib.flip lib.mapAttrsToList c (key: val: "${key}\t${configVal val}\n"));
mainConfig = pkgs.writeText "sympa.conf" (configGenerator cfg.settings); mainConfig = pkgs.writeText "sympa.conf" (configGenerator cfg.settings);
robotConfig = fqdn: domain: pkgs.writeText "${fqdn}-robot.conf" (configGenerator domain.settings); robotConfig = fqdn: domain: pkgs.writeText "${fqdn}-robot.conf" (configGenerator domain.settings);
transport = pkgs.writeText "transport.sympa" (concatStringsSep "\n" (flip map fqdns (domain: '' transport = pkgs.writeText "transport.sympa" (lib.concatStringsSep "\n" (lib.flip map fqdns (domain: ''
${domain} error:User unknown in recipient table ${domain} error:User unknown in recipient table
sympa@${domain} sympa:sympa@${domain} sympa@${domain} sympa:sympa@${domain}
listmaster@${domain} sympa:listmaster@${domain} listmaster@${domain} sympa:listmaster@${domain}
@ -58,7 +55,7 @@ let
abuse-feedback-report@${domain} sympabounce:sympa@${domain} abuse-feedback-report@${domain} sympabounce:sympa@${domain}
''))); '')));
virtual = pkgs.writeText "virtual.sympa" (concatStringsSep "\n" (flip map fqdns (domain: '' virtual = pkgs.writeText "virtual.sympa" (lib.concatStringsSep "\n" (lib.flip map fqdns (domain: ''
sympa-request@${domain} postmaster@localhost sympa-request@${domain} postmaster@localhost
sympa-owner@${domain} postmaster@localhost sympa-owner@${domain} postmaster@localhost
''))); '')));
@ -73,16 +70,16 @@ let
[% list.name %][% return_path_suffix %]@[% list.domain %] sympabounce:[% list.name %]@[% list.domain %] [% list.name %][% return_path_suffix %]@[% list.domain %] sympabounce:[% list.name %]@[% list.domain %]
''; '';
enabledFiles = filterAttrs (n: v: v.enable) cfg.settingsFile; enabledFiles = lib.filterAttrs (n: v: v.enable) cfg.settingsFile;
in in
{ {
###### interface ###### interface
options.services.sympa = with types; { options.services.sympa = with lib.types; {
enable = mkEnableOption "Sympa mailing list manager"; enable = lib.mkEnableOption "Sympa mailing list manager";
lang = mkOption { lang = lib.mkOption {
type = str; type = str;
default = "en_US"; default = "en_US";
example = "cs"; example = "cs";
@ -93,7 +90,7 @@ in
''; '';
}; };
listMasters = mkOption { listMasters = lib.mkOption {
type = listOf str; type = listOf str;
example = [ "postmaster@sympa.example.org" ]; example = [ "postmaster@sympa.example.org" ];
description = '' description = ''
@ -102,7 +99,7 @@ in
''; '';
}; };
mainDomain = mkOption { mainDomain = lib.mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;
example = "lists.example.org"; example = "lists.example.org";
@ -112,10 +109,10 @@ in
''; '';
}; };
domains = mkOption { domains = lib.mkOption {
type = attrsOf (submodule ({ name, config, ... }: { type = attrsOf (submodule ({ name, config, ... }: {
options = { options = {
webHost = mkOption { webHost = lib.mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;
example = "archive.example.org"; example = "archive.example.org";
@ -124,13 +121,13 @@ in
DNS record of type A (or AAAA or CNAME) has to exist with this value. DNS record of type A (or AAAA or CNAME) has to exist with this value.
''; '';
}; };
webLocation = mkOption { webLocation = lib.mkOption {
type = str; type = str;
default = "/"; default = "/";
example = "/sympa"; example = "/sympa";
description = "URL path part of the web interface."; description = "URL path part of the web interface.";
}; };
settings = mkOption { settings = lib.mkOption {
type = attrsOf (oneOf [ str int bool ]); type = attrsOf (oneOf [ str int bool ]);
default = {}; default = {};
example = { example = {
@ -144,8 +141,8 @@ in
}; };
}; };
config.settings = mkIf (cfg.web.enable && config.webHost != null) { config.settings = lib.mkIf (cfg.web.enable && config.webHost != null) {
wwsympa_url = mkDefault "https://${config.webHost}${strings.removeSuffix "/" config.webLocation}"; wwsympa_url = lib.mkDefault "https://${config.webHost}${lib.removeSuffix "/" config.webLocation}";
}; };
})); }));
@ -153,7 +150,7 @@ in
Email domains handled by this instance. There have Email domains handled by this instance. There have
to be MX records for keys of this attribute set. to be MX records for keys of this attribute set.
''; '';
example = literalExpression '' example = lib.literalExpression ''
{ {
"lists.example.org" = { "lists.example.org" = {
webHost = "lists.example.org"; webHost = "lists.example.org";
@ -168,14 +165,14 @@ in
}; };
database = { database = {
type = mkOption { type = lib.mkOption {
type = enum [ "SQLite" "PostgreSQL" "MySQL" ]; type = enum [ "SQLite" "PostgreSQL" "MySQL" ];
default = "SQLite"; default = "SQLite";
example = "MySQL"; example = "MySQL";
description = "Database engine to use."; description = "Database engine to use.";
}; };
host = mkOption { host = lib.mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;
description = '' description = ''
@ -191,29 +188,29 @@ in
''; '';
}; };
port = mkOption { port = lib.mkOption {
type = nullOr port; type = nullOr port;
default = null; default = null;
description = "Database port. Use `null` for default port."; description = "Database port. Use `null` for default port.";
}; };
name = mkOption { name = lib.mkOption {
type = str; type = str;
default = if cfg.database.type == "SQLite" then "${dataDir}/sympa.sqlite" else "sympa"; default = if cfg.database.type == "SQLite" then "${dataDir}/sympa.sqlite" else "sympa";
defaultText = literalExpression ''if database.type == "SQLite" then "${dataDir}/sympa.sqlite" else "sympa"''; defaultText = lib.literalExpression ''if database.type == "SQLite" then "${dataDir}/sympa.sqlite" else "sympa"'';
description = '' description = ''
Database name. When using SQLite this must be an absolute Database name. When using SQLite this must be an absolute
path to the database file. path to the database file.
''; '';
}; };
user = mkOption { user = lib.mkOption {
type = nullOr str; type = nullOr str;
default = user; default = user;
description = "Database user. The system user name is used as a default."; description = "Database user. The system user name is used as a default.";
}; };
passwordFile = mkOption { passwordFile = lib.mkOption {
type = nullOr path; type = nullOr path;
default = null; default = null;
example = "/run/keys/sympa-dbpassword"; example = "/run/keys/sympa-dbpassword";
@ -222,7 +219,7 @@ in
''; '';
}; };
createLocally = mkOption { createLocally = lib.mkOption {
type = bool; type = bool;
default = true; default = true;
description = "Whether to create a local database automatically."; description = "Whether to create a local database automatically.";
@ -230,13 +227,13 @@ in
}; };
web = { web = {
enable = mkOption { enable = lib.mkOption {
type = bool; type = bool;
default = true; default = true;
description = "Whether to enable Sympa web interface."; description = "Whether to enable Sympa web interface.";
}; };
server = mkOption { server = lib.mkOption {
type = enum [ "nginx" "none" ]; type = enum [ "nginx" "none" ];
default = "nginx"; default = "nginx";
description = '' description = ''
@ -246,7 +243,7 @@ in
''; '';
}; };
https = mkOption { https = lib.mkOption {
type = bool; type = bool;
default = true; default = true;
description = '' description = ''
@ -255,7 +252,7 @@ in
''; '';
}; };
fcgiProcs = mkOption { fcgiProcs = lib.mkOption {
type = ints.positive; type = ints.positive;
default = 2; default = 2;
description = "Number of FastCGI processes to fork."; description = "Number of FastCGI processes to fork.";
@ -263,7 +260,7 @@ in
}; };
mta = { mta = {
type = mkOption { type = lib.mkOption {
type = enum [ "postfix" "none" ]; type = enum [ "postfix" "none" ];
default = "postfix"; default = "postfix";
description = '' description = ''
@ -276,10 +273,10 @@ in
}; };
}; };
settings = mkOption { settings = lib.mkOption {
type = attrsOf (oneOf [ str int bool ]); type = attrsOf (oneOf [ str int bool ]);
default = {}; default = {};
example = literalExpression '' example = lib.literalExpression ''
{ {
default_home = "lists"; default_home = "lists";
viewlogs_page_size = 50; viewlogs_page_size = 50;
@ -292,29 +289,29 @@ in
''; '';
}; };
settingsFile = mkOption { settingsFile = lib.mkOption {
type = attrsOf (submodule ({ name, config, ... }: { type = attrsOf (submodule ({ name, config, ... }: {
options = { options = {
enable = mkOption { enable = lib.mkOption {
type = bool; type = bool;
default = true; default = true;
description = "Whether this file should be generated. This option allows specific files to be disabled."; description = "Whether this file should be generated. This option allows specific files to be disabled.";
}; };
text = mkOption { text = lib.mkOption {
default = null; default = null;
type = nullOr lines; type = nullOr lines;
description = "Text of the file."; description = "Text of the file.";
}; };
source = mkOption { source = lib.mkOption {
type = path; type = path;
description = "Path of the source file."; description = "Path of the source file.";
}; };
}; };
config.source = mkIf (config.text != null) (mkDefault (pkgs.writeText "sympa-${baseNameOf name}" config.text)); config.source = lib.mkIf (config.text != null) (lib.mkDefault (pkgs.writeText "sympa-${baseNameOf name}" config.text));
})); }));
default = {}; default = {};
example = literalExpression '' example = lib.literalExpression ''
{ {
"list_data/lists.example.org/help" = { "list_data/lists.example.org/help" = {
text = "subject This list provides help to users"; text = "subject This list provides help to users";
@ -327,11 +324,11 @@ in
###### implementation ###### implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.sympa.settings = (mapAttrs (_: v: mkDefault v) { services.sympa.settings = (lib.mapAttrs (_: v: lib.mkDefault v) {
domain = if cfg.mainDomain != null then cfg.mainDomain else head fqdns; domain = if cfg.mainDomain != null then cfg.mainDomain else lib.head fqdns;
listmaster = concatStringsSep "," cfg.listMasters; listmaster = lib.concatStringsSep "," cfg.listMasters;
lang = cfg.lang; lang = cfg.lang;
home = "${dataDir}/list_data"; home = "${dataDir}/list_data";
@ -344,24 +341,24 @@ in
db_name = cfg.database.name; db_name = cfg.database.name;
db_user = cfg.database.name; db_user = cfg.database.name;
} }
// (optionalAttrs (cfg.database.host != null) { // (lib.optionalAttrs (cfg.database.host != null) {
db_host = cfg.database.host; db_host = cfg.database.host;
}) })
// (optionalAttrs mysqlLocal { // (lib.optionalAttrs mysqlLocal {
db_host = "localhost"; # use unix domain socket db_host = "localhost"; # use unix domain socket
}) })
// (optionalAttrs pgsqlLocal { // (lib.optionalAttrs pgsqlLocal {
db_host = "/run/postgresql"; # use unix domain socket db_host = "/run/postgresql"; # use unix domain socket
}) })
// (optionalAttrs (cfg.database.port != null) { // (lib.optionalAttrs (cfg.database.port != null) {
db_port = cfg.database.port; db_port = cfg.database.port;
}) })
// (optionalAttrs (cfg.mta.type == "postfix") { // (lib.optionalAttrs (cfg.mta.type == "postfix") {
sendmail_aliases = "${dataDir}/sympa_transport"; sendmail_aliases = "${dataDir}/sympa_transport";
aliases_program = "${pkgs.postfix}/bin/postmap"; aliases_program = "${pkgs.postfix}/bin/postmap";
aliases_db_type = "hash"; aliases_db_type = "hash";
}) })
// (optionalAttrs cfg.web.enable { // (lib.optionalAttrs cfg.web.enable {
static_content_path = "${dataDir}/static_content"; static_content_path = "${dataDir}/static_content";
css_path = "${dataDir}/static_content/css"; css_path = "${dataDir}/static_content/css";
pictures_path = "${dataDir}/static_content/pictures"; pictures_path = "${dataDir}/static_content/pictures";
@ -369,12 +366,12 @@ in
})); }));
services.sympa.settingsFile = { services.sympa.settingsFile = {
"virtual.sympa" = mkDefault { source = virtual; }; "virtual.sympa" = lib.mkDefault { source = virtual; };
"transport.sympa" = mkDefault { source = transport; }; "transport.sympa" = lib.mkDefault { source = transport; };
"etc/list_aliases.tt2" = mkDefault { source = listAliases; }; "etc/list_aliases.tt2" = lib.mkDefault { source = listAliases; };
} }
// (flip mapAttrs' cfg.domains (fqdn: domain: // (lib.flip lib.mapAttrs' cfg.domains (fqdn: domain:
nameValuePair "etc/${fqdn}/robot.conf" (mkDefault { source = robotConfig fqdn domain; }))); lib.nameValuePair "etc/${fqdn}/robot.conf" (lib.mkDefault { source = robotConfig fqdn domain; })));
environment = { environment = {
systemPackages = [ pkg ]; systemPackages = [ pkg ];
@ -416,14 +413,14 @@ in
"d /run/sympa 0755 ${user} ${group} - -" "d /run/sympa 0755 ${user} ${group} - -"
] ]
++ (flip concatMap fqdns (fqdn: [ ++ (lib.flip lib.concatMap fqdns (fqdn: [
"d ${dataDir}/etc/${fqdn} 0700 ${user} ${group} - -" "d ${dataDir}/etc/${fqdn} 0700 ${user} ${group} - -"
"d ${dataDir}/list_data/${fqdn} 0700 ${user} ${group} - -" "d ${dataDir}/list_data/${fqdn} 0700 ${user} ${group} - -"
])) ]))
#++ (flip mapAttrsToList enabledFiles (k: v: #++ (lib.flip lib.mapAttrsToList enabledFiles (k: v:
# "L+ ${dataDir}/${k} - - - - ${v.source}" # "L+ ${dataDir}/${k} - - - - ${v.source}"
#)) #))
++ (concatLists (flip mapAttrsToList enabledFiles (k: v: [ ++ (lib.concatLists (lib.flip lib.mapAttrsToList enabledFiles (k: v: [
# sympa doesn't handle symlinks well (e.g. fails to create locks) # sympa doesn't handle symlinks well (e.g. fails to create locks)
# force-copy instead # force-copy instead
"R ${dataDir}/${k} - - - - -" "R ${dataDir}/${k} - - - - -"
@ -443,13 +440,13 @@ in
umask 0077 umask 0077
cp -f ${mainConfig} ${dataDir}/etc/sympa.conf cp -f ${mainConfig} ${dataDir}/etc/sympa.conf
${optionalString (cfg.database.passwordFile != null) '' ${lib.optionalString (cfg.database.passwordFile != null) ''
chmod u+w ${dataDir}/etc/sympa.conf chmod u+w ${dataDir}/etc/sympa.conf
echo -n "db_passwd " >> ${dataDir}/etc/sympa.conf echo -n "db_passwd " >> ${dataDir}/etc/sympa.conf
cat ${cfg.database.passwordFile} >> ${dataDir}/etc/sympa.conf cat ${cfg.database.passwordFile} >> ${dataDir}/etc/sympa.conf
''} ''}
${optionalString (cfg.mta.type == "postfix") '' ${lib.optionalString (cfg.mta.type == "postfix") ''
${pkgs.postfix}/bin/postmap hash:${dataDir}/virtual.sympa ${pkgs.postfix}/bin/postmap hash:${dataDir}/virtual.sympa
${pkgs.postfix}/bin/postmap hash:${dataDir}/transport.sympa ${pkgs.postfix}/bin/postmap hash:${dataDir}/transport.sympa
''} ''}
@ -478,7 +475,7 @@ in
serviceConfig = sympaServiceConfig "task_manager"; serviceConfig = sympaServiceConfig "task_manager";
}; };
systemd.services.wwsympa = mkIf usingNginx { systemd.services.wwsympa = lib.mkIf usingNginx {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "sympa.service" ]; after = [ "sympa.service" ];
serviceConfig = { serviceConfig = {
@ -499,14 +496,14 @@ in
} // commonServiceConfig; } // commonServiceConfig;
}; };
services.nginx.enable = mkIf usingNginx true; services.nginx.enable = lib.mkIf usingNginx true;
services.nginx.virtualHosts = mkIf usingNginx (let services.nginx.virtualHosts = lib.mkIf usingNginx (let
vHosts = unique (remove null (mapAttrsToList (_k: v: v.webHost) cfg.domains)); vHosts = lib.unique (lib.remove null (lib.mapAttrsToList (_k: v: v.webHost) cfg.domains));
hostLocations = host: map (v: v.webLocation) (filter (v: v.webHost == host) (attrValues cfg.domains)); hostLocations = host: map (v: v.webLocation) (lib.filter (v: v.webHost == host) (lib.attrValues cfg.domains));
httpsOpts = optionalAttrs cfg.web.https { forceSSL = mkDefault true; enableACME = mkDefault true; }; httpsOpts = lib.optionalAttrs cfg.web.https { forceSSL = lib.mkDefault true; enableACME = lib.mkDefault true; };
in in
genAttrs vHosts (host: { lib.genAttrs vHosts (host: {
locations = genAttrs (hostLocations host) (loc: { locations = lib.genAttrs (hostLocations host) (loc: {
extraConfig = '' extraConfig = ''
include ${config.services.nginx.package}/conf/fastcgi_params; include ${config.services.nginx.package}/conf/fastcgi_params;
@ -517,7 +514,7 @@ in
}; };
} // httpsOpts)); } // httpsOpts));
services.postfix = mkIf (cfg.mta.type == "postfix") { services.postfix = lib.mkIf (cfg.mta.type == "postfix") {
enable = true; enable = true;
recipientDelimiter = "+"; recipientDelimiter = "+";
config = { config = {
@ -561,9 +558,9 @@ in
}; };
}; };
services.mysql = optionalAttrs mysqlLocal { services.mysql = lib.optionalAttrs mysqlLocal {
enable = true; enable = true;
package = mkDefault pkgs.mariadb; package = lib.mkDefault pkgs.mariadb;
ensureDatabases = [ cfg.database.name ]; ensureDatabases = [ cfg.database.name ];
ensureUsers = [ ensureUsers = [
{ name = cfg.database.user; { name = cfg.database.user;
@ -572,7 +569,7 @@ in
]; ];
}; };
services.postgresql = optionalAttrs pgsqlLocal { services.postgresql = lib.optionalAttrs pgsqlLocal {
enable = true; enable = true;
ensureDatabases = [ cfg.database.name ]; ensureDatabases = [ cfg.database.name ];
ensureUsers = [ ensureUsers = [
@ -584,5 +581,5 @@ in
}; };
meta.maintainers = with maintainers; [ mmilata sorki ]; meta.maintainers = with lib.maintainers; [ mmilata sorki ];
} }

View file

@ -1,32 +1,29 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.autorandr; cfg = config.services.autorandr;
hookType = types.lines; hookType = lib.types.lines;
matrixOf = n: m: elemType: matrixOf = n: m: elemType:
mkOptionType rec { lib.mkOptionType rec {
name = "matrixOf"; name = "matrixOf";
description = description =
"${toString n}×${toString m} matrix of ${elemType.description}s"; "${toString n}×${toString m} matrix of ${elemType.description}s";
check = xss: check = xss:
let listOfSize = l: xs: isList xs && length xs == l; let listOfSize = l: xs: lib.isList xs && lib.length xs == l;
in listOfSize n xss in listOfSize n xss
&& all (xs: listOfSize m xs && all elemType.check xs) xss; && lib.all (xs: listOfSize m xs && lib.all elemType.check xs) xss;
merge = mergeOneOption; merge = lib.mergeOneOption;
getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "*" "*" ]); getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "*" "*" ]);
getSubModules = elemType.getSubModules; getSubModules = elemType.getSubModules;
substSubModules = mod: matrixOf n m (elemType.substSubModules mod); substSubModules = mod: matrixOf n m (elemType.substSubModules mod);
functor = (defaultFunctor name) // { wrapped = elemType; }; functor = (lib.defaultFunctor name) // { wrapped = elemType; };
}; };
profileModule = types.submodule { profileModule = lib.types.submodule {
options = { options = {
fingerprint = mkOption { fingerprint = lib.mkOption {
type = types.attrsOf types.str; type = lib.types.attrsOf lib.types.str;
description = '' description = ''
Output name to EDID mapping. Output name to EDID mapping.
Use `autorandr --fingerprint` to get current setup values. Use `autorandr --fingerprint` to get current setup values.
@ -34,13 +31,13 @@ let
default = { }; default = { };
}; };
config = mkOption { config = lib.mkOption {
type = types.attrsOf configModule; type = lib.types.attrsOf configModule;
description = "Per output profile configuration."; description = "Per output profile configuration.";
default = { }; default = { };
}; };
hooks = mkOption { hooks = lib.mkOption {
type = hooksModule; type = hooksModule;
description = "Profile hook scripts."; description = "Profile hook scripts.";
default = { }; default = { };
@ -48,66 +45,66 @@ let
}; };
}; };
configModule = types.submodule { configModule = lib.types.submodule {
options = { options = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
description = "Whether to enable the output."; description = "Whether to enable the output.";
default = true; default = true;
}; };
crtc = mkOption { crtc = lib.mkOption {
type = types.nullOr types.ints.unsigned; type = lib.types.nullOr lib.types.ints.unsigned;
description = "Output video display controller."; description = "Output video display controller.";
default = null; default = null;
example = 0; example = 0;
}; };
primary = mkOption { primary = lib.mkOption {
type = types.bool; type = lib.types.bool;
description = "Whether output should be marked as primary"; description = "Whether output should be marked as primary";
default = false; default = false;
}; };
position = mkOption { position = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Output position"; description = "Output position";
default = ""; default = "";
example = "5760x0"; example = "5760x0";
}; };
mode = mkOption { mode = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Output resolution."; description = "Output resolution.";
default = ""; default = "";
example = "3840x2160"; example = "3840x2160";
}; };
rate = mkOption { rate = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Output framerate."; description = "Output framerate.";
default = ""; default = "";
example = "60.00"; example = "60.00";
}; };
gamma = mkOption { gamma = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Output gamma configuration."; description = "Output gamma configuration.";
default = ""; default = "";
example = "1.0:0.909:0.833"; example = "1.0:0.909:0.833";
}; };
rotate = mkOption { rotate = lib.mkOption {
type = types.nullOr (types.enum [ "normal" "left" "right" "inverted" ]); type = lib.types.nullOr (lib.types.enum [ "normal" "left" "right" "inverted" ]);
description = "Output rotate configuration."; description = "Output rotate configuration.";
default = null; default = null;
example = "left"; example = "left";
}; };
transform = mkOption { transform = lib.mkOption {
type = types.nullOr (matrixOf 3 3 types.float); type = lib.types.nullOr (matrixOf 3 3 lib.types.float);
default = null; default = null;
example = literalExpression '' example = lib.literalExpression ''
[ [
[ 0.6 0.0 0.0 ] [ 0.6 0.0 0.0 ]
[ 0.0 0.6 0.0 ] [ 0.0 0.6 0.0 ]
@ -121,30 +118,30 @@ let
''; '';
}; };
dpi = mkOption { dpi = lib.mkOption {
type = types.nullOr types.ints.positive; type = lib.types.nullOr lib.types.ints.positive;
description = "Output DPI configuration."; description = "Output DPI configuration.";
default = null; default = null;
example = 96; example = 96;
}; };
scale = mkOption { scale = lib.mkOption {
type = types.nullOr (types.submodule { type = lib.types.nullOr (lib.types.submodule {
options = { options = {
method = mkOption { method = lib.mkOption {
type = types.enum [ "factor" "pixel" ]; type = lib.types.enum [ "factor" "pixel" ];
description = "Output scaling method."; description = "Output scaling method.";
default = "factor"; default = "factor";
example = "pixel"; example = "pixel";
}; };
x = mkOption { x = lib.mkOption {
type = types.either types.float types.ints.positive; type = lib.types.either lib.types.float lib.types.ints.positive;
description = "Horizontal scaling factor/pixels."; description = "Horizontal scaling factor/pixels.";
}; };
y = mkOption { y = lib.mkOption {
type = types.either types.float types.ints.positive; type = lib.types.either lib.types.float lib.types.ints.positive;
description = "Vertical scaling factor/pixels."; description = "Vertical scaling factor/pixels.";
}; };
}; };
@ -164,7 +161,7 @@ let
exclusive. exclusive.
''; '';
default = null; default = null;
example = literalExpression '' example = lib.literalExpression ''
{ {
x = 1.25; x = 1.25;
y = 1.25; y = 1.25;
@ -174,22 +171,22 @@ let
}; };
}; };
hooksModule = types.submodule { hooksModule = lib.types.submodule {
options = { options = {
postswitch = mkOption { postswitch = lib.mkOption {
type = types.attrsOf hookType; type = lib.types.attrsOf hookType;
description = "Postswitch hook executed after mode switch."; description = "Postswitch hook executed after mode switch.";
default = { }; default = { };
}; };
preswitch = mkOption { preswitch = lib.mkOption {
type = types.attrsOf hookType; type = lib.types.attrsOf hookType;
description = "Preswitch hook executed before mode switch."; description = "Preswitch hook executed before mode switch.";
default = { }; default = { };
}; };
predetect = mkOption { predetect = lib.mkOption {
type = types.attrsOf hookType; type = lib.types.attrsOf hookType;
description = '' description = ''
Predetect hook executed before autorandr attempts to run xrandr. Predetect hook executed before autorandr attempts to run xrandr.
''; '';
@ -199,37 +196,37 @@ let
}; };
hookToFile = folder: name: hook: hookToFile = folder: name: hook:
nameValuePair "xdg/autorandr/${folder}/${name}" { lib.nameValuePair "xdg/autorandr/${folder}/${name}" {
source = "${pkgs.writeShellScriptBin "hook" hook}/bin/hook"; source = "${pkgs.writeShellScriptBin "hook" hook}/bin/hook";
}; };
profileToFiles = name: profile: profileToFiles = name: profile:
with profile; with profile;
mkMerge ([ lib.mkMerge ([
{ {
"xdg/autorandr/${name}/setup".text = concatStringsSep "\n" "xdg/autorandr/${name}/setup".text = lib.concatStringsSep "\n"
(mapAttrsToList fingerprintToString fingerprint); (lib.mapAttrsToList fingerprintToString fingerprint);
"xdg/autorandr/${name}/config".text = "xdg/autorandr/${name}/config".text =
concatStringsSep "\n" (mapAttrsToList configToString profile.config); lib.concatStringsSep "\n" (lib.mapAttrsToList configToString profile.config);
} }
(mapAttrs' (hookToFile "${name}/postswitch.d") hooks.postswitch) (lib.mapAttrs' (hookToFile "${name}/postswitch.d") hooks.postswitch)
(mapAttrs' (hookToFile "${name}/preswitch.d") hooks.preswitch) (lib.mapAttrs' (hookToFile "${name}/preswitch.d") hooks.preswitch)
(mapAttrs' (hookToFile "${name}/predetect.d") hooks.predetect) (lib.mapAttrs' (hookToFile "${name}/predetect.d") hooks.predetect)
]); ]);
fingerprintToString = name: edid: "${name} ${edid}"; fingerprintToString = name: edid: "${name} ${edid}";
configToString = name: config: configToString = name: config:
if config.enable then if config.enable then
concatStringsSep "\n" ([ "output ${name}" ] lib.concatStringsSep "\n" ([ "output ${name}" ]
++ optional (config.position != "") "pos ${config.position}" ++ lib.optional (config.position != "") "pos ${config.position}"
++ optional (config.crtc != null) "crtc ${toString config.crtc}" ++ lib.optional (config.crtc != null) "crtc ${toString config.crtc}"
++ optional config.primary "primary" ++ lib.optional config.primary "primary"
++ optional (config.dpi != null) "dpi ${toString config.dpi}" ++ lib.optional (config.dpi != null) "dpi ${toString config.dpi}"
++ optional (config.gamma != "") "gamma ${config.gamma}" ++ lib.optional (config.gamma != "") "gamma ${config.gamma}"
++ optional (config.mode != "") "mode ${config.mode}" ++ lib.optional (config.mode != "") "mode ${config.mode}"
++ optional (config.rate != "") "rate ${config.rate}" ++ lib.optional (config.rate != "") "rate ${config.rate}"
++ optional (config.rotate != null) "rotate ${config.rotate}" ++ lib.optional (config.rotate != null) "rotate ${config.rotate}"
++ optional (config.transform != null) ("transform " ++ lib.optional (config.transform != null) ("transform "
+ concatMapStringsSep "," toString (flatten config.transform)) + lib.concatMapStringsSep "," toString (lib.flatten config.transform))
++ optional (config.scale != null) ++ lib.optional (config.scale != null)
((if config.scale.method == "factor" then "scale" else "scale-from") ((if config.scale.method == "factor" then "scale" else "scale-from")
+ " ${toString config.scale.x}x${toString config.scale.y}")) + " ${toString config.scale.x}x${toString config.scale.y}"))
else '' else ''
@ -242,11 +239,11 @@ in {
options = { options = {
services.autorandr = { services.autorandr = {
enable = mkEnableOption "handling of hotplug and sleep events by autorandr"; enable = lib.mkEnableOption "handling of hotplug and sleep events by autorandr";
defaultTarget = mkOption { defaultTarget = lib.mkOption {
default = "default"; default = "default";
type = types.str; type = lib.types.str;
description = '' description = ''
Fallback if no monitor layout can be detected. See the docs Fallback if no monitor layout can be detected. See the docs
(https://github.com/phillipberndt/autorandr/blob/v1.0/README.md#how-to-use) (https://github.com/phillipberndt/autorandr/blob/v1.0/README.md#how-to-use)
@ -254,23 +251,23 @@ in {
''; '';
}; };
ignoreLid = mkOption { ignoreLid = lib.mkOption {
default = false; default = false;
type = types.bool; type = lib.types.bool;
description = "Treat outputs as connected even if their lids are closed"; description = "Treat outputs as connected even if their lids are closed";
}; };
matchEdid = mkOption { matchEdid = lib.mkOption {
default = false; default = false;
type = types.bool; type = lib.types.bool;
description = "Match displays based on edid instead of name"; description = "Match displays based on edid instead of name";
}; };
hooks = mkOption { hooks = lib.mkOption {
type = hooksModule; type = hooksModule;
description = "Global hook scripts"; description = "Global hook scripts";
default = { }; default = { };
example = literalExpression '' example = lib.literalExpression ''
{ {
postswitch = { postswitch = {
"notify-i3" = "''${pkgs.i3}/bin/i3-msg restart"; "notify-i3" = "''${pkgs.i3}/bin/i3-msg restart";
@ -296,11 +293,11 @@ in {
} }
''; '';
}; };
profiles = mkOption { profiles = lib.mkOption {
type = types.attrsOf profileModule; type = lib.types.attrsOf profileModule;
description = "Autorandr profiles specification."; description = "Autorandr profiles specification.";
default = { }; default = { };
example = literalExpression '' example = lib.literalExpression ''
{ {
"work" = { "work" = {
fingerprint = { fingerprint = {
@ -330,17 +327,17 @@ in {
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.udev.packages = [ pkgs.autorandr ]; services.udev.packages = [ pkgs.autorandr ];
environment = { environment = {
systemPackages = [ pkgs.autorandr ]; systemPackages = [ pkgs.autorandr ];
etc = mkMerge ([ etc = lib.mkMerge ([
(mapAttrs' (hookToFile "postswitch.d") cfg.hooks.postswitch) (lib.mapAttrs' (hookToFile "postswitch.d") cfg.hooks.postswitch)
(mapAttrs' (hookToFile "preswitch.d") cfg.hooks.preswitch) (lib.mapAttrs' (hookToFile "preswitch.d") cfg.hooks.preswitch)
(mapAttrs' (hookToFile "predetect.d") cfg.hooks.predetect) (lib.mapAttrs' (hookToFile "predetect.d") cfg.hooks.predetect)
(mkMerge (mapAttrsToList profileToFiles cfg.profiles)) (lib.mkMerge (lib.mapAttrsToList profileToFiles cfg.profiles))
]); ]);
}; };
@ -357,8 +354,8 @@ in {
--batch \ --batch \
--change \ --change \
--default ${cfg.defaultTarget} \ --default ${cfg.defaultTarget} \
${optionalString cfg.ignoreLid "--ignore-lid"} \ ${lib.optionalString cfg.ignoreLid "--ignore-lid"} \
${optionalString cfg.matchEdid "--match-edid"} ${lib.optionalString cfg.matchEdid "--match-edid"}
''; '';
Type = "oneshot"; Type = "oneshot";
RemainAfterExit = false; RemainAfterExit = false;
@ -368,5 +365,5 @@ in {
}; };
meta.maintainers = with maintainers; [ alexnortung ]; meta.maintainers = with lib.maintainers; [ alexnortung ];
} }

View file

@ -1,6 +1,4 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib;
let let
cfg = config.services.gammu-smsd; cfg = config.services.gammu-smsd;
@ -10,7 +8,7 @@ let
Connection = ${cfg.device.connection} Connection = ${cfg.device.connection}
SynchronizeTime = ${if cfg.device.synchronizeTime then "yes" else "no"} SynchronizeTime = ${if cfg.device.synchronizeTime then "yes" else "no"}
LogFormat = ${cfg.log.format} LogFormat = ${cfg.log.format}
${optionalString (cfg.device.pin != null) "PIN = ${cfg.device.pin}"} ${lib.optionalString (cfg.device.pin != null) "PIN = ${cfg.device.pin}"}
${cfg.extraConfig.gammu} ${cfg.extraConfig.gammu}
@ -18,25 +16,25 @@ let
LogFile = ${cfg.log.file} LogFile = ${cfg.log.file}
Service = ${cfg.backend.service} Service = ${cfg.backend.service}
${optionalString (cfg.backend.service == "files") '' ${lib.optionalString (cfg.backend.service == "files") ''
InboxPath = ${cfg.backend.files.inboxPath} InboxPath = ${cfg.backend.files.inboxPath}
OutboxPath = ${cfg.backend.files.outboxPath} OutboxPath = ${cfg.backend.files.outboxPath}
SentSMSPath = ${cfg.backend.files.sentSMSPath} SentSMSPath = ${cfg.backend.files.sentSMSPath}
ErrorSMSPath = ${cfg.backend.files.errorSMSPath} ErrorSMSPath = ${cfg.backend.files.errorSMSPath}
''} ''}
${optionalString (cfg.backend.service == "sql" && cfg.backend.sql.driver == "sqlite") '' ${lib.optionalString (cfg.backend.service == "sql" && cfg.backend.sql.driver == "sqlite") ''
Driver = ${cfg.backend.sql.driver} Driver = ${cfg.backend.sql.driver}
DBDir = ${cfg.backend.sql.database} DBDir = ${cfg.backend.sql.database}
''} ''}
${optionalString (cfg.backend.service == "sql" && cfg.backend.sql.driver == "native_pgsql") ( ${lib.optionalString (cfg.backend.service == "sql" && cfg.backend.sql.driver == "native_pgsql") (
with cfg.backend; '' with cfg.backend; ''
Driver = ${sql.driver} Driver = ${sql.driver}
${optionalString (sql.database!= null) "Database = ${sql.database}"} ${lib.optionalString (sql.database!= null) "Database = ${sql.database}"}
${optionalString (sql.host != null) "Host = ${sql.host}"} ${lib.optionalString (sql.host != null) "Host = ${sql.host}"}
${optionalString (sql.user != null) "User = ${sql.user}"} ${lib.optionalString (sql.user != null) "User = ${sql.user}"}
${optionalString (sql.password != null) "Password = ${sql.password}"} ${lib.optionalString (sql.password != null) "Password = ${sql.password}"}
'')} '')}
${cfg.extraConfig.smsd} ${cfg.extraConfig.smsd}
@ -53,42 +51,42 @@ in {
options = { options = {
services.gammu-smsd = { services.gammu-smsd = {
enable = mkEnableOption "gammu-smsd daemon"; enable = lib.mkEnableOption "gammu-smsd daemon";
user = mkOption { user = lib.mkOption {
type = types.str; type = lib.types.str;
default = "smsd"; default = "smsd";
description = "User that has access to the device"; description = "User that has access to the device";
}; };
device = { device = {
path = mkOption { path = lib.mkOption {
type = types.path; type = lib.types.path;
description = "Device node or address of the phone"; description = "Device node or address of the phone";
example = "/dev/ttyUSB2"; example = "/dev/ttyUSB2";
}; };
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "root"; default = "root";
description = "Owner group of the device"; description = "Owner group of the device";
example = "dialout"; example = "dialout";
}; };
connection = mkOption { connection = lib.mkOption {
type = types.str; type = lib.types.str;
default = "at"; default = "at";
description = "Protocol which will be used to talk to the phone"; description = "Protocol which will be used to talk to the phone";
}; };
synchronizeTime = mkOption { synchronizeTime = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Whether to set time from computer to the phone during starting connection"; description = "Whether to set time from computer to the phone during starting connection";
}; };
pin = mkOption { pin = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = "PIN code for the simcard"; description = "PIN code for the simcard";
}; };
@ -96,14 +94,14 @@ in {
log = { log = {
file = mkOption { file = lib.mkOption {
type = types.str; type = lib.types.str;
default = "syslog"; default = "syslog";
description = "Path to file where information about communication will be stored"; description = "Path to file where information about communication will be stored";
}; };
format = mkOption { format = lib.mkOption {
type = types.enum [ "nothing" "text" "textall" "textalldate" "errors" "errorsdate" "binary" ]; type = lib.types.enum [ "nothing" "text" "textall" "textalldate" "errors" "errorsdate" "binary" ];
default = "errors"; default = "errors";
description = "Determines what will be logged to the LogFile"; description = "Determines what will be logged to the LogFile";
}; };
@ -111,15 +109,15 @@ in {
extraConfig = { extraConfig = {
gammu = mkOption { gammu = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = "Extra config lines to be added into [gammu] section"; description = "Extra config lines to be added into [gammu] section";
}; };
smsd = mkOption { smsd = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = "Extra config lines to be added into [smsd] section"; description = "Extra config lines to be added into [smsd] section";
}; };
@ -127,70 +125,70 @@ in {
backend = { backend = {
service = mkOption { service = lib.mkOption {
type = types.enum [ "null" "files" "sql" ]; type = lib.types.enum [ "null" "files" "sql" ];
default = "null"; default = "null";
description = "Service to use to store sms data."; description = "Service to use to store sms data.";
}; };
files = { files = {
inboxPath = mkOption { inboxPath = lib.mkOption {
type = types.path; type = lib.types.path;
default = "/var/spool/sms/inbox/"; default = "/var/spool/sms/inbox/";
description = "Where the received SMSes are stored"; description = "Where the received SMSes are stored";
}; };
outboxPath = mkOption { outboxPath = lib.mkOption {
type = types.path; type = lib.types.path;
default = "/var/spool/sms/outbox/"; default = "/var/spool/sms/outbox/";
description = "Where SMSes to be sent should be placed"; description = "Where SMSes to be sent should be placed";
}; };
sentSMSPath = mkOption { sentSMSPath = lib.mkOption {
type = types.path; type = lib.types.path;
default = "/var/spool/sms/sent/"; default = "/var/spool/sms/sent/";
description = "Where the transmitted SMSes are placed"; description = "Where the transmitted SMSes are placed";
}; };
errorSMSPath = mkOption { errorSMSPath = lib.mkOption {
type = types.path; type = lib.types.path;
default = "/var/spool/sms/error/"; default = "/var/spool/sms/error/";
description = "Where SMSes with error in transmission is placed"; description = "Where SMSes with error in transmission is placed";
}; };
}; };
sql = { sql = {
driver = mkOption { driver = lib.mkOption {
type = types.enum [ "native_mysql" "native_pgsql" "odbc" "dbi" ]; type = lib.types.enum [ "native_mysql" "native_pgsql" "odbc" "dbi" ];
description = "DB driver to use"; description = "DB driver to use";
}; };
sqlDialect = mkOption { sqlDialect = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = "SQL dialect to use (odbc driver only)"; description = "SQL dialect to use (odbc driver only)";
}; };
database = mkOption { database = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = "Database name to store sms data"; description = "Database name to store sms data";
}; };
host = mkOption { host = lib.mkOption {
type = types.str; type = lib.types.str;
default = "localhost"; default = "localhost";
description = "Database server address"; description = "Database server address";
}; };
user = mkOption { user = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = "User name used for connection to the database"; description = "User name used for connection to the database";
}; };
password = mkOption { password = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = "User password used for connection to the database"; description = "User password used for connection to the database";
}; };
@ -199,7 +197,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
users.users.${cfg.user} = { users.users.${cfg.user} = {
description = "gammu-smsd user"; description = "gammu-smsd user";
isSystemUser = true; isSystemUser = true;
@ -207,7 +205,7 @@ in {
}; };
environment.systemPackages = with cfg.backend; [ gammuPackage ] environment.systemPackages = with cfg.backend; [ gammuPackage ]
++ optionals (service == "sql" && sql.driver == "sqlite") [ pkgs.sqlite ]; ++ lib.optionals (service == "sql" && sql.driver == "sqlite") [ pkgs.sqlite ];
systemd.services.gammu-smsd = { systemd.services.gammu-smsd = {
description = "gammu-smsd daemon"; description = "gammu-smsd daemon";
@ -215,29 +213,29 @@ in {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
wants = with cfg.backend; [ ] wants = with cfg.backend; [ ]
++ optionals (service == "sql" && sql.driver == "native_pgsql") [ "postgresql.service" ]; ++ lib.optionals (service == "sql" && sql.driver == "native_pgsql") [ "postgresql.service" ];
preStart = with cfg.backend; preStart = with cfg.backend;
optionalString (service == "files") (with files; '' lib.optionalString (service == "files") (with files; ''
mkdir -m 755 -p ${inboxPath} ${outboxPath} ${sentSMSPath} ${errorSMSPath} mkdir -m 755 -p ${inboxPath} ${outboxPath} ${sentSMSPath} ${errorSMSPath}
chown ${cfg.user} -R ${inboxPath} chown ${cfg.user} -R ${inboxPath}
chown ${cfg.user} -R ${outboxPath} chown ${cfg.user} -R ${outboxPath}
chown ${cfg.user} -R ${sentSMSPath} chown ${cfg.user} -R ${sentSMSPath}
chown ${cfg.user} -R ${errorSMSPath} chown ${cfg.user} -R ${errorSMSPath}
'') '')
+ optionalString (service == "sql" && sql.driver == "sqlite") '' + lib.optionalString (service == "sql" && sql.driver == "sqlite") ''
cat "${gammuPackage}/${initDBDir}/sqlite.sql" \ cat "${gammuPackage}/${initDBDir}/sqlite.sql" \
| ${pkgs.sqlite.bin}/bin/sqlite3 ${sql.database} | ${pkgs.sqlite.bin}/bin/sqlite3 ${sql.database}
'' ''
+ (let execPsql = extraArgs: concatStringsSep " " [ + (let execPsql = extraArgs: lib.concatStringsSep " " [
(optionalString (sql.password != null) "PGPASSWORD=${sql.password}") (lib.optionalString (sql.password != null) "PGPASSWORD=${sql.password}")
"${config.services.postgresql.package}/bin/psql" "${config.services.postgresql.package}/bin/psql"
(optionalString (sql.host != null) "-h ${sql.host}") (lib.optionalString (sql.host != null) "-h ${sql.host}")
(optionalString (sql.user != null) "-U ${sql.user}") (lib.optionalString (sql.user != null) "-U ${sql.user}")
"$extraArgs" "$extraArgs"
"${sql.database}" "${sql.database}"
]; in optionalString (service == "sql" && sql.driver == "native_pgsql") '' ]; in lib.optionalString (service == "sql" && sql.driver == "native_pgsql") ''
echo '\i '"${gammuPackage}/${initDBDir}/pgsql.sql" | ${execPsql ""} echo '\i '"${gammuPackage}/${initDBDir}/pgsql.sql" | ${execPsql ""}
''); '');

View file

@ -1,7 +1,4 @@
{ config, lib, options, pkgs, ... }: { config, lib, options, pkgs, ... }:
with lib;
let let
gid = config.ids.gids.mediatomb; gid = config.ids.gids.mediatomb;
@ -13,19 +10,19 @@ let
# configuration on media directory # configuration on media directory
mediaDirectory = { mediaDirectory = {
options = { options = {
path = mkOption { path = lib.mkOption {
type = types.str; type = lib.types.str;
description = '' description = ''
Absolute directory path to the media directory to index. Absolute directory path to the media directory to index.
''; '';
}; };
recursive = mkOption { recursive = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Whether the indexation must take place recursively or not."; description = "Whether the indexation must take place recursively or not.";
}; };
hidden-files = mkOption { hidden-files = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Whether to index the hidden files or not."; description = "Whether to index the hidden files or not.";
}; };
@ -66,7 +63,7 @@ let
</transcoding> </transcoding>
''; '';
configText = optionalString (! cfg.customCfg) '' configText = lib.optionalString (! cfg.customCfg) ''
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd"> <config version="2" xmlns="http://mediatomb.cc/config/2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mediatomb.cc/config/2 http://mediatomb.cc/config/2.xsd">
<server> <server>
@ -87,7 +84,7 @@ let
</sqlite3> </sqlite3>
</storage> </storage>
<protocolInfo extend="${optionYesNo cfg.ps3Support}"/> <protocolInfo extend="${optionYesNo cfg.ps3Support}"/>
${optionalString cfg.dsmSupport '' ${lib.optionalString cfg.dsmSupport ''
<custom-http-headers> <custom-http-headers>
<add header="X-User-Agent: redsonic"/> <add header="X-User-Agent: redsonic"/>
</custom-http-headers> </custom-http-headers>
@ -95,7 +92,7 @@ let
<manufacturerURL>redsonic.com</manufacturerURL> <manufacturerURL>redsonic.com</manufacturerURL>
<modelNumber>105</modelNumber> <modelNumber>105</modelNumber>
''} ''}
${optionalString cfg.tg100Support '' ${lib.optionalString cfg.tg100Support ''
<upnp-string-limit>101</upnp-string-limit> <upnp-string-limit>101</upnp-string-limit>
''} ''}
<extended-runtime-options> <extended-runtime-options>
@ -109,7 +106,7 @@ let
</server> </server>
<import hidden-files="no"> <import hidden-files="no">
<autoscan use-inotify="auto"> <autoscan use-inotify="auto">
${concatMapStrings toMediaDirectory cfg.mediaDirectories} ${lib.concatMapStrings toMediaDirectory cfg.mediaDirectories}
</autoscan> </autoscan>
<scripting script-charset="UTF-8"> <scripting script-charset="UTF-8">
<common-script>${pkg}/share/${name}/js/common.js</common-script> <common-script>${pkg}/share/${name}/js/common.js</common-script>
@ -139,10 +136,10 @@ let
<map from="flv" to="video/x-flv"/> <map from="flv" to="video/x-flv"/>
<map from="mkv" to="video/x-matroska"/> <map from="mkv" to="video/x-matroska"/>
<map from="mka" to="audio/x-matroska"/> <map from="mka" to="audio/x-matroska"/>
${optionalString cfg.ps3Support '' ${lib.optionalString cfg.ps3Support ''
<map from="avi" to="video/divx"/> <map from="avi" to="video/divx"/>
''} ''}
${optionalString cfg.dsmSupport '' ${lib.optionalString cfg.dsmSupport ''
<map from="avi" to="video/avi"/> <map from="avi" to="video/avi"/>
''} ''}
</extension-mimetype> </extension-mimetype>
@ -199,26 +196,26 @@ in {
services.mediatomb = { services.mediatomb = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable the Gerbera/Mediatomb DLNA server. Whether to enable the Gerbera/Mediatomb DLNA server.
''; '';
}; };
serverName = mkOption { serverName = lib.mkOption {
type = types.str; type = lib.types.str;
default = "Gerbera (Mediatomb)"; default = "Gerbera (Mediatomb)";
description = '' description = ''
How to identify the server on the network. How to identify the server on the network.
''; '';
}; };
package = mkPackageOption pkgs "gerbera" { }; package = lib.mkPackageOption pkgs "gerbera" { };
ps3Support = mkOption { ps3Support = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable ps3 specific tweaks. Whether to enable ps3 specific tweaks.
@ -226,8 +223,8 @@ in {
''; '';
}; };
dsmSupport = mkOption { dsmSupport = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable D-Link DSM 320 specific tweaks. Whether to enable D-Link DSM 320 specific tweaks.
@ -235,69 +232,69 @@ in {
''; '';
}; };
tg100Support = mkOption { tg100Support = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable Telegent TG100 specific tweaks. Whether to enable Telegent TG100 specific tweaks.
''; '';
}; };
transcoding = mkOption { transcoding = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable transcoding. Whether to enable transcoding.
''; '';
}; };
dataDir = mkOption { dataDir = lib.mkOption {
type = types.path; type = lib.types.path;
default = "/var/lib/${name}"; default = "/var/lib/${name}";
defaultText = literalExpression ''"/var/lib/''${config.${opt.package}.pname}"''; defaultText = lib.literalExpression ''"/var/lib/''${config.${opt.package}.pname}"'';
description = '' description = ''
The directory where Gerbera/Mediatomb stores its state, data, etc. The directory where Gerbera/Mediatomb stores its state, data, etc.
''; '';
}; };
pcDirectoryHide = mkOption { pcDirectoryHide = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether to list the top-level directory or not (from upnp client standpoint). Whether to list the top-level directory or not (from upnp client standpoint).
''; '';
}; };
user = mkOption { user = lib.mkOption {
type = types.str; type = lib.types.str;
default = "mediatomb"; default = "mediatomb";
description = "User account under which the service runs."; description = "User account under which the service runs.";
}; };
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "mediatomb"; default = "mediatomb";
description = "Group account under which the service runs."; description = "Group account under which the service runs.";
}; };
port = mkOption { port = lib.mkOption {
type = types.port; type = lib.types.port;
default = 49152; default = 49152;
description = '' description = ''
The network port to listen on. The network port to listen on.
''; '';
}; };
interface = mkOption { interface = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = '' description = ''
A specific interface to bind to. A specific interface to bind to.
''; '';
}; };
openFirewall = mkOption { openFirewall = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
If false (the default), this is up to the user to declare the firewall rules. If false (the default), this is up to the user to declare the firewall rules.
@ -310,16 +307,16 @@ in {
''; '';
}; };
uuid = mkOption { uuid = lib.mkOption {
type = types.str; type = lib.types.str;
default = "fdfc8a4e-a3ad-4c1d-b43d-a2eedb03a687"; default = "fdfc8a4e-a3ad-4c1d-b43d-a2eedb03a687";
description = '' description = ''
A unique (on your network) to identify the server by. A unique (on your network) to identify the server by.
''; '';
}; };
mediaDirectories = mkOption { mediaDirectories = lib.mkOption {
type = with types; listOf (submodule mediaDirectory); type = with lib.types; listOf (submodule mediaDirectory);
default = []; default = [];
description = '' description = ''
Declare media directories to index. Declare media directories to index.
@ -330,8 +327,8 @@ in {
]; ];
}; };
customCfg = mkOption { customCfg = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Allow the service to create and use its own config file inside the `dataDir` as Allow the service to create and use its own config file inside the `dataDir` as
@ -350,9 +347,9 @@ in {
###### implementation ###### implementation
config = let binaryCommand = "${pkg}/bin/${name}"; config = let binaryCommand = "${pkg}/bin/${name}";
interfaceFlag = optionalString ( cfg.interface != "") "--interface ${cfg.interface}"; interfaceFlag = lib.optionalString ( cfg.interface != "") "--interface ${cfg.interface}";
configFlag = optionalString (! cfg.customCfg) "--config ${pkgs.writeText "config.xml" configText}"; configFlag = lib.optionalString (! cfg.customCfg) "--config ${pkgs.writeText "config.xml" configText}";
in mkIf cfg.enable { in lib.mkIf cfg.enable {
systemd.services.mediatomb = { systemd.services.mediatomb = {
description = "${cfg.serverName} media Server"; description = "${cfg.serverName} media Server";
# Gerbera might fail if the network interface is not available on startup # Gerbera might fail if the network interface is not available on startup
@ -365,11 +362,11 @@ in {
serviceConfig.Group = cfg.group; serviceConfig.Group = cfg.group;
}; };
users.groups = optionalAttrs (cfg.group == "mediatomb") { users.groups = lib.optionalAttrs (cfg.group == "mediatomb") {
mediatomb.gid = gid; mediatomb.gid = gid;
}; };
users.users = optionalAttrs (cfg.user == "mediatomb") { users.users = lib.optionalAttrs (cfg.user == "mediatomb") {
mediatomb = { mediatomb = {
isSystemUser = true; isSystemUser = true;
group = cfg.group; group = cfg.group;
@ -380,11 +377,11 @@ in {
}; };
# Open firewall only if users enable it # Open firewall only if users enable it
networking.firewall = mkMerge [ networking.firewall = lib.mkMerge [
(mkIf (cfg.openFirewall && cfg.interface != "") { (lib.mkIf (cfg.openFirewall && cfg.interface != "") {
interfaces."${cfg.interface}" = defaultFirewallRules; interfaces."${cfg.interface}" = defaultFirewallRules;
}) })
(mkIf (cfg.openFirewall && cfg.interface == "") defaultFirewallRules) (lib.mkIf (cfg.openFirewall && cfg.interface == "") defaultFirewallRules)
]; ];
}; };
} }

View file

@ -4,12 +4,9 @@
pkgs, pkgs,
... ...
}: }:
with lib;
let let
cfg = config.services.mqtt2influxdb; cfg = config.services.mqtt2influxdb;
filterNull = filterAttrsRecursive (n: v: v != null); filterNull = lib.filterAttrsRecursive (n: v: v != null);
configFile = (pkgs.formats.yaml {}).generate "mqtt2influxdb.config.yaml" ( configFile = (pkgs.formats.yaml {}).generate "mqtt2influxdb.config.yaml" (
filterNull { filterNull {
inherit (cfg) mqtt influxdb; inherit (cfg) mqtt influxdb;
@ -17,26 +14,26 @@ let
} }
); );
pointType = types.submodule { pointType = lib.types.submodule {
options = { options = {
measurement = mkOption { measurement = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Name of the measurement"; description = "Name of the measurement";
}; };
topic = mkOption { topic = lib.mkOption {
type = types.str; type = lib.types.str;
description = "MQTT topic to subscribe to."; description = "MQTT topic to subscribe to.";
}; };
fields = mkOption { fields = lib.mkOption {
type = types.submodule { type = lib.types.submodule {
options = { options = {
value = mkOption { value = lib.mkOption {
type = types.str; type = lib.types.str;
default = "$.payload"; default = "$.payload";
description = "Value to be picked up"; description = "Value to be picked up";
}; };
type = mkOption { type = lib.mkOption {
type = with types; nullOr str; type = with lib.types; nullOr str;
default = null; default = null;
description = "Type to be picked up"; description = "Type to be picked up";
}; };
@ -44,8 +41,8 @@ let
}; };
description = "Field selector."; description = "Field selector.";
}; };
tags = mkOption { tags = lib.mkOption {
type = with types; attrsOf str; type = with lib.types; attrsOf str;
default = {}; default = {};
description = "Tags applied"; description = "Tags applied";
}; };
@ -124,10 +121,10 @@ let
in { in {
options = { options = {
services.mqtt2influxdb = { services.mqtt2influxdb = {
enable = mkEnableOption "BigClown MQTT to InfluxDB bridge"; enable = lib.mkEnableOption "BigClown MQTT to InfluxDB bridge";
package = mkPackageOption pkgs ["python3Packages" "mqtt2influxdb"] {}; package = lib.mkPackageOption pkgs ["python3Packages" "mqtt2influxdb"] {};
environmentFiles = mkOption { environmentFiles = lib.mkOption {
type = types.listOf types.path; type = lib.types.listOf lib.types.path;
default = []; default = [];
example = [ "/run/keys/mqtt2influxdb.env" ]; example = [ "/run/keys/mqtt2influxdb.env" ];
description = '' description = ''
@ -138,23 +135,23 @@ in {
''; '';
}; };
mqtt = { mqtt = {
host = mkOption { host = lib.mkOption {
type = types.str; type = lib.types.str;
default = "127.0.0.1"; default = "127.0.0.1";
description = "Host where MQTT server is running."; description = "Host where MQTT server is running.";
}; };
port = mkOption { port = lib.mkOption {
type = types.port; type = lib.types.port;
default = 1883; default = 1883;
description = "MQTT server port."; description = "MQTT server port.";
}; };
username = mkOption { username = lib.mkOption {
type = with types; nullOr str; type = with lib.types; nullOr str;
default = null; default = null;
description = "Username used to connect to the MQTT server."; description = "Username used to connect to the MQTT server.";
}; };
password = mkOption { password = lib.mkOption {
type = with types; nullOr str; type = with lib.types; nullOr str;
default = null; default = null;
description = '' description = ''
MQTT password. MQTT password.
@ -164,44 +161,44 @@ in {
the store. the store.
''; '';
}; };
cafile = mkOption { cafile = lib.mkOption {
type = with types; nullOr path; type = with lib.types; nullOr path;
default = null; default = null;
description = "Certification Authority file for MQTT"; description = "Certification Authority file for MQTT";
}; };
certfile = mkOption { certfile = lib.mkOption {
type = with types; nullOr path; type = with lib.types; nullOr path;
default = null; default = null;
description = "Certificate file for MQTT"; description = "Certificate file for MQTT";
}; };
keyfile = mkOption { keyfile = lib.mkOption {
type = with types; nullOr path; type = with lib.types; nullOr path;
default = null; default = null;
description = "Key file for MQTT"; description = "Key file for MQTT";
}; };
}; };
influxdb = { influxdb = {
host = mkOption { host = lib.mkOption {
type = types.str; type = lib.types.str;
default = "127.0.0.1"; default = "127.0.0.1";
description = "Host where InfluxDB server is running."; description = "Host where InfluxDB server is running.";
}; };
port = mkOption { port = lib.mkOption {
type = types.port; type = lib.types.port;
default = 8086; default = 8086;
description = "InfluxDB server port"; description = "InfluxDB server port";
}; };
database = mkOption { database = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Name of the InfluxDB database."; description = "Name of the InfluxDB database.";
}; };
username = mkOption { username = lib.mkOption {
type = with types; nullOr str; type = with lib.types; nullOr str;
default = null; default = null;
description = "Username for InfluxDB login."; description = "Username for InfluxDB login.";
}; };
password = mkOption { password = lib.mkOption {
type = with types; nullOr str; type = with lib.types; nullOr str;
default = null; default = null;
description = '' description = ''
Password for InfluxDB login. Password for InfluxDB login.
@ -211,26 +208,26 @@ in {
the store. the store.
''; '';
}; };
ssl = mkOption { ssl = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Use SSL to connect to the InfluxDB server."; description = "Use SSL to connect to the InfluxDB server.";
}; };
verify_ssl = mkOption { verify_ssl = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Verify SSL certificate when connecting to the InfluxDB server."; description = "Verify SSL certificate when connecting to the InfluxDB server.";
}; };
}; };
points = mkOption { points = lib.mkOption {
type = types.listOf pointType; type = lib.types.listOf pointType;
default = defaultPoints; default = defaultPoints;
description = "Points to bridge from MQTT to InfluxDB."; description = "Points to bridge from MQTT to InfluxDB.";
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.services.bigclown-mqtt2influxdb = let systemd.services.bigclown-mqtt2influxdb = let
envConfig = cfg.environmentFiles != []; envConfig = cfg.environmentFiles != [];
finalConfig = if envConfig finalConfig = if envConfig
@ -239,7 +236,7 @@ in {
in { in {
description = "BigClown MQTT to InfluxDB bridge"; description = "BigClown MQTT to InfluxDB bridge";
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
wants = mkIf config.services.mosquitto.enable ["mosquitto.service"]; wants = lib.mkIf config.services.mosquitto.enable ["mosquitto.service"];
preStart = '' preStart = ''
umask 077 umask 077
${pkgs.envsubst}/bin/envsubst -i "${configFile}" -o "${finalConfig}" ${pkgs.envsubst}/bin/envsubst -i "${configFile}" -o "${finalConfig}"

View file

@ -1,16 +1,13 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.nitter; cfg = config.services.nitter;
configFile = pkgs.writeText "nitter.conf" '' configFile = pkgs.writeText "nitter.conf" ''
${generators.toINI { ${lib.generators.toINI {
# String values need to be quoted # String values need to be quoted
mkKeyValue = generators.mkKeyValueDefault { mkKeyValue = lib.generators.mkKeyValueDefault {
mkValueString = v: mkValueString = v:
if isString v then "\"" + (strings.escape ["\""] (toString v)) + "\"" if lib.isString v then "\"" + (lib.escape ["\""] (toString v)) + "\""
else generators.mkValueStringDefault {} v; else lib.generators.mkValueStringDefault {} v;
} " = "; } " = ";
} (lib.recursiveUpdate { } (lib.recursiveUpdate {
Server = cfg.server; Server = cfg.server;
@ -47,57 +44,57 @@ in
{ {
imports = [ imports = [
# https://github.com/zedeus/nitter/pull/772 # https://github.com/zedeus/nitter/pull/772
(mkRemovedOptionModule [ "services" "nitter" "replaceInstagram" ] "Nitter no longer supports this option as Bibliogram has been discontinued.") (lib.mkRemovedOptionModule [ "services" "nitter" "replaceInstagram" ] "Nitter no longer supports this option as Bibliogram has been discontinued.")
]; ];
options = { options = {
services.nitter = { services.nitter = {
enable = mkEnableOption "Nitter, an alternative Twitter front-end"; enable = lib.mkEnableOption "Nitter, an alternative Twitter front-end";
package = mkPackageOption pkgs "nitter" { }; package = lib.mkPackageOption pkgs "nitter" { };
server = { server = {
address = mkOption { address = lib.mkOption {
type = types.str; type = lib.types.str;
default = "0.0.0.0"; default = "0.0.0.0";
example = "127.0.0.1"; example = "127.0.0.1";
description = "The address to listen on."; description = "The address to listen on.";
}; };
port = mkOption { port = lib.mkOption {
type = types.port; type = lib.types.port;
default = 8080; default = 8080;
example = 8000; example = 8000;
description = "The port to listen on."; description = "The port to listen on.";
}; };
https = mkOption { https = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Set secure attribute on cookies. Keep it disabled to enable cookies when not using HTTPS."; description = "Set secure attribute on cookies. Keep it disabled to enable cookies when not using HTTPS.";
}; };
httpMaxConnections = mkOption { httpMaxConnections = lib.mkOption {
type = types.int; type = lib.types.int;
default = 100; default = 100;
description = "Maximum number of HTTP connections."; description = "Maximum number of HTTP connections.";
}; };
staticDir = mkOption { staticDir = lib.mkOption {
type = types.path; type = lib.types.path;
default = "${cfg.package}/share/nitter/public"; default = "${cfg.package}/share/nitter/public";
defaultText = literalExpression ''"''${config.services.nitter.package}/share/nitter/public"''; defaultText = lib.literalExpression ''"''${config.services.nitter.package}/share/nitter/public"'';
description = "Path to the static files directory."; description = "Path to the static files directory.";
}; };
title = mkOption { title = lib.mkOption {
type = types.str; type = lib.types.str;
default = "nitter"; default = "nitter";
description = "Title of the instance."; description = "Title of the instance.";
}; };
hostname = mkOption { hostname = lib.mkOption {
type = types.str; type = lib.types.str;
default = "localhost"; default = "localhost";
example = "nitter.net"; example = "nitter.net";
description = "Hostname of the instance."; description = "Hostname of the instance.";
@ -105,38 +102,38 @@ in
}; };
cache = { cache = {
listMinutes = mkOption { listMinutes = lib.mkOption {
type = types.int; type = lib.types.int;
default = 240; default = 240;
description = "How long to cache list info (not the tweets, so keep it high)."; description = "How long to cache list info (not the tweets, so keep it high).";
}; };
rssMinutes = mkOption { rssMinutes = lib.mkOption {
type = types.int; type = lib.types.int;
default = 10; default = 10;
description = "How long to cache RSS queries."; description = "How long to cache RSS queries.";
}; };
redisHost = mkOption { redisHost = lib.mkOption {
type = types.str; type = lib.types.str;
default = "localhost"; default = "localhost";
description = "Redis host."; description = "Redis host.";
}; };
redisPort = mkOption { redisPort = lib.mkOption {
type = types.port; type = lib.types.port;
default = 6379; default = 6379;
description = "Redis port."; description = "Redis port.";
}; };
redisConnections = mkOption { redisConnections = lib.mkOption {
type = types.int; type = lib.types.int;
default = 20; default = 20;
description = "Redis connection pool size."; description = "Redis connection pool size.";
}; };
redisMaxConnections = mkOption { redisMaxConnections = lib.mkOption {
type = types.int; type = lib.types.int;
default = 30; default = 30;
description = '' description = ''
Maximum number of connections to Redis. Maximum number of connections to Redis.
@ -149,30 +146,30 @@ in
}; };
config = { config = {
base64Media = mkOption { base64Media = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Use base64 encoding for proxied media URLs."; description = "Use base64 encoding for proxied media URLs.";
}; };
enableRSS = mkEnableOption "RSS feeds" // { default = true; }; enableRSS = lib.mkEnableOption "RSS feeds" // { default = true; };
enableDebug = mkEnableOption "request logs and debug endpoints"; enableDebug = lib.mkEnableOption "request logs and debug endpoints";
proxy = mkOption { proxy = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = "URL to a HTTP/HTTPS proxy."; description = "URL to a HTTP/HTTPS proxy.";
}; };
proxyAuth = mkOption { proxyAuth = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
description = "Credentials for proxy."; description = "Credentials for proxy.";
}; };
tokenCount = mkOption { tokenCount = lib.mkOption {
type = types.int; type = lib.types.int;
default = 10; default = 10;
description = '' description = ''
Minimum amount of usable tokens. Minimum amount of usable tokens.
@ -187,114 +184,114 @@ in
}; };
preferences = { preferences = {
replaceTwitter = mkOption { replaceTwitter = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
example = "nitter.net"; example = "nitter.net";
description = "Replace Twitter links with links to this instance (blank to disable)."; description = "Replace Twitter links with links to this instance (blank to disable).";
}; };
replaceYouTube = mkOption { replaceYouTube = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
example = "piped.kavin.rocks"; example = "piped.kavin.rocks";
description = "Replace YouTube links with links to this instance (blank to disable)."; description = "Replace YouTube links with links to this instance (blank to disable).";
}; };
replaceReddit = mkOption { replaceReddit = lib.mkOption {
type = types.str; type = lib.types.str;
default = ""; default = "";
example = "teddit.net"; example = "teddit.net";
description = "Replace Reddit links with links to this instance (blank to disable)."; description = "Replace Reddit links with links to this instance (blank to disable).";
}; };
mp4Playback = mkOption { mp4Playback = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Enable MP4 video playback."; description = "Enable MP4 video playback.";
}; };
hlsPlayback = mkOption { hlsPlayback = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Enable HLS video streaming (requires JavaScript)."; description = "Enable HLS video streaming (requires JavaScript).";
}; };
proxyVideos = mkOption { proxyVideos = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Proxy video streaming through the server (might be slow)."; description = "Proxy video streaming through the server (might be slow).";
}; };
muteVideos = mkOption { muteVideos = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Mute videos by default."; description = "Mute videos by default.";
}; };
autoplayGifs = mkOption { autoplayGifs = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Autoplay GIFs."; description = "Autoplay GIFs.";
}; };
theme = mkOption { theme = lib.mkOption {
type = types.str; type = lib.types.str;
default = "Nitter"; default = "Nitter";
description = "Instance theme."; description = "Instance theme.";
}; };
infiniteScroll = mkOption { infiniteScroll = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Infinite scrolling (requires JavaScript, experimental!)."; description = "Infinite scrolling (requires JavaScript, experimental!).";
}; };
stickyProfile = mkOption { stickyProfile = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Make profile sidebar stick to top."; description = "Make profile sidebar stick to top.";
}; };
bidiSupport = mkOption { bidiSupport = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Support bidirectional text (makes clicking on tweets harder)."; description = "Support bidirectional text (makes clicking on tweets harder).";
}; };
hideTweetStats = mkOption { hideTweetStats = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Hide tweet stats (replies, retweets, likes)."; description = "Hide tweet stats (replies, retweets, likes).";
}; };
hideBanner = mkOption { hideBanner = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Hide profile banner."; description = "Hide profile banner.";
}; };
hidePins = mkOption { hidePins = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Hide pinned tweets."; description = "Hide pinned tweets.";
}; };
hideReplies = mkOption { hideReplies = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Hide tweet replies."; description = "Hide tweet replies.";
}; };
squareAvatars = mkOption { squareAvatars = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Square profile pictures."; description = "Square profile pictures.";
}; };
}; };
settings = mkOption { settings = lib.mkOption {
type = types.attrs; type = lib.types.attrs;
default = {}; default = {};
description = '' description = ''
Add settings here to override NixOS module generated settings. Add settings here to override NixOS module generated settings.
@ -304,8 +301,8 @@ in
''; '';
}; };
guestAccounts = mkOption { guestAccounts = lib.mkOption {
type = types.path; type = lib.types.path;
default = "/var/lib/nitter/guest_accounts.jsonl"; default = "/var/lib/nitter/guest_accounts.jsonl";
description = '' description = ''
Path to the guest accounts file. Path to the guest accounts file.
@ -321,21 +318,21 @@ in
''; '';
}; };
redisCreateLocally = mkOption { redisCreateLocally = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Configure local Redis server for Nitter."; description = "Configure local Redis server for Nitter.";
}; };
openFirewall = mkOption { openFirewall = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open ports in the firewall for Nitter web interface."; description = "Open ports in the firewall for Nitter web interface.";
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = [ assertions = [
{ {
assertion = !cfg.redisCreateLocally || (cfg.cache.redisHost == "localhost" && cfg.cache.redisPort == 6379); assertion = !cfg.redisCreateLocally || (cfg.cache.redisHost == "localhost" && cfg.cache.redisPort == 6379);
@ -397,7 +394,7 @@ in
port = cfg.cache.redisPort; port = cfg.cache.redisPort;
}; };
networking.firewall = mkIf cfg.openFirewall { networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.server.port ]; allowedTCPPorts = [ cfg.server.port ];
}; };
}; };

View file

@ -1,39 +1,36 @@
{ config, lib, pkgs, ...}: { config, lib, pkgs, ...}:
with lib;
let let
cfg = config.services.mosquitto; cfg = config.services.mosquitto;
# note that mosquitto config parsing is very simplistic as of may 2021. # note that mosquitto config parsing is very simplistic as of may 2021.
# often times they'll e.g. strtok() a line, check the first two tokens, and ignore the rest. # often times they'll e.g. strtok() a line, check the first two tokens, and ignore the rest.
# there's no escaping available either, so we have to prevent any being necessary. # there's no escaping available either, so we have to prevent any being necessary.
str = types.strMatching "[^\r\n]*" // { str = lib.types.strMatching "[^\r\n]*" // {
description = "single-line string"; description = "single-line string";
}; };
path = types.addCheck types.path (p: str.check "${p}"); path = lib.types.addCheck lib.types.path (p: str.check "${p}");
configKey = types.strMatching "[^\r\n\t ]+"; configKey = lib.types.strMatching "[^\r\n\t ]+";
optionType = with types; oneOf [ str path bool int ] // { optionType = with lib.types; oneOf [ str path bool int ] // {
description = "string, path, bool, or integer"; description = "string, path, bool, or integer";
}; };
optionToString = v: optionToString = v:
if isBool v then boolToString v if lib.isBool v then lib.boolToString v
else if path.check v then "${v}" else if path.check v then "${v}"
else toString v; else toString v;
assertKeysValid = prefix: valid: config: assertKeysValid = prefix: valid: config:
mapAttrsToList lib.mapAttrsToList
(n: _: { (n: _: {
assertion = valid ? ${n}; assertion = valid ? ${n};
message = "Invalid config key ${prefix}.${n}."; message = "Invalid config key ${prefix}.${n}.";
}) })
config; config;
formatFreeform = { prefix ? "" }: mapAttrsToList (n: v: "${prefix}${n} ${optionToString v}"); formatFreeform = { prefix ? "" }: lib.mapAttrsToList (n: v: "${prefix}${n} ${optionToString v}");
userOptions = with types; submodule { userOptions = with lib.types; submodule {
options = { options = {
password = mkOption { password = lib.mkOption {
type = uniq (nullOr str); type = uniq (nullOr str);
default = null; default = null;
description = '' description = ''
@ -41,7 +38,7 @@ let
''; '';
}; };
passwordFile = mkOption { passwordFile = lib.mkOption {
type = uniq (nullOr path); type = uniq (nullOr path);
example = "/path/to/file"; example = "/path/to/file";
default = null; default = null;
@ -54,7 +51,7 @@ let
''; '';
}; };
hashedPassword = mkOption { hashedPassword = lib.mkOption {
type = uniq (nullOr str); type = uniq (nullOr str);
default = null; default = null;
description = '' description = ''
@ -66,7 +63,7 @@ let
''; '';
}; };
hashedPasswordFile = mkOption { hashedPasswordFile = lib.mkOption {
type = uniq (nullOr path); type = uniq (nullOr path);
example = "/path/to/file"; example = "/path/to/file";
default = null; default = null;
@ -82,7 +79,7 @@ let
''; '';
}; };
acl = mkOption { acl = lib.mkOption {
type = listOf str; type = listOf str;
example = [ "read A/B" "readwrite A/#" ]; example = [ "read A/B" "readwrite A/#" ];
default = []; default = [];
@ -94,15 +91,15 @@ let
}; };
userAsserts = prefix: users: userAsserts = prefix: users:
mapAttrsToList lib.mapAttrsToList
(n: _: { (n: _: {
assertion = builtins.match "[^:\r\n]+" n != null; assertion = builtins.match "[^:\r\n]+" n != null;
message = "Invalid user name ${n} in ${prefix}"; message = "Invalid user name ${n} in ${prefix}";
}) })
users users
++ mapAttrsToList ++ lib.mapAttrsToList
(n: u: { (n: u: {
assertion = count (s: s != null) [ assertion = lib.count (s: s != null) [
u.password u.passwordFile u.hashedPassword u.hashedPasswordFile u.password u.passwordFile u.hashedPassword u.hashedPasswordFile
] <= 1; ] <= 1;
message = "Cannot set more than one password option for user ${n} in ${prefix}"; message = "Cannot set more than one password option for user ${n} in ${prefix}";
@ -112,26 +109,26 @@ let
userScope = prefix: index: "${prefix}-user-${toString index}"; userScope = prefix: index: "${prefix}-user-${toString index}";
credentialID = prefix: credential: "${prefix}-${credential}"; credentialID = prefix: credential: "${prefix}-${credential}";
toScopedUsers = listenerScope: users: pipe users [ toScopedUsers = listenerScope: users: lib.pipe users [
attrNames lib.attrNames
(imap0 (index: user: nameValuePair user (lib.imap0 (index: user: lib.nameValuePair user
(users.${user} // { scope = userScope listenerScope index; }) (users.${user} // { scope = userScope listenerScope index; })
)) ))
listToAttrs lib.listToAttrs
]; ];
userCredentials = user: credentials: pipe credentials [ userCredentials = user: credentials: lib.pipe credentials [
(filter (credential: user.${credential} != null)) (lib.filter (credential: user.${credential} != null))
(map (credential: "${credentialID user.scope credential}:${user.${credential}}")) (map (credential: "${credentialID user.scope credential}:${user.${credential}}"))
]; ];
usersCredentials = listenerScope: users: credentials: pipe users [ usersCredentials = listenerScope: users: credentials: lib.pipe users [
(toScopedUsers listenerScope) (toScopedUsers listenerScope)
(mapAttrsToList (_: user: userCredentials user credentials)) (lib.mapAttrsToList (_: user: userCredentials user credentials))
concatLists lib.concatLists
]; ];
systemdCredentials = listeners: listenerCredentials: pipe listeners [ systemdCredentials = listeners: listenerCredentials: lib.pipe listeners [
(imap0 (index: listener: listenerCredentials (listenerScope index) listener)) (lib.imap0 (index: listener: listenerCredentials (listenerScope index) listener))
concatLists lib.concatLists
]; ];
makePasswordFile = listenerScope: users: path: makePasswordFile = listenerScope: users: path:
@ -139,12 +136,12 @@ let
makeLines = store: file: let makeLines = store: file: let
scopedUsers = toScopedUsers listenerScope users; scopedUsers = toScopedUsers listenerScope users;
in in
mapAttrsToList lib.mapAttrsToList
(name: user: ''addLine ${escapeShellArg name} "''$(systemd-creds cat ${credentialID user.scope store})"'') (name: user: ''addLine ${lib.escapeShellArg name} "''$(systemd-creds cat ${credentialID user.scope store})"'')
(filterAttrs (_: user: user.${store} != null) scopedUsers) (lib.filterAttrs (_: user: user.${store} != null) scopedUsers)
++ mapAttrsToList ++ lib.mapAttrsToList
(name: user: ''addFile ${escapeShellArg name} "''${CREDENTIALS_DIRECTORY}/${credentialID user.scope file}"'') (name: user: ''addFile ${lib.escapeShellArg name} "''${CREDENTIALS_DIRECTORY}/${credentialID user.scope file}"'')
(filterAttrs (_: user: user.${file} != null) scopedUsers); (lib.filterAttrs (_: user: user.${file} != null) scopedUsers);
plainLines = makeLines "password" "passwordFile"; plainLines = makeLines "password" "passwordFile";
hashedLines = makeLines "hashedPassword" "hashedPasswordFile"; hashedLines = makeLines "hashedPassword" "hashedPasswordFile";
in in
@ -154,7 +151,7 @@ let
set -eu set -eu
file=${escapeShellArg path} file=${lib.escapeShellArg path}
rm -f "$file" rm -f "$file"
touch "$file" touch "$file"
@ -170,23 +167,23 @@ let
echo "$1:$(cat "$2")" >> "$file" echo "$1:$(cat "$2")" >> "$file"
} }
'' ''
+ concatStringsSep "\n" + lib.concatStringsSep "\n"
(plainLines (plainLines
++ optional (plainLines != []) '' ++ lib.optional (plainLines != []) ''
${cfg.package}/bin/mosquitto_passwd -U "$file" ${cfg.package}/bin/mosquitto_passwd -U "$file"
'' ''
++ hashedLines)); ++ hashedLines));
authPluginOptions = with types; submodule { authPluginOptions = with lib.types; submodule {
options = { options = {
plugin = mkOption { plugin = lib.mkOption {
type = path; type = path;
description = '' description = ''
Plugin path to load, should be a `.so` file. Plugin path to load, should be a `.so` file.
''; '';
}; };
denySpecialChars = mkOption { denySpecialChars = lib.mkOption {
type = bool; type = bool;
description = '' description = ''
Automatically disallow all clients using `#` Automatically disallow all clients using `#`
@ -195,7 +192,7 @@ let
default = true; default = true;
}; };
options = mkOption { options = lib.mkOption {
type = attrsOf optionType; type = attrsOf optionType;
description = '' description = ''
Options for the auth plugin. Each key turns into a `auth_opt_*` Options for the auth plugin. Each key turns into a `auth_opt_*`
@ -207,7 +204,7 @@ let
}; };
authAsserts = prefix: auth: authAsserts = prefix: auth:
mapAttrsToList lib.mapAttrsToList
(n: _: { (n: _: {
assertion = configKey.check n; assertion = configKey.check n;
message = "Invalid auth plugin key ${prefix}.${n}"; message = "Invalid auth plugin key ${prefix}.${n}";
@ -253,9 +250,9 @@ let
use_username_as_clientid = 1; use_username_as_clientid = 1;
}; };
listenerOptions = with types; submodule { listenerOptions = with lib.types; submodule {
options = { options = {
port = mkOption { port = lib.mkOption {
type = port; type = port;
description = '' description = ''
Port to listen on. Must be set to 0 to listen on a unix domain socket. Port to listen on. Must be set to 0 to listen on a unix domain socket.
@ -263,7 +260,7 @@ let
default = 1883; default = 1883;
}; };
address = mkOption { address = lib.mkOption {
type = nullOr str; type = nullOr str;
description = '' description = ''
Address to listen on. Listen on `0.0.0.0`/`::` Address to listen on. Listen on `0.0.0.0`/`::`
@ -272,7 +269,7 @@ let
default = null; default = null;
}; };
authPlugins = mkOption { authPlugins = lib.mkOption {
type = listOf authPluginOptions; type = listOf authPluginOptions;
description = '' description = ''
Authentication plugin to attach to this listener. Authentication plugin to attach to this listener.
@ -282,7 +279,7 @@ let
default = []; default = [];
}; };
users = mkOption { users = lib.mkOption {
type = attrsOf userOptions; type = attrsOf userOptions;
example = { john = { password = "123456"; acl = [ "readwrite john/#" ]; }; }; example = { john = { password = "123456"; acl = [ "readwrite john/#" ]; }; };
description = '' description = ''
@ -291,7 +288,7 @@ let
default = {}; default = {};
}; };
omitPasswordAuth = mkOption { omitPasswordAuth = lib.mkOption {
type = bool; type = bool;
description = '' description = ''
Omits password checking, allowing anyone to log in with any user name unless Omits password checking, allowing anyone to log in with any user name unless
@ -300,7 +297,7 @@ let
default = false; default = false;
}; };
acl = mkOption { acl = lib.mkOption {
type = listOf str; type = listOf str;
description = '' description = ''
Additional ACL items to prepend to the generated ACL file. Additional ACL items to prepend to the generated ACL file.
@ -309,7 +306,7 @@ let
default = []; default = [];
}; };
settings = mkOption { settings = lib.mkOption {
type = submodule { type = submodule {
freeformType = attrsOf optionType; freeformType = attrsOf optionType;
}; };
@ -324,7 +321,7 @@ let
listenerAsserts = prefix: listener: listenerAsserts = prefix: listener:
assertKeysValid "${prefix}.settings" freeformListenerKeys listener.settings assertKeysValid "${prefix}.settings" freeformListenerKeys listener.settings
++ userAsserts prefix listener.users ++ userAsserts prefix listener.users
++ imap0 ++ lib.imap0
(i: v: authAsserts "${prefix}.authPlugins.${toString i}" v) (i: v: authAsserts "${prefix}.authPlugins.${toString i}" v)
listener.authPlugins; listener.authPlugins;
@ -333,9 +330,9 @@ let
"listener ${toString listener.port} ${toString listener.address}" "listener ${toString listener.port} ${toString listener.address}"
"acl_file /etc/mosquitto/acl-${toString idx}.conf" "acl_file /etc/mosquitto/acl-${toString idx}.conf"
] ]
++ optional (! listener.omitPasswordAuth) "password_file ${cfg.dataDir}/passwd-${toString idx}" ++ lib.optional (! listener.omitPasswordAuth) "password_file ${cfg.dataDir}/passwd-${toString idx}"
++ formatFreeform {} listener.settings ++ formatFreeform {} listener.settings
++ concatMap formatAuthPlugin listener.authPlugins; ++ lib.concatMap formatAuthPlugin listener.authPlugins;
freeformBridgeKeys = { freeformBridgeKeys = {
bridge_alpn = 1; bridge_alpn = 1;
@ -373,19 +370,19 @@ let
try_private = 1; try_private = 1;
}; };
bridgeOptions = with types; submodule { bridgeOptions = with lib.types; submodule {
options = { options = {
addresses = mkOption { addresses = lib.mkOption {
type = listOf (submodule { type = listOf (submodule {
options = { options = {
address = mkOption { address = lib.mkOption {
type = str; type = str;
description = '' description = ''
Address of the remote MQTT broker. Address of the remote MQTT broker.
''; '';
}; };
port = mkOption { port = lib.mkOption {
type = port; type = port;
description = '' description = ''
Port of the remote MQTT broker. Port of the remote MQTT broker.
@ -400,7 +397,7 @@ let
''; '';
}; };
topics = mkOption { topics = lib.mkOption {
type = listOf str; type = listOf str;
description = '' description = ''
Topic patterns to be shared between the two brokers. Topic patterns to be shared between the two brokers.
@ -411,7 +408,7 @@ let
example = [ "# both 2 local/topic/ remote/topic/" ]; example = [ "# both 2 local/topic/ remote/topic/" ];
}; };
settings = mkOption { settings = lib.mkOption {
type = submodule { type = submodule {
freeformType = attrsOf optionType; freeformType = attrsOf optionType;
}; };
@ -426,14 +423,14 @@ let
bridgeAsserts = prefix: bridge: bridgeAsserts = prefix: bridge:
assertKeysValid "${prefix}.settings" freeformBridgeKeys bridge.settings assertKeysValid "${prefix}.settings" freeformBridgeKeys bridge.settings
++ [ { ++ [ {
assertion = length bridge.addresses > 0; assertion = lib.length bridge.addresses > 0;
message = "Bridge ${prefix} needs remote broker addresses"; message = "Bridge ${prefix} needs remote broker addresses";
} ]; } ];
formatBridge = name: bridge: formatBridge = name: bridge:
[ [
"connection ${name}" "connection ${name}"
"addresses ${concatMapStringsSep " " (a: "${a.address}:${toString a.port}") bridge.addresses}" "addresses ${lib.concatMapStringsSep " " (a: "${a.address}:${toString a.port}") bridge.addresses}"
] ]
++ map (t: "topic ${t}") bridge.topics ++ map (t: "topic ${t}") bridge.topics
++ formatFreeform {} bridge.settings; ++ formatFreeform {} bridge.settings;
@ -468,12 +465,12 @@ let
websockets_log_level = 1; websockets_log_level = 1;
}; };
globalOptions = with types; { globalOptions = with lib.types; {
enable = mkEnableOption "the MQTT Mosquitto broker"; enable = lib.mkEnableOption "the MQTT Mosquitto broker";
package = mkPackageOption pkgs "mosquitto" { }; package = lib.mkPackageOption pkgs "mosquitto" { };
bridges = mkOption { bridges = lib.mkOption {
type = attrsOf bridgeOptions; type = attrsOf bridgeOptions;
default = {}; default = {};
description = '' description = ''
@ -481,7 +478,7 @@ let
''; '';
}; };
listeners = mkOption { listeners = lib.mkOption {
type = listOf listenerOptions; type = listOf listenerOptions;
default = []; default = [];
description = '' description = ''
@ -489,7 +486,7 @@ let
''; '';
}; };
includeDirs = mkOption { includeDirs = lib.mkOption {
type = listOf path; type = listOf path;
description = '' description = ''
Directories to be scanned for further config files to include. Directories to be scanned for further config files to include.
@ -500,7 +497,7 @@ let
default = []; default = [];
}; };
logDest = mkOption { logDest = lib.mkOption {
type = listOf (either path (enum [ "stdout" "stderr" "syslog" "topic" "dlt" ])); type = listOf (either path (enum [ "stdout" "stderr" "syslog" "topic" "dlt" ]));
description = '' description = ''
Destinations to send log messages to. Destinations to send log messages to.
@ -508,7 +505,7 @@ let
default = [ "stderr" ]; default = [ "stderr" ];
}; };
logType = mkOption { logType = lib.mkOption {
type = listOf (enum [ "debug" "error" "warning" "notice" "information" type = listOf (enum [ "debug" "error" "warning" "notice" "information"
"subscribe" "unsubscribe" "websockets" "none" "all" ]); "subscribe" "unsubscribe" "websockets" "none" "all" ]);
description = '' description = ''
@ -517,7 +514,7 @@ let
default = []; default = [];
}; };
persistence = mkOption { persistence = lib.mkOption {
type = bool; type = bool;
description = '' description = ''
Enable persistent storage of subscriptions and messages. Enable persistent storage of subscriptions and messages.
@ -525,15 +522,15 @@ let
default = true; default = true;
}; };
dataDir = mkOption { dataDir = lib.mkOption {
default = "/var/lib/mosquitto"; default = "/var/lib/mosquitto";
type = types.path; type = lib.types.path;
description = '' description = ''
The data directory. The data directory.
''; '';
}; };
settings = mkOption { settings = lib.mkOption {
type = submodule { type = submodule {
freeformType = attrsOf optionType; freeformType = attrsOf optionType;
}; };
@ -545,10 +542,10 @@ let
}; };
globalAsserts = prefix: cfg: globalAsserts = prefix: cfg:
flatten [ lib.flatten [
(assertKeysValid "${prefix}.settings" freeformGlobalKeys cfg.settings) (assertKeysValid "${prefix}.settings" freeformGlobalKeys cfg.settings)
(imap0 (n: l: listenerAsserts "${prefix}.listener.${toString n}" l) cfg.listeners) (lib.imap0 (n: l: listenerAsserts "${prefix}.listener.${toString n}" l) cfg.listeners)
(mapAttrsToList (n: b: bridgeAsserts "${prefix}.bridge.${n}" b) cfg.bridges) (lib.mapAttrsToList (n: b: bridgeAsserts "${prefix}.bridge.${n}" b) cfg.bridges)
]; ];
formatGlobal = cfg: formatGlobal = cfg:
@ -561,12 +558,12 @@ let
cfg.logDest cfg.logDest
++ map (t: "log_type ${t}") cfg.logType ++ map (t: "log_type ${t}") cfg.logType
++ formatFreeform {} cfg.settings ++ formatFreeform {} cfg.settings
++ concatLists (imap0 formatListener cfg.listeners) ++ lib.concatLists (lib.imap0 formatListener cfg.listeners)
++ concatLists (mapAttrsToList formatBridge cfg.bridges) ++ lib.concatLists (lib.mapAttrsToList formatBridge cfg.bridges)
++ map (d: "include_dir ${d}") cfg.includeDirs; ++ map (d: "include_dir ${d}") cfg.includeDirs;
configFile = pkgs.writeText "mosquitto.conf" configFile = pkgs.writeText "mosquitto.conf"
(concatStringsSep "\n" (formatGlobal cfg)); (lib.concatStringsSep "\n" (formatGlobal cfg));
in in
@ -578,7 +575,7 @@ in
###### Implementation ###### Implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = globalAsserts "services.mosquitto" cfg; assertions = globalAsserts "services.mosquitto" cfg;
@ -633,13 +630,13 @@ in
ReadWritePaths = [ ReadWritePaths = [
cfg.dataDir cfg.dataDir
"/tmp" # mosquitto_passwd creates files in /tmp before moving them "/tmp" # mosquitto_passwd creates files in /tmp before moving them
] ++ filter path.check cfg.logDest; ] ++ lib.filter path.check cfg.logDest;
ReadOnlyPaths = ReadOnlyPaths =
map (p: "${p}") map (p: "${p}")
(cfg.includeDirs (cfg.includeDirs
++ filter ++ lib.filter
(v: v != null) (v: v != null)
(flatten [ (lib.flatten [
(map (map
(l: [ (l: [
(l.settings.psk_file or null) (l.settings.psk_file or null)
@ -652,7 +649,7 @@ in
(l.settings.keyfile or null) (l.settings.keyfile or null)
]) ])
cfg.listeners) cfg.listeners)
(mapAttrsToList (lib.mapAttrsToList
(_: b: [ (_: b: [
(b.settings.bridge_cafile or null) (b.settings.bridge_cafile or null)
(b.settings.bridge_capath or null) (b.settings.bridge_capath or null)
@ -680,26 +677,26 @@ in
UMask = "0077"; UMask = "0077";
}; };
preStart = preStart =
concatStringsSep lib.concatStringsSep
"\n" "\n"
(imap0 (lib.imap0
(idx: listener: makePasswordFile (listenerScope idx) listener.users "${cfg.dataDir}/passwd-${toString idx}") (idx: listener: makePasswordFile (listenerScope idx) listener.users "${cfg.dataDir}/passwd-${toString idx}")
cfg.listeners); cfg.listeners);
}; };
environment.etc = listToAttrs ( environment.etc = lib.listToAttrs (
imap0 lib.imap0
(idx: listener: { (idx: listener: {
name = "mosquitto/acl-${toString idx}.conf"; name = "mosquitto/acl-${toString idx}.conf";
value = { value = {
user = config.users.users.mosquitto.name; user = config.users.users.mosquitto.name;
group = config.users.users.mosquitto.group; group = config.users.users.mosquitto.group;
mode = "0400"; mode = "0400";
text = (concatStringsSep text = (lib.concatStringsSep
"\n" "\n"
(flatten [ (lib.flatten [
listener.acl listener.acl
(mapAttrsToList (lib.mapAttrsToList
(n: u: [ "user ${n}" ] ++ map (t: "topic ${t}") u.acl) (n: u: [ "user ${n}" ] ++ map (t: "topic ${t}") u.acl)
listener.users) listener.users)
])); ]));

View file

@ -23,6 +23,8 @@ in
''; '';
}; };
unprivilegedContainers = lib.mkEnableOption "support for unprivileged users to launch containers";
systemConfig = systemConfig =
lib.mkOption { lib.mkOption {
type = lib.types.lines; type = lib.types.lines;
@ -53,6 +55,15 @@ in
administration access in LXC. See {manpage}`lxc-usernet(5)`. administration access in LXC. See {manpage}`lxc-usernet(5)`.
''; '';
}; };
bridgeConfig =
lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
This is the config file for override lxc-net bridge default settings.
'';
};
}; };
###### implementation ###### implementation
@ -62,6 +73,8 @@ in
environment.etc."lxc/lxc.conf".text = cfg.systemConfig; environment.etc."lxc/lxc.conf".text = cfg.systemConfig;
environment.etc."lxc/lxc-usernet".text = cfg.usernetConfig; environment.etc."lxc/lxc-usernet".text = cfg.usernetConfig;
environment.etc."lxc/default.conf".text = cfg.defaultConfig; environment.etc."lxc/default.conf".text = cfg.defaultConfig;
environment.etc."lxc/lxc-net".text = cfg.bridgeConfig;
environment.pathsToLink = [ "/share/lxc" ];
systemd.tmpfiles.rules = [ "d /var/lib/lxc/rootfs 0755 root root -" ]; systemd.tmpfiles.rules = [ "d /var/lib/lxc/rootfs 0755 root root -" ];
security.apparmor.packages = [ cfg.package ]; security.apparmor.packages = [ cfg.package ];
@ -73,5 +86,30 @@ in
include ${cfg.package}/etc/apparmor.d/lxc-containers include ${cfg.package}/etc/apparmor.d/lxc-containers
''; '';
}; };
# We don't need the `lxc-user` group, unless the unprivileged containers are enabled.
users.groups = lib.mkIf cfg.unprivilegedContainers { lxc-user = {}; };
# `lxc-user-nic` needs suid to attach to bridge for unpriv containers.
security.wrappers = lib.mkIf cfg.unprivilegedContainers {
lxcUserNet = {
source = "${pkgs.lxc}/libexec/lxc/lxc-user-nic";
setuid = true;
owner = "root";
group = "lxc-user";
program = "lxc-user-nic";
permissions = "u+rx,g+x,o-rx";
};
};
# Add lxc-net service if unpriv mode is enabled.
systemd.packages = lib.mkIf cfg.unprivilegedContainers [ pkgs.lxc ];
systemd.services = lib.mkIf cfg.unprivilegedContainers {
lxc-net = {
enable = true;
wantedBy = [ "multi-user.target" ];
path = [ pkgs.iproute2 pkgs.iptables pkgs.getent pkgs.dnsmasq ];
};
};
}; };
} }

View file

@ -539,6 +539,7 @@ in {
loki = handleTest ./loki.nix {}; loki = handleTest ./loki.nix {};
luks = handleTest ./luks.nix {}; luks = handleTest ./luks.nix {};
lvm2 = handleTest ./lvm2 {}; lvm2 = handleTest ./lvm2 {};
lxc = handleTest ./lxc {};
lxd = pkgs.recurseIntoAttrs (handleTest ./lxd { inherit handleTestOn; }); lxd = pkgs.recurseIntoAttrs (handleTest ./lxd { inherit handleTestOn; });
lxd-image-server = handleTest ./lxd-image-server.nix {}; lxd-image-server = handleTest ./lxd-image-server.nix {};
#logstash = handleTest ./logstash.nix {}; #logstash = handleTest ./logstash.nix {};

View file

@ -11,8 +11,8 @@ let
extra; extra;
}; };
container-image-metadata = releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system}; container-image-metadata = "${releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system}}/tarball/nixos-system-${pkgs.stdenv.hostPlatform.system}.tar.xz";
container-image-rootfs = releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system}; container-image-rootfs = "${releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system}}/nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}.squashfs";
in in
{ {
inherit name; inherit name;
@ -61,7 +61,7 @@ in
machine.succeed("incus admin init --minimal") machine.succeed("incus admin init --minimal")
with subtest("Container image can be imported"): with subtest("Container image can be imported"):
machine.succeed("incus image import ${container-image-metadata}/*/*.tar.xz ${container-image-rootfs} --alias nixos") machine.succeed("incus image import ${container-image-metadata} ${container-image-rootfs} --alias nixos")
with subtest("Container can be launched and managed"): with subtest("Container can be launched and managed"):
machine.succeed("incus launch nixos container") machine.succeed("incus launch nixos container")

View file

@ -16,8 +16,12 @@ import ../make-test-python.nix (
}; };
}; };
container-image-metadata = releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system}; container-image-metadata = "${
container-image-rootfs = releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system}; releases.incusContainerMeta.${pkgs.stdenv.hostPlatform.system}
}/tarball/nixos-system-${pkgs.stdenv.hostPlatform.system}.tar.xz";
container-image-rootfs = "${
releases.incusContainerImage.${pkgs.stdenv.hostPlatform.system}
}/nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}.squashfs";
in in
{ {
name = "incusd-options"; name = "incusd-options";
@ -87,7 +91,7 @@ import ../make-test-python.nix (
machine.wait_for_unit("incus-preseed.service") machine.wait_for_unit("incus-preseed.service")
with subtest("Container image can be imported"): with subtest("Container image can be imported"):
machine.succeed("incus image import ${container-image-metadata}/*/*.tar.xz ${container-image-rootfs} --alias nixos") machine.succeed("incus image import ${container-image-metadata} ${container-image-rootfs} --alias nixos")
with subtest("Container can be launched and managed"): with subtest("Container can be launched and managed"):
machine.succeed("incus launch nixos container") machine.succeed("incus launch nixos container")

124
nixos/tests/lxc/default.nix Normal file
View file

@ -0,0 +1,124 @@
import ../make-test-python.nix (
{ pkgs, lib, ... }:
let
releases = import ../../release.nix {
configuration = {
# Building documentation makes the test unnecessarily take a longer time:
documentation.enable = lib.mkForce false;
};
};
lxc-image-metadata = releases.lxdContainerMeta.${pkgs.stdenv.hostPlatform.system};
lxc-image-rootfs = releases.lxdContainerImage.${pkgs.stdenv.hostPlatform.system};
in
{
name = "lxc-container-unprivileged";
meta = {
maintainers = lib.teams.lxc.members;
};
nodes.machine =
{ lib, pkgs, ... }:
{
virtualisation = {
diskSize = 6144;
cores = 2;
memorySize = 512;
writableStore = true;
lxc = {
enable = true;
unprivilegedContainers = true;
systemConfig = ''
lxc.lxcpath = /tmp/lxc
'';
defaultConfig = ''
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536
'';
# Permit user alice to connect to bridge
usernetConfig = ''
@lxc-user veth lxcbr0 10
'';
bridgeConfig = ''
LXC_IPV6_ADDR=""
LXC_IPV6_MASK=""
LXC_IPV6_NETWORK=""
LXC_IPV6_NAT="false"
'';
};
};
# Needed for lxc
environment.systemPackages = with pkgs; [
pkgs.wget
pkgs.dnsmasq
];
# Create user for test
users.users.alice = {
isNormalUser = true;
password = "test";
description = "Lxc unprivileged user with access to lxcbr0";
extraGroups = [ "lxc-user" ];
subGidRanges = [
{
startGid = 100000;
count = 65536;
}
];
subUidRanges = [
{
startUid = 100000;
count = 65536;
}
];
};
users.users.bob = {
isNormalUser = true;
password = "test";
description = "Lxc unprivileged user without access to lxcbr0";
subGidRanges = [
{
startGid = 100000;
count = 65536;
}
];
subUidRanges = [
{
startUid = 100000;
count = 65536;
}
];
};
};
testScript = ''
machine.wait_for_unit("lxc-net.service")
# Copy config files for alice
machine.execute("su -- alice -c 'mkdir -p ~/.config/lxc'")
machine.execute("su -- alice -c 'cp /etc/lxc/default.conf ~/.config/lxc/'")
machine.execute("su -- alice -c 'cp /etc/lxc/lxc.conf ~/.config/lxc/'")
machine.succeed("su -- alice -c 'lxc-create -t local -n test -- --metadata ${lxc-image-metadata}/*/*.tar.xz --fstree ${lxc-image-rootfs}/*/*.tar.xz'")
machine.succeed("su -- alice -c 'lxc-start test'")
machine.succeed("su -- alice -c 'lxc-stop test'")
# Copy config files for bob
machine.execute("su -- bob -c 'mkdir -p ~/.config/lxc'")
machine.execute("su -- bob -c 'cp /etc/lxc/default.conf ~/.config/lxc/'")
machine.execute("su -- bob -c 'cp /etc/lxc/lxc.conf ~/.config/lxc/'")
machine.fail("su -- bob -c 'lxc-start test'")
'';
}
)

View file

@ -64,7 +64,7 @@ in {
with subtest("Squashfs image is functional"): with subtest("Squashfs image is functional"):
machine.succeed( machine.succeed(
"lxc image import ${lxd-image-metadata}/*/*.tar.xz ${lxd-image-rootfs-squashfs} --alias nixos-squashfs" "lxc image import ${lxd-image-metadata}/*/*.tar.xz ${lxd-image-rootfs-squashfs}/nixos-lxc-image-${pkgs.stdenv.hostPlatform.system}.squashfs --alias nixos-squashfs"
) )
machine.succeed("lxc launch nixos-squashfs container") machine.succeed("lxc launch nixos-squashfs container")
with machine.nested("Waiting for instance to start and be usable"): with machine.nested("Waiting for instance to start and be usable"):

View file

@ -1,77 +0,0 @@
{ lib
, python3
, fetchFromGitHub
, meson
, ninja
, gettext
, appstream
, appstream-glib
, wrapGAppsHook4
, desktop-file-utils
, gobject-introspection
, gtk4
, gtksourceview5
, libadwaita
, libportal
, librsvg
, poppler_gi
, webkitgtk_6_0
}:
python3.pkgs.buildPythonApplication rec {
pname = "setzer";
version = "65";
src = fetchFromGitHub {
owner = "cvfosammmm";
repo = "Setzer";
rev = "v${version}";
hash = "sha256-5Hpj/RkD11bNcr9/gQG0Y7BNMsh1BGZQiN4IMbI4osc=";
};
format = "other";
nativeBuildInputs = [
meson
ninja
gettext
appstream # for appstreamcli
appstream-glib
wrapGAppsHook4
desktop-file-utils
gobject-introspection
];
buildInputs = [
gtk4
gtksourceview5
libadwaita
libportal
librsvg
poppler_gi
webkitgtk_6_0
];
propagatedBuildInputs = with python3.pkgs; [
bibtexparser
numpy
pdfminer-six
pexpect
pillow
pycairo
pygobject3
pyxdg
];
checkPhase = ''
meson test --print-errorlogs
'';
meta = with lib; {
description = "LaTeX editor written in Python with Gtk";
mainProgram = "setzer";
homepage = src.meta.homepage;
license = licenses.gpl3Plus;
maintainers = with maintainers; [ dotlambda ];
};
}

View file

@ -1,5 +1,5 @@
{ stdenv, nixosTests, lib, edk2, util-linux, nasm, acpica-tools, llvmPackages { stdenv, nixosTests, lib, edk2, util-linux, nasm, acpica-tools, llvmPackages
, fetchurl, python3, pexpect, xorriso, qemu, dosfstools, mtools , fetchFromGitLab, python3, pexpect, xorriso, qemu, dosfstools, mtools
, fdSize2MB ? false , fdSize2MB ? false
, fdSize4MB ? secureBoot , fdSize4MB ? secureBoot
, secureBoot ? false , secureBoot ? false
@ -12,7 +12,7 @@
# to use as the PK and first KEK for the keystore. # to use as the PK and first KEK for the keystore.
# #
# By default, we use Debian's cert. This default # By default, we use Debian's cert. This default
# should chnage to a NixOS cert once we have our # should change to a NixOS cert once we have our
# own secure boot signing infrastructure. # own secure boot signing infrastructure.
# #
# Ignored if msVarsTemplate is false. # Ignored if msVarsTemplate is false.
@ -66,9 +66,18 @@ let
OvmfPkKek1AppPrefix = "4e32566d-8e9e-4f52-81d3-5bb9715f9727"; OvmfPkKek1AppPrefix = "4e32566d-8e9e-4f52-81d3-5bb9715f9727";
debian-edk-src = fetchurl { debian-edk-src = fetchFromGitLab {
url = "http://deb.debian.org/debian/pool/main/e/edk2/edk2_2023.11-5.debian.tar.xz"; domain = "salsa.debian.org";
sha256 = "1yxlab4md30pxvjadr6b4xn6cyfw0c292q63pyfv4vylvhsb24g4"; owner = "qemu-team";
repo = "edk2";
nonConeMode = true;
sparseCheckout = [
"debian/edk2-vars-generator.py"
"debian/python"
"debian/PkKek-1-*.pem"
];
rev = "refs/tags/debian/2024.05-1";
hash = "sha256-uAjXJaHOVh944ZxcA2IgCsrsncxuhc0JKlsXs0E03s0=";
}; };
buildPrefix = "Build/*/*"; buildPrefix = "Build/*/*";
@ -111,7 +120,7 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
env.PYTHON_COMMAND = "python3"; env.PYTHON_COMMAND = "python3";
postUnpack = lib.optionalDrvAttr msVarsTemplate '' postUnpack = lib.optionalDrvAttr msVarsTemplate ''
unpackFile ${debian-edk-src} ln -s ${debian-edk-src}/debian
''; '';
postConfigure = lib.optionalDrvAttr msVarsTemplate '' postConfigure = lib.optionalDrvAttr msVarsTemplate ''
@ -138,7 +147,8 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
'' + lib.optionalString msVarsTemplate '' '' + lib.optionalString msVarsTemplate ''
( (
cd ${buildPrefix} cd ${buildPrefix}
python3 $NIX_BUILD_TOP/debian/edk2-vars-generator.py \ # locale must be set on Darwin for invocations of mtools to work correctly
LC_ALL=C python3 $NIX_BUILD_TOP/debian/edk2-vars-generator.py \
--flavor ${msVarsArgs.flavor} \ --flavor ${msVarsArgs.flavor} \
--enrolldefaultkeys ${msVarsArgs.archDir}/EnrollDefaultKeys.efi \ --enrolldefaultkeys ${msVarsArgs.archDir}/EnrollDefaultKeys.efi \
--shell ${msVarsArgs.archDir}/Shell.efi \ --shell ${msVarsArgs.archDir}/Shell.efi \
@ -165,7 +175,7 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
ln -sv $fd/FV/${fwPrefix}_CODE{,.ms}.fd ln -sv $fd/FV/${fwPrefix}_CODE{,.ms}.fd
'' + lib.optionalString stdenv.hostPlatform.isAarch '' '' + lib.optionalString stdenv.hostPlatform.isAarch ''
mv -v $out/FV/QEMU_{EFI,VARS}.fd $fd/FV mv -v $out/FV/QEMU_{EFI,VARS}.fd $fd/FV
# Add symlinks for Fedora dir layout: https://src.fedoraproject.org/cgit/rpms/edk2.git/tree/edk2.spec # Add symlinks for Fedora dir layout: https://src.fedoraproject.org/rpms/edk2/blob/main/f/edk2.spec
mkdir -vp $fd/AAVMF mkdir -vp $fd/AAVMF
ln -s $fd/FV/AAVMF_CODE.fd $fd/AAVMF/QEMU_EFI-pflash.raw ln -s $fd/FV/AAVMF_CODE.fd $fd/AAVMF/QEMU_EFI-pflash.raw
ln -s $fd/FV/AAVMF_VARS.fd $fd/AAVMF/vars-template-pflash.raw ln -s $fd/FV/AAVMF_VARS.fd $fd/AAVMF/vars-template-pflash.raw
@ -179,6 +189,9 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
in { in {
firmware = "${prefix}_CODE.fd"; firmware = "${prefix}_CODE.fd";
variables = "${prefix}_VARS.fd"; variables = "${prefix}_VARS.fd";
variablesMs =
assert msVarsTemplate;
"${prefix}_VARS.ms.fd";
# This will test the EFI firmware for the host platform as part of the NixOS Tests setup. # This will test the EFI firmware for the host platform as part of the NixOS Tests setup.
tests.basic-systemd-boot = nixosTests.systemd-boot.basic; tests.basic-systemd-boot = nixosTests.systemd-boot.basic;
tests.secureBoot-systemd-boot = nixosTests.systemd-boot.secureBoot; tests.secureBoot-systemd-boot = nixosTests.systemd-boot.secureBoot;
@ -190,7 +203,7 @@ edk2.mkDerivation projectDscPath (finalAttrs: {
homepage = "https://github.com/tianocore/tianocore.github.io/wiki/OVMF"; homepage = "https://github.com/tianocore/tianocore.github.io/wiki/OVMF";
license = lib.licenses.bsd2; license = lib.licenses.bsd2;
platforms = metaPlatforms; platforms = metaPlatforms;
maintainers = with lib.maintainers; [ adamcstephens raitobezarius ]; maintainers = with lib.maintainers; [ adamcstephens raitobezarius mjoerg ];
broken = stdenv.isDarwin; broken = stdenv.isDarwin && stdenv.isAarch64;
}; };
}) })

View file

@ -12,7 +12,7 @@ let
self = python3; self = python3;
packageOverrides = _: super: { tree-sitter = super.tree-sitter_0_21; }; packageOverrides = _: super: { tree-sitter = super.tree-sitter_0_21; };
}; };
version = "0.51.0"; version = "0.53.0";
in in
python3.pkgs.buildPythonApplication { python3.pkgs.buildPythonApplication {
pname = "aider-chat"; pname = "aider-chat";
@ -23,7 +23,7 @@ python3.pkgs.buildPythonApplication {
owner = "paul-gauthier"; owner = "paul-gauthier";
repo = "aider"; repo = "aider";
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
hash = "sha256-vomRXWL3++1R8jpjMKbsGrB+B1FWQxVbLKxuPttnspw="; hash = "sha256-KQp4qqQKm++oB9RVQZhAWQJs7Nbyssc9eKKRH1VZbRU=";
}; };
build-system = with python3.pkgs; [ setuptools ]; build-system = with python3.pkgs; [ setuptools ];

View file

@ -11,13 +11,13 @@
buildNpmPackage rec { buildNpmPackage rec {
pname = "bitwarden-cli"; pname = "bitwarden-cli";
version = "2024.8.0"; version = "2024.8.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "bitwarden"; owner = "bitwarden";
repo = "clients"; repo = "clients";
rev = "cli-v${version}"; rev = "cli-v${version}";
hash = "sha256-vosEc8HCMHEaaQadzA+jDjQA1liEtD8sS1Zndz/Iv00="; hash = "sha256-l9fLh1YFivVcMs688vM0pHoN0Um2r/EDpo7dvwvZFwY=";
}; };
postPatch = '' postPatch = ''
@ -27,10 +27,10 @@ buildNpmPackage rec {
nodejs = nodejs_20; nodejs = nodejs_20;
npmDepsHash = "sha256-5neEpU7ZhVO5OR181owsvAnFfl7lr0MymvqbRFCPs3M="; npmDepsHash = "sha256-/6yWdTy6/GvYy8u5eZB+x5KRG6vhPVE0DIn+RUAO5MI=";
nativeBuildInputs = [ nativeBuildInputs = [
python3 (python3.withPackages (ps: with ps; [ setuptools ]))
] ++ lib.optionals stdenv.isDarwin [ ] ++ lib.optionals stdenv.isDarwin [
cctools cctools
xcbuild.xcrun xcbuild.xcrun
@ -38,7 +38,19 @@ buildNpmPackage rec {
makeCacheWritable = true; makeCacheWritable = true;
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; env = {
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
npm_config_build_from_source = "true";
};
# node-argon2 builds with LTO, but that causes missing symbols. So disable it
# and rebuild. See https://github.com/ranisalt/node-argon2/pull/415
preConfigure = ''
pushd node_modules/argon2
substituteInPlace binding.gyp --replace-fail '"-flto", ' ""
"$npm_config_node_gyp" rebuild
popd
'';
npmBuildScript = "build:oss:prod"; npmBuildScript = "build:oss:prod";

File diff suppressed because it is too large Load diff

View file

@ -15,27 +15,31 @@
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "cosmic-notifications"; pname = "cosmic-notifications";
version = "unstable-2024-01-05"; version = "1.0.0-alpha.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "pop-os"; owner = "pop-os";
repo = pname; repo = "cosmic-notifications";
rev = "3b07cf550a54b757a5f136e4d8fde74d09afe3fd"; rev = "epoch-${version}";
hash = "sha256-+S8bPorarSJQwIQfTmo4qK+B1kKAlQvllUuZ2UBL0eY="; hash = "sha256-tCizZePze94tbJbR91N9rfUhrLFTAMW2oL9ByKOeDAU=";
}; };
cargoLock = { cargoLock = {
lockFile = ./Cargo.lock; lockFile = ./Cargo.lock;
outputHashes = { outputHashes = {
"accesskit-0.11.0" = "sha256-xVhe6adUb8VmwIKKjHxwCwOo5Y1p3Or3ylcJJdLDrrE="; "accesskit-0.12.2" = "sha256-1UwgRyUe0PQrZrpS7574oNLi13fg5HpgILtZGW6JNtQ=";
"atomicwrites-0.4.2" = "sha256-QZSuGPrJXh+svMeFWqAXoqZQxLq/WfIiamqvjJNVhxA="; "atomicwrites-0.4.2" = "sha256-QZSuGPrJXh+svMeFWqAXoqZQxLq/WfIiamqvjJNVhxA=";
"cosmic-client-toolkit-0.1.0" = "sha256-AEgvF7i/OWPdEMi8WUaAg99igBwE/AexhAXHxyeJMdc="; "clipboard_macos-0.1.0" = "sha256-cG5vnkiyDlQnbEfV2sPbmBYKv1hd3pjJrymfZb8ziKk=";
"cosmic-config-0.1.0" = "sha256-DmuUvFjhoqI5lneiWFFYF3WM3mACx5ZfZqeKpsyL7Ss="; "cosmic-client-toolkit-0.1.0" = "sha256-1XtyEvednEMN4MApxTQid4eed19dEN5ZBDt/XRjuda0=";
"cosmic-text-0.10.0" = "sha256-kIBhh6CakQaWGfBWu5qaV8LAbJENX7GW+BStJK/P4iA="; "cosmic-config-0.1.0" = "sha256-DgMh0gqWUmXjBhBySR0CMnv/8O3XbS2BwomU9eNt+4o=";
"cosmic-settings-daemon-0.1.0" = "sha256-z/dvRyc3Zc1fAQh2HKk6NI6QSDpNqarqslwszjU+0nc="; "cosmic-panel-config-0.1.0" = "sha256-bBUSZ3CTLq/DCQ2dMvaIcGcIcjqM/5vny5kTE3Jclj8=";
"glyphon-0.3.0" = "sha256-JGkNIfj1HjOF8kGxqJPNq/JO+NhZD6XrZ4KmkXEP6Xc="; "cosmic-settings-daemon-0.1.0" = "sha256-+1XB7r45Uc71fLnNR4U0DUF2EB8uzKeE4HIrdvKhFXo=";
"smithay-client-toolkit-0.18.0" = "sha256-2WbDKlSGiyVmi7blNBr2Aih9FfF2dq/bny57hoA4BrE="; "cosmic-text-0.12.1" = "sha256-x0XTxzbmtE2d4XCG/Nuq3DzBpz15BbnjRRlirfNJEiU=";
"softbuffer-0.3.3" = "sha256-eKYFVr6C1+X6ulidHIu9SP591rJxStxwL9uMiqnXx4k="; "cosmic-time-0.4.0" = "sha256-w4yY1fc4r1+pSv93dy/Hu3AD+I1+sozIPbbCoaVQj7w=";
"d3d12-0.19.0" = "sha256-usrxQXWLGJDjmIdw1LBXtBvX+CchZDvE8fHC0LjvhD4=";
"glyphon-0.5.0" = "sha256-j1HrbEpUBqazWqNfJhpyjWuxYAxkvbXzRKeSouUoPWg=";
"smithay-clipboard-0.8.0" = "sha256-4InFXm0ahrqFrtNLeqIuE3yeOpxKZJZx+Bc0yQDtv34=";
"softbuffer-0.4.1" = "sha256-a0bUFz6O8CWRweNt/OxTvflnPYwO5nm6vsyc/WcXyNg=";
"taffy-0.3.11" = "sha256-SCx9GEIJjWdoNVyq+RZAGn0N71qraKZxf9ZWhvyzLaI="; "taffy-0.3.11" = "sha256-SCx9GEIJjWdoNVyq+RZAGn0N71qraKZxf9ZWhvyzLaI=";
}; };
}; };

View file

@ -6,13 +6,13 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "cosmic-protocols"; pname = "cosmic-protocols";
version = "0-unstable-2024-01-11"; version = "0-unstable-2024-07-31";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "pop-os"; owner = "pop-os";
repo = pname; repo = pname;
rev = "e65fa5e2bb47e51656221657049bd3f88ae9dae5"; rev = "de2fead49d6af3a221db153642e4d7c2235aafc4";
hash = "sha256-vj7Wm1uJ5ULvGNEwKznNhujCZQiuntsWMyKQbIVaO/Q="; hash = "sha256-qgo8FMKo/uCbhUjfykRRN8KSavbyhZpu82M8npLcIPI=";
}; };
makeFlags = [ "PREFIX=${placeholder "out"}" ]; makeFlags = [ "PREFIX=${placeholder "out"}" ];
@ -20,7 +20,7 @@ stdenv.mkDerivation rec {
meta = with lib; { meta = with lib; {
homepage = "https://github.com/pop-os/cosmic-protocols"; homepage = "https://github.com/pop-os/cosmic-protocols";
description = "Addtional wayland-protocols used by the COSMIC desktop environment"; description = "Additional wayland-protocols used by the COSMIC desktop environment";
license = [ licenses.mit licenses.gpl3Only ]; license = [ licenses.mit licenses.gpl3Only ];
maintainers = with maintainers; [ nyanbinary ]; maintainers = with maintainers; [ nyanbinary ];
platforms = platforms.linux; platforms = platforms.linux;

View file

@ -8,16 +8,16 @@
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "cosmic-screenshot"; pname = "cosmic-screenshot";
version = "unstable-2023-11-08"; version = "1.0.0-alpha.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "pop-os"; owner = "pop-os";
repo = pname; repo = pname;
rev = "b413a7128ddcdfb3c63e84bdade5c5b90b163a9a"; rev = "epoch-${version}";
hash = "sha256-SDxBBhmnqNDX95Rb7QiI46sAxrfodB5tSq8AbXAU480="; hash = "sha256-+yHpRbK+AWnpcGrC5U0wKbt0u8tm3CFGjKTCDQpb3G0=";
}; };
cargoHash = "sha256-ZRsAhIWPm38Ys9jM/3yVJLW818lUGLCcSfFZb+UTbnU="; cargoHash = "sha256-d56y35npMPrQM0yF0ytNcOdMKBz9IQvEz37DNvKBBSk=";
nativeBuildInputs = [ just pkg-config ]; nativeBuildInputs = [ just pkg-config ];

View file

@ -1,12 +1,12 @@
{ stdenv { stdenv
, fetchFromGitHub , fetchFromGitHub
, fetchpatch , fetchpatch
, applyPatches
, libuuid , libuuid
, bc , bc
, lib , lib
, buildPackages , buildPackages
, nixosTests , nixosTests
, runCommand
, writeScript , writeScript
}: }:
@ -31,45 +31,68 @@ buildType = if stdenv.isDarwin then
else else
"GCC5"; "GCC5";
edk2 = stdenv.mkDerivation rec { edk2 = stdenv.mkDerivation {
pname = "edk2"; pname = "edk2";
version = "202402"; version = "202408";
patches = [
# pass targetPrefix as an env var
(fetchpatch {
url = "https://src.fedoraproject.org/rpms/edk2/raw/08f2354cd280b4ce5a7888aa85cf520e042955c3/f/0021-Tweak-the-tools_def-to-support-cross-compiling.patch";
hash = "sha256-E1/fiFNVx0aB1kOej2DJ2DlBIs9tAAcxoedym2Zhjxw=";
})
# https://github.com/tianocore/edk2/pull/5658
(fetchpatch {
url = "https://github.com/tianocore/edk2/commit/a34ff4a8f69a7b8a52b9b299153a8fac702c7df1.patch";
hash = "sha256-u+niqwjuLV5tNPykW4xhb7PW2XvUmXhx5uvftG1UIbU=";
})
];
srcWithVendoring = fetchFromGitHub { srcWithVendoring = fetchFromGitHub {
owner = "tianocore"; owner = "tianocore";
repo = "edk2"; repo = "edk2";
rev = "edk2-stable${edk2.version}"; rev = "edk2-stable${edk2.version}";
fetchSubmodules = true; fetchSubmodules = true;
hash = "sha256-Nurm6QNKCyV6wvbj0ELdYAL7mbZ0yg/tTwnEJ+N18ng="; hash = "sha256-2odaTqiAZD5xduT0dwIYWj3gY/aFPVsTFbblIsEhBiA=";
}; };
# We don't want EDK2 to keep track of OpenSSL, src = applyPatches {
# they're frankly bad at it. name = "edk2-${edk2.version}-unvendored-src";
src = runCommand "edk2-unvendored-src" { } '' src = edk2.srcWithVendoring;
cp --no-preserve=mode -r ${srcWithVendoring} $out
rm -rf $out/CryptoPkg/Library/OpensslLib/openssl
mkdir -p $out/CryptoPkg/Library/OpensslLib/openssl
tar --strip-components=1 -xf ${buildPackages.openssl.src} -C $out/CryptoPkg/Library/OpensslLib/openssl
chmod -R +w $out/
# Fix missing INT64_MAX include that edk2 explicitly does not provide patches = [
# via it's own <stdint.h>. Let's pull in openssl's definition instead: # pass targetPrefix as an env var
sed -i $out/CryptoPkg/Library/OpensslLib/openssl/crypto/property/property_parse.c \ (fetchpatch {
-e '1i #include "internal/numbers.h"' url = "https://src.fedoraproject.org/rpms/edk2/raw/08f2354cd280b4ce5a7888aa85cf520e042955c3/f/0021-Tweak-the-tools_def-to-support-cross-compiling.patch";
''; hash = "sha256-E1/fiFNVx0aB1kOej2DJ2DlBIs9tAAcxoedym2Zhjxw=";
})
# https://github.com/tianocore/edk2/pull/5658
(fetchpatch {
name = "fix-cross-compilation-antlr-dlg.patch";
url = "https://github.com/tianocore/edk2/commit/a34ff4a8f69a7b8a52b9b299153a8fac702c7df1.patch";
hash = "sha256-u+niqwjuLV5tNPykW4xhb7PW2XvUmXhx5uvftG1UIbU=";
})
];
postPatch = ''
# We don't want EDK2 to keep track of OpenSSL, they're frankly bad at it.
rm -r CryptoPkg/Library/OpensslLib/openssl
mkdir -p CryptoPkg/Library/OpensslLib/openssl
(
cd CryptoPkg/Library/OpensslLib/openssl
tar --strip-components=1 -xf ${buildPackages.openssl.src}
# Apply OpenSSL patches.
${lib.pipe buildPackages.openssl.patches [
(builtins.filter (
patch:
!builtins.elem (baseNameOf patch) [
# Exclude patches not required in this context.
"nix-ssl-cert-file.patch"
"openssl-disable-kernel-detection.patch"
"use-etc-ssl-certs-darwin.patch"
"use-etc-ssl-certs.patch"
]
))
(map (patch: "patch -p1 < ${patch}\n"))
lib.concatStrings
]}
)
# enable compilation using Clang
# https://bugzilla.tianocore.org/show_bug.cgi?id=4620
substituteInPlace BaseTools/Conf/tools_def.template --replace-fail \
'DEFINE CLANGPDB_WARNING_OVERRIDES = ' \
'DEFINE CLANGPDB_WARNING_OVERRIDES = -Wno-unneeded-internal-declaration '
'';
};
nativeBuildInputs = [ pythonEnv ]; nativeBuildInputs = [ pythonEnv ];
depsBuildBuild = [ buildPackages.stdenv.cc buildPackages.bash ]; depsBuildBuild = [ buildPackages.stdenv.cc buildPackages.bash ];
@ -100,12 +123,13 @@ edk2 = stdenv.mkDerivation rec {
enableParallelBuilding = true; enableParallelBuilding = true;
meta = with lib; { meta = {
description = "Intel EFI development kit"; description = "Intel EFI development kit";
homepage = "https://github.com/tianocore/tianocore.github.io/wiki/EDK-II/"; homepage = "https://github.com/tianocore/tianocore.github.io/wiki/EDK-II/";
changelog = "https://github.com/tianocore/edk2/releases/tag/edk2-stable${edk2.version}"; changelog = "https://github.com/tianocore/edk2/releases/tag/edk2-stable${edk2.version}";
license = licenses.bsd2; license = lib.licenses.bsd2;
platforms = with platforms; aarch64 ++ arm ++ i686 ++ x86_64 ++ riscv64; platforms = with lib.platforms; aarch64 ++ arm ++ i686 ++ x86_64 ++ riscv64;
maintainers = [ lib.maintainers.mjoerg ];
}; };
passthru = { passthru = {

View file

@ -122,6 +122,9 @@ rustPlatform.buildRustPackage rec {
withSecretProvisioning = kanidm.override { enableSecretProvisioning = true; }; withSecretProvisioning = kanidm.override { enableSecretProvisioning = true; };
}; };
# can take over 4 hours on 2 cores and needs 16GB+ RAM
requiredSystemFeatures = [ "big-parallel" ];
meta = with lib; { meta = with lib; {
changelog = "https://github.com/kanidm/kanidm/releases/tag/v${version}"; changelog = "https://github.com/kanidm/kanidm/releases/tag/v${version}";
description = "Simple, secure and fast identity management platform"; description = "Simple, secure and fast identity management platform";

View file

@ -48,16 +48,37 @@ stdenv.mkDerivation (finalAttrs: {
patches = [ patches = [
# fix docbook2man version detection # fix docbook2man version detection
./docbook-hack.patch ./docbook-hack.patch
# Fix hardcoded path of lxc-user-nic
# This is needed to use unprivileged containers
./user-nic.diff
]; ];
mesonFlags = [ mesonFlags = [
"-Dinstall-init-files=false" "-Dinstall-init-files=true"
"-Dinstall-state-dirs=false" "-Dinstall-state-dirs=false"
"-Dspecfile=false" "-Dspecfile=false"
"-Dtools-multicall=true" "-Dtools-multicall=true"
"-Dtools=false" "-Dtools=false"
"-Dusernet-config-path=/etc/lxc/lxc-usernet"
"-Ddistrosysconfdir=${placeholder "out"}/etc/lxc"
"-Dsystemd-unitdir=${placeholder "out"}/lib/systemd/system"
]; ];
# /run/current-system/sw/share
postInstall = ''
substituteInPlace $out/etc/lxc/lxc --replace-fail "$out/etc/lxc" "/etc/lxc"
substituteInPlace $out/libexec/lxc/lxc-net --replace-fail "$out/etc/lxc" "/etc/lxc"
substituteInPlace $out/share/lxc/templates/lxc-download --replace-fail "$out/share" "/run/current-system/sw/share"
substituteInPlace $out/share/lxc/templates/lxc-local --replace-fail "$out/share" "/run/current-system/sw/share"
substituteInPlace $out/share/lxc/templates/lxc-oci --replace-fail "$out/share" "/run/current-system/sw/share"
substituteInPlace $out/share/lxc/config/common.conf --replace-fail "$out/share" "/run/current-system/sw/share"
substituteInPlace $out/share/lxc/config/userns.conf --replace-fail "$out/share" "/run/current-system/sw/share"
substituteInPlace $out/share/lxc/config/oci.common.conf --replace-fail "$out/share" "/run/current-system/sw/share"
'';
enableParallelBuilding = true; enableParallelBuilding = true;
doCheck = true; doCheck = true;
@ -66,6 +87,7 @@ stdenv.mkDerivation (finalAttrs: {
tests = { tests = {
incus-legacy-init = nixosTests.incus.container-legacy-init; incus-legacy-init = nixosTests.incus.container-legacy-init;
incus-systemd-init = nixosTests.incus.container-systemd-init; incus-systemd-init = nixosTests.incus.container-systemd-init;
lxc = nixosTests.lxc;
lxd = nixosTests.lxd.container; lxd = nixosTests.lxd.container;
}; };

View file

@ -0,0 +1,13 @@
diff --git a/src/lxc/network.c b/src/lxc/network.c
index 0a99d32..850e975 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -2940,7 +2940,7 @@ int lxc_find_gateway_addresses(struct lxc_handler *handler)
#ifdef IN_LIBLXC
-#define LXC_USERNIC_PATH LIBEXECDIR "/lxc/lxc-user-nic"
+#define LXC_USERNIC_PATH "/run/wrappers/bin/lxc-user-nic"
static int lxc_create_network_unpriv_exec(const char *lxcpath,
const char *lxcname,
struct lxc_netdev *netdev, pid_t pid,

View file

@ -16,13 +16,13 @@
python3Packages.buildPythonApplication rec { python3Packages.buildPythonApplication rec {
pname = "nwg-panel"; pname = "nwg-panel";
version = "0.9.37"; version = "0.9.38";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "nwg-piotr"; owner = "nwg-piotr";
repo = "nwg-panel"; repo = "nwg-panel";
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
hash = "sha256-CKufaOAh7wH2ECN+zsPk4PQNYuewT2BzTci8nt8EhlU="; hash = "sha256-5vq/5QovvoDUDu9IiAeI9c06g0iy9YLi7CdpEhXbLqI=";
}; };
# No tests # No tests

View file

@ -18,15 +18,15 @@ rustPlatform.buildRustPackage rec {
postPatch = '' postPatch = ''
substituteInPlace src/lib.rs \ substituteInPlace src/lib.rs \
--replace '/usr/lib/pop-launcher' "$out/share/pop-launcher" --replace-fail '/usr/lib/pop-launcher' "$out/share/pop-launcher"
substituteInPlace plugins/src/scripts/mod.rs \ substituteInPlace plugins/src/scripts/mod.rs \
--replace '/usr/lib/pop-launcher' "$out/share/pop-launcher" --replace-fail '/usr/lib/pop-launcher' "$out/share/pop-launcher"
substituteInPlace plugins/src/calc/mod.rs \ substituteInPlace plugins/src/calc/mod.rs \
--replace 'Command::new("qalc")' 'Command::new("${libqalculate}/bin/qalc")' --replace-fail 'Command::new("qalc")' 'Command::new("${libqalculate}/bin/qalc")'
substituteInPlace plugins/src/find/mod.rs \ substituteInPlace plugins/src/find/mod.rs \
--replace 'spawn("fd")' 'spawn("${fd}/bin/fd")' --replace-fail 'spawn("fd")' 'spawn("${fd}/bin/fd")'
substituteInPlace plugins/src/terminal/mod.rs \ substituteInPlace plugins/src/terminal/mod.rs \
--replace '/usr/bin/gnome-terminal' 'gnome-terminal' --replace-fail '/usr/bin/gnome-terminal' 'gnome-terminal'
''; '';
cargoHash = "sha256-cTvrq0fH057UIx/O9u8zHMsg+psMGg1q9klV5OMxtok="; cargoHash = "sha256-cTvrq0fH057UIx/O9u8zHMsg+psMGg1q9klV5OMxtok=";

View file

@ -0,0 +1,81 @@
{
appstream,
appstream-glib,
desktop-file-utils,
fetchFromGitHub,
gettext,
gobject-introspection,
gtk4,
gtksourceview5,
lib,
libadwaita,
libportal,
librsvg,
meson,
ninja,
poppler_gi,
python3Packages,
webkitgtk_6_0,
wrapGAppsHook4,
}:
python3Packages.buildPythonApplication rec {
pname = "setzer";
version = "66";
pyproject = false;
src = fetchFromGitHub {
owner = "cvfosammmm";
repo = "Setzer";
rev = "refs/tags/v${version}";
hash = "sha256-hqwwDR9jCk2XptcqpaReZ73jqpq4JpYD3Rc2OmrEPxg=";
};
nativeBuildInputs = [
meson
ninja
gettext
appstream # for appstreamcli
appstream-glib
wrapGAppsHook4
desktop-file-utils
gobject-introspection
];
buildInputs = [
gtk4
gtksourceview5
libadwaita
libportal
librsvg
poppler_gi
webkitgtk_6_0
];
dependencies = with python3Packages; [
bibtexparser
numpy
pdfminer-six
pexpect
pillow
pycairo
pygobject3
pyxdg
];
checkPhase = ''
runHook preCheck
meson test --print-errorlogs
runHook postCheck
'';
meta = {
description = "LaTeX editor written in Python with Gtk";
mainProgram = "setzer";
homepage = "https://www.cvfosammmm.org/setzer/";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ dotlambda ];
};
}

View file

@ -7,13 +7,13 @@
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
pname = "uxn"; pname = "uxn";
version = "1.0-unstable-2024-08-12"; version = "1.0-unstable-2024-08-25";
src = fetchFromSourcehut { src = fetchFromSourcehut {
owner = "~rabbits"; owner = "~rabbits";
repo = "uxn"; repo = "uxn";
rev = "3a901ed0beeaf5e3268a40779f2944ef99f93774"; rev = "6d5e3848bdbd76420b93ca47de148cbf46baf9f6";
hash = "sha256-JlDNiKcaZG2OYeiVlIovEIDN/h7ET5d0M83vlHMQQK4="; hash = "sha256-YTDL3NZSjbVqu6aPJBmUmsT3bDX2VUeufXq/Q+jn4Og=";
}; };
outputs = [ "out" "projects" ]; outputs = [ "out" "projects" ];

View file

@ -39,13 +39,13 @@
stdenv.mkDerivation (finalPackages: { stdenv.mkDerivation (finalPackages: {
pname = "xarcan"; pname = "xarcan";
version = "0-unstable-2024-08-04"; version = "0-unstable-2024-08-26";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "letoram"; owner = "letoram";
repo = "xarcan"; repo = "xarcan";
rev = "7644616b3bd0ff2b5708e93acc990cd757b20ae9"; rev = "5672116f627de492fb4df0b33d36b78041cd3931";
hash = "sha256-iKYTuJ/1iwm449ZOBOzi+LkrTTio7aaIHUn+M+Sbzc8="; hash = "sha256-xZX6uLs/H/wONKrUnYxSynHK7CL7FDfzWvSjtXxT8es=";
}; };
nativeBuildInputs = [ nativeBuildInputs = [

View file

@ -16,6 +16,7 @@ let
"12.1" = "12.1.1"; "12.1" = "12.1.1";
"12.2" = "12.2.2"; "12.2" = "12.2.2";
"12.3" = "12.3.0"; "12.3" = "12.3.0";
"12.4" = "12.4.0";
}; };
# Check if the current CUDA version is supported. # Check if the current CUDA version is supported.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -105,4 +105,10 @@
url = "https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda_12.3.0_545.23.06_linux.run"; url = "https://developer.download.nvidia.com/compute/cuda/12.3.0/local_installers/cuda_12.3.0_545.23.06_linux.run";
sha256 = "sha256-fBP6zjr2TW4WSNbjEB0xyBEedHFDrLAHfZc8FpCCBCI="; sha256 = "sha256-fBP6zjr2TW4WSNbjEB0xyBEedHFDrLAHfZc8FpCCBCI=";
}; };
"12.4" = {
version = "12.4.0";
url = "https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run";
sha256 = "sha256-5qhC9OypSQV1zbaLaxu3jUe5Wol95I3uKSxDGJLlfRc=";
};
} }

View file

@ -11,6 +11,13 @@
url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-aarch64/cudnn-linux-aarch64-8.9.5.30_cuda12-archive.tar.xz"; url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-aarch64/cudnn-linux-aarch64-8.9.5.30_cuda12-archive.tar.xz";
hash = "sha256-BJH3sC9VwiB362eL8xTB+RdSS9UHz1tlgjm/mKRyM6E="; hash = "sha256-BJH3sC9VwiB362eL8xTB+RdSS9UHz1tlgjm/mKRyM6E=";
} }
{
version = "9.3.0.75";
minCudaVersion = "12.0";
maxCudaVersion = "12.6";
url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-aarch64/cudnn-linux-aarch64-9.3.0.75_cuda12-archive.tar.xz";
hash = "sha256-Gq5L/O1j+TC0Z3+eko4ZeHjezi7dUcqPp6uDY9Dm7WA=";
}
]; ];
# powerpc # powerpc
linux-ppc64le = [ ]; linux-ppc64le = [ ];
@ -72,6 +79,20 @@
url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/cudnn-linux-sbsa-8.9.7.29_cuda12-archive.tar.xz"; url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/cudnn-linux-sbsa-8.9.7.29_cuda12-archive.tar.xz";
hash = "sha256-6Yt8gAEHheXVygHuTOm1sMjHNYfqb4ZIvjTT+NHUe9E="; hash = "sha256-6Yt8gAEHheXVygHuTOm1sMjHNYfqb4ZIvjTT+NHUe9E=";
} }
{
version = "9.3.0.75";
minCudaVersion = "12.0";
maxCudaVersion = "12.6";
url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/cudnn-linux-sbsa-9.3.0.75_cuda12-archive.tar.xz";
hash = "sha256-Eibdm5iciYY4VSlj0ACjz7uKCgy5uvjLCear137X1jk=";
}
{
version = "9.3.0.75";
minCudaVersion = "11.8";
maxCudaVersion = "11.8";
url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-sbsa/cudnn-linux-sbsa-9.3.0.75_cuda11-archive.tar.xz";
hash = "sha256-BLVvv3vuFcJOM5wrqU0Xqoi54zTQzRnnWFPcVFJ5S/c=";
}
]; ];
# x86_64 # x86_64
linux-x86_64 = [ linux-x86_64 = [

View file

@ -119,6 +119,12 @@ let
# No changes from 12.2 to 12.3 # No changes from 12.2 to 12.3
"12.3" = attrs."12.2"; "12.3" = attrs."12.2";
# No changes from 12.2 to 12.3
"12.4" = attrs."12.3" // {
clangMaxMajorVersion = "17";
gccMaxMajorVersion = "13";
};
}; };
in in
attrs attrs

View file

@ -0,0 +1,38 @@
{
buildPythonPackage,
fetchFromGitHub,
lib,
pytestCheckHook,
setuptools,
}:
buildPythonPackage rec {
pname = "curio-compat";
version = "1.6.7";
pyproject = true;
src = fetchFromGitHub {
owner = "klen";
repo = "curio";
rev = "refs/tags/${version}";
hash = "sha256-Crd9r4Icwga85wvtXaePbE56R192o+FXU9Zn+Lc7trI=";
};
build-system = [ setuptools ];
pythonImportsCheck = [ "curio" ];
nativeCheckInputs = [ pytestCheckHook ];
disabledTests = [
# contacts google.com
"test_ssl_outgoing"
];
meta = {
description = "Coroutine-based library for concurrent systems programming";
homepage = "https://github.com/klen/curio";
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ dotlambda ];
};
}

View file

@ -0,0 +1,41 @@
{
buildPythonPackage,
fetchFromGitHub,
idasen,
lib,
pytest-asyncio,
pytestCheckHook,
setuptools,
}:
buildPythonPackage rec {
pname = "idasen-ha";
version = "2.6.2";
pyproject = true;
src = fetchFromGitHub {
owner = "abmantis";
repo = "idasen-ha";
rev = "refs/tags/${version}";
hash = "sha256-lqqSx4jxQVq2pjVv9lvaX6nNK6OqtMjPqOtLMLpVMUU=";
};
build-system = [ setuptools ];
dependencies = [ idasen ];
pythonImportsCheck = [ "idasen_ha" ];
nativeCheckInputs = [
pytest-asyncio
pytestCheckHook
];
meta = {
changelog = "https://github.com/abmantis/idasen-ha/releases/tag/${version}";
description = "Home Assistant helper lib for the IKEA Idasen Desk integration";
homepage = "https://github.com/abmantis/idasen-ha";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ dotlambda ];
};
}

View file

@ -14,7 +14,7 @@
buildPythonPackage rec { buildPythonPackage rec {
pname = "idasen"; pname = "idasen";
version = "0.12.0"; version = "0.12.0";
format = "pyproject"; pyproject = true;
disabled = pythonOlder "3.8"; disabled = pythonOlder "3.8";
@ -25,9 +25,9 @@ buildPythonPackage rec {
hash = "sha256-TQ+DBFpG+IeZ4/dN+YKMw3AM4Dl1rpqA1kRcb3Tb3jA="; hash = "sha256-TQ+DBFpG+IeZ4/dN+YKMw3AM4Dl1rpqA1kRcb3Tb3jA=";
}; };
nativeBuildInputs = [ poetry-core ]; build-system = [ poetry-core ];
propagatedBuildInputs = [ dependencies = [
bleak bleak
pyyaml pyyaml
voluptuous voluptuous

View file

@ -24,14 +24,14 @@
buildPythonPackage rec { buildPythonPackage rec {
pname = "marimo"; pname = "marimo";
version = "0.7.20"; version = "0.8.3";
pyproject = true; pyproject = true;
disabled = pythonOlder "3.8"; disabled = pythonOlder "3.8";
src = fetchPypi { src = fetchPypi {
inherit pname version; inherit pname version;
hash = "sha256-vkEBHJN7VqJU+diijiTV7JABT5g/5NY2XEXM0turDWU="; hash = "sha256-t7VYKInsZ0hYW+svD0vnsMyGcMtIeuWaor8nijyDhn8=";
}; };
build-system = [ setuptools ]; build-system = [ setuptools ];

View file

@ -1,34 +1,31 @@
{ {
lib, lib,
stdenv, stdenv,
darwin,
ocl-icd,
buildPythonPackage,
fetchFromGitHub, fetchFromGitHub,
buildPythonPackage,
# build-system # build-system
cmake, cmake,
nanobind,
ninja,
numpy,
pathspec,
scikit-build-core, scikit-build-core,
pathspec,
# buildInputs ninja,
opencl-headers, nanobind,
pybind11,
# dependencies # dependencies
darwin,
numpy,
ocl-icd,
opencl-headers,
platformdirs, platformdirs,
pybind11,
pytools, pytools,
# checks # tests
pytestCheckHook, pytestCheckHook,
}: }:
let let
os-specific-buildInputs = os-specific-buildInputs = if stdenv.isDarwin then [ darwin.apple_sdk.frameworks.OpenCL ] else [ ocl-icd ];
if stdenv.isDarwin then [ darwin.apple_sdk.frameworks.OpenCL ] else [ ocl-icd ];
in in
buildPythonPackage rec { buildPythonPackage rec {
pname = "pyopencl"; pname = "pyopencl";
@ -39,7 +36,8 @@ buildPythonPackage rec {
owner = "inducer"; owner = "inducer";
repo = "pyopencl"; repo = "pyopencl";
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
hash = "sha256-DfZCtTeN1a1KS2qUU6iztba4opAVC/RUCe/hnkqTbII="; fetchSubmodules = true;
hash = "sha256-VeaEDYnGfMYf9/WqMIZ9g4KounD48eWF3Romt79RMEQ=";
}; };
build-system = [ build-system = [
@ -66,23 +64,28 @@ buildPythonPackage rec {
nativeCheckInputs = [ pytestCheckHook ]; nativeCheckInputs = [ pytestCheckHook ];
preBuild = '' preCheck = ''
export HOME=$(mktemp -d) export HOME=$(mktemp -d)
rm -rf pyopencl
# import from $out
rm -r pyopencl
''; '';
# gcc: error: pygpu_language_opencl.cpp: No such file or directory # pyopencl._cl.LogicError: clGetPlatformIDs failed: PLATFORM_NOT_FOUND_KHR
doCheck = false; doCheck = false;
pythonImportsCheck = [ "pyopencl" ]; pythonImportsCheck = [
"pyopencl"
"pyopencl.array"
"pyopencl.cltypes"
"pyopencl.elementwise"
"pyopencl.tools"
];
meta = { meta = with lib; {
description = "Python wrapper for OpenCL";
homepage = "https://github.com/pyopencl/pyopencl";
changelog = "https://github.com/inducer/pyopencl/releases/tag/v${version}"; changelog = "https://github.com/inducer/pyopencl/releases/tag/v${version}";
license = lib.licenses.mit; description = "Python wrapper for OpenCL";
maintainers = with lib.maintainers; [ GaetanLepage ]; homepage = "https://github.com/inducer/pyopencl";
# ld: symbol(s) not found for architecture arm64 license = licenses.mit;
broken = stdenv.isDarwin && stdenv.isAarch64;
}; };
} }

View file

@ -2,16 +2,16 @@
lib, lib,
anyio, anyio,
buildPythonPackage, buildPythonPackage,
curio, curio-compat,
fetchFromGitHub, fetchFromGitHub,
hypothesis, hypothesis,
pytest, pytest,
pytestCheckHook, pytestCheckHook,
pythonOlder, pythonOlder,
poetry-core, poetry-core,
sniffio,
trio, trio,
trio-asyncio, trio-asyncio,
uvloop,
}: }:
buildPythonPackage rec { buildPythonPackage rec {
@ -19,7 +19,7 @@ buildPythonPackage rec {
version = "1.9.0"; version = "1.9.0";
pyproject = true; pyproject = true;
disabled = pythonOlder "3.7"; disabled = pythonOlder "3.9";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "klen"; owner = "klen";
@ -32,16 +32,18 @@ buildPythonPackage rec {
buildInputs = [ pytest ]; buildInputs = [ pytest ];
dependencies = [ optional-dependencies = {
anyio curio = [ curio-compat ];
curio trio = [ trio ];
hypothesis uvloop = [ uvloop ];
sniffio };
trio
trio-asyncio
];
nativeCheckInputs = [ pytestCheckHook ]; nativeCheckInputs = [
anyio
hypothesis
pytestCheckHook
trio-asyncio
] ++ lib.flatten (lib.attrValues optional-dependencies);
pythonImportsCheck = [ "pytest_aio" ]; pythonImportsCheck = [ "pytest_aio" ];

View file

@ -5,11 +5,16 @@
fetchFromGitHub, fetchFromGitHub,
hatchling, hatchling,
aiohttp, aiohttp,
mashumaro,
aioresponses,
pytest-aio,
pytestCheckHook,
syrupy,
}: }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "solarlog-cli"; pname = "solarlog-cli";
version = "0.1.6"; version = "0.2.0";
pyproject = true; pyproject = true;
disabled = pythonOlder "3.12"; disabled = pythonOlder "3.12";
@ -18,17 +23,24 @@ buildPythonPackage rec {
owner = "dontinelli"; owner = "dontinelli";
repo = "solarlog_cli"; repo = "solarlog_cli";
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
hash = "sha256-Bliq1n6xH0cZQHueiGDyalIo0zms8zCSpUGq2KH5xZY="; hash = "sha256-x9MovIKFImu60Ns2sJTy71S22cR9Az/yNMWzGM50y7Y=";
}; };
build-system = [ hatchling ]; build-system = [ hatchling ];
dependencies = [ aiohttp ]; dependencies = [
aiohttp
mashumaro
];
pythonImportsCheck = [ "solarlog_cli" ]; pythonImportsCheck = [ "solarlog_cli" ];
# upstream has no tests nativeCheckInputs = [
doCheck = false; aioresponses
pytest-aio
pytestCheckHook
syrupy
];
meta = { meta = {
changelog = "https://github.com/dontinelli/solarlog_cli/releases/tag/v${version}"; changelog = "https://github.com/dontinelli/solarlog_cli/releases/tag/v${version}";

View file

@ -5,30 +5,27 @@
python, python,
poetry-core, poetry-core,
pytest, pytest,
colored,
invoke, invoke,
}: }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "syrupy"; pname = "syrupy";
version = "4.6.1"; version = "4.7.1";
format = "pyproject"; pyproject = true;
disabled = lib.versionOlder python.version "3.8.1"; disabled = lib.versionOlder python.version "3.8.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "tophat"; owner = "syrupy-project";
repo = "syrupy"; repo = "syrupy";
rev = "refs/tags/v${version}"; rev = "refs/tags/v${version}";
hash = "sha256-NBJJqQsZqqKHOdqGa/j/2KQvlenLCEJBqlfdjtFK00U="; hash = "sha256-dTUugNqzaMuKV6ZwxRSf9df7tsnmZUBhgqwgGxBhirw=";
}; };
nativeBuildInputs = [ poetry-core ]; build-system = [ poetry-core ];
buildInputs = [ pytest ]; buildInputs = [ pytest ];
propagatedBuildInputs = [ colored ];
nativeCheckInputs = [ nativeCheckInputs = [
invoke invoke
pytest pytest
@ -43,11 +40,11 @@ buildPythonPackage rec {
pythonImportsCheck = [ "syrupy" ]; pythonImportsCheck = [ "syrupy" ];
meta = with lib; { meta = {
changelog = "https://github.com/tophat/syrupy/releases/tag/v${version}"; changelog = "https://github.com/syrupy-project/syrupy/blob/${src.rev}/CHANGELOG.md";
description = "Pytest Snapshot Test Utility"; description = "Pytest Snapshot Test Utility";
homepage = "https://github.com/tophat/syrupy"; homepage = "https://github.com/syrupy-project/syrupy";
license = licenses.asl20; license = lib.licenses.asl20;
maintainers = [ ]; maintainers = with lib.maintainers; [ dotlambda ];
}; };
} }

View file

@ -27,9 +27,9 @@ dependencies = [
[[package]] [[package]]
name = "anstyle" name = "anstyle"
version = "1.0.6" version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
[[package]] [[package]]
name = "anstyle-parse" name = "anstyle-parse"
@ -73,9 +73,9 @@ checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69"
[[package]] [[package]]
name = "aya-rustc-llvm-proxy" name = "aya-rustc-llvm-proxy"
version = "0.9.2" version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09de71afbd6668d1e10f1895f967d5a2c02b2e6db01ea4ac9677c29e22dac548" checksum = "3c81d599ae18f5a5fdf5e3e13e376c142a6e2c3d4d5ee960e50e61b034ada46b"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cargo_metadata", "cargo_metadata",
@ -103,7 +103,7 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]] [[package]]
name = "bpf-linker" name = "bpf-linker"
version = "0.9.12" version = "0.9.13"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ar", "ar",
@ -170,9 +170,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.5.11" version = "4.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -180,9 +180,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.5.11" version = "4.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -192,9 +192,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_derive" name = "clap_derive"
version = "4.5.11" version = "4.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",
@ -447,9 +447,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]] [[package]]
name = "llvm-sys" name = "llvm-sys"
version = "180.0.0" version = "191.0.0-rc1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "778fa5fa02e32728e718f11eec147e6f134137399ab02fd2c13d32476337affa" checksum = "fc981f56df5430a462d0f7676913fe9e8e4c8cc4df02e3157a6e3d808f7ae443"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cc", "cc",
@ -598,9 +598,9 @@ dependencies = [
[[package]] [[package]]
name = "regex" name = "regex"
version = "1.10.5" version = "1.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"memchr", "memchr",
@ -648,9 +648,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
[[package]] [[package]]
name = "rustc-build-sysroot" name = "rustc-build-sysroot"
version = "0.5.2" version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa3ca63cc537c1cb69e4c2c0afc5fda2ccd36ac84c97d5a4ae05e69b1c834afb" checksum = "2471f8f296262437d7e848e527b4210b44a96e53a3b4435b890227ce3e6da106"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"rustc_version", "rustc_version",
@ -1015,9 +1015,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]] [[package]]
name = "which" name = "which"
version = "6.0.1" version = "6.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" checksum = "3d9c5ed668ee1f17edb3b627225343d210006a90bb1e3745ce1f30b1fb115075"
dependencies = [ dependencies = [
"either", "either",
"home", "home",

View file

@ -2,7 +2,7 @@
, stdenv , stdenv
, rustPlatform , rustPlatform
, fetchFromGitHub , fetchFromGitHub
, llvmPackages_18 , llvmPackages_19
, zlib , zlib
, ncurses , ncurses
, libxml2 , libxml2
@ -10,13 +10,13 @@
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "bpf-linker"; pname = "bpf-linker";
version = "0.9.12-unstable-2024-07-31"; version = "0.9.13";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "aya-rs"; owner = "aya-rs";
repo = pname; repo = pname;
rev = "7585ff7c0709bae13f2ad25f421450d493b02c1a"; rev = "refs/tags/v${version}";
hash = "sha256-HvjS+74ZjyhF3h2IaKq4T+aGB5/XJRR3TxLSxp0rEYk="; hash = "sha256-CRYp1ktmmY4OS23+LNKOBQJUMkd+GXptBp5LPfbyZAc=";
}; };
cargoLock = { cargoLock = {
@ -28,7 +28,7 @@ rustPlatform.buildRustPackage rec {
buildNoDefaultFeatures = true; buildNoDefaultFeatures = true;
nativeBuildInputs = [ llvmPackages_18.llvm ]; nativeBuildInputs = [ llvmPackages_19.llvm ];
buildInputs = [ zlib ncurses libxml2 ]; buildInputs = [ zlib ncurses libxml2 ];
# fails with: couldn't find crate `core` with expected target triple bpfel-unknown-none # fails with: couldn't find crate `core` with expected target triple bpfel-unknown-none

View file

@ -2,16 +2,16 @@
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "typos"; pname = "typos";
version = "1.23.7"; version = "1.24.1";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "crate-ci"; owner = "crate-ci";
repo = pname; repo = pname;
rev = "v${version}"; rev = "v${version}";
hash = "sha256-VxmSYqpKtzPaiKuB3lhjYGi2T1W4VFt2414OUDGUaZI="; hash = "sha256-oQy3R9PSM8jU4qs3clxK0HmmM0Ua4pwZYxnu0d6SW+I=";
}; };
cargoHash = "sha256-SdHlejMxoh8B/HkOdOAtEIRGKfWYDIKXw7SL80sxvJw="; cargoHash = "sha256-z2JN5JyUIEeZInw5qpRf/Zja+7Np9YnBj3hcohFkAsc=";
meta = with lib; { meta = with lib; {
description = "Source code spell checker"; description = "Source code spell checker";

View file

@ -1,70 +1,91 @@
{ lib, stdenv, fetchurl, kernel }: {
lib,
stdenv,
fetchurl,
fetchFromGitHub,
kernel,
}:
let let
version = "6.30.223.271"; version = "6.30.223.271";
hashes = { hashes = {
i686-linux = "1kaqa2dw3nb8k23ffvx46g8jj3wdhz8xa6jp1v3wb35cjfr712sg"; i686-linux = "sha256-T4twspOsjMXHDlca1dGHjQ8p0TOkb+eGmGjZwZtQWM0=";
x86_64-linux = "1gj485qqr190idilacpxwgqyw21il03zph2rddizgj7fbd6pfyaz"; x86_64-linux = "sha256-X3l3TVvuyPdja1nA+wegMQju8eP9MkVjiyCFjHFBRL4=";
}; };
arch = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "_64"; arch = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux") "_64";
tarballVersion = lib.replaceStrings ["."] ["_"] version; tarballVersion = lib.replaceStrings [ "." ] [ "_" ] version;
tarball = "hybrid-v35${arch}-nodebug-pcoem-${tarballVersion}.tar.gz"; tarball = "hybrid-v35${arch}-nodebug-pcoem-${tarballVersion}.tar.gz";
rpmFusionPatches = fetchFromGitHub {
owner = "rpmfusion";
repo = "wl-kmod";
rev = "a04330284bfc38fd91eade6f8b28fa63cfcdc95e";
hash = "sha256-c72Pr/v+nxZPLEeNKbWnSpbH3gqYZaTgzMO9PlYQkf0=";
};
patchset = [
"wl-kmod-001_wext_workaround.patch"
"wl-kmod-002_kernel_3.18_null_pointer.patch"
"wl-kmod-003_gcc_4.9_remove_TIME_DATE_macros.patch"
"wl-kmod-004_kernel_4.3_rdtscl_to_rdtsc.patch"
"wl-kmod-005_kernel_4.7_IEEE80211_BAND_to_NL80211_BAND.patch"
"wl-kmod-006_gcc_6_fix_indentation_warnings.patch"
"wl-kmod-007_kernel_4.8_add_cfg80211_scan_info_struct.patch"
"wl-kmod-008_fix_kernel_warnings.patch"
"wl-kmod-009_kernel_4.11_remove_last_rx_in_net_device_struct.patch"
"wl-kmod-010_kernel_4.12_add_cfg80211_roam_info_struct.patch"
"wl-kmod-011_kernel_4.14_new_kernel_read_function_prototype.patch"
"wl-kmod-012_kernel_4.15_new_timer.patch"
"wl-kmod-013_gcc8_fix_bounds_check_warnings.patch"
"wl-kmod-014_kernel_read_pos_increment_fix.patch"
"wl-kmod-015_kernel_5.1_get_ds_removed.patch"
"wl-kmod-016_fix_unsupported_mesh_point.patch"
"wl-kmod-017_fix_gcc_fallthrough_warning.patch"
"wl-kmod-018_kernel_5.6_adaptations.patch"
"wl-kmod-019_kernel_5.9_segment_eq_removed.patch"
"wl-kmod-020_kernel_5.10_get_set_fs_removed.patch"
"wl-kmod-021_kernel_5.17_adaptation.patch"
"wl-kmod-022_kernel_5.18_adaptation.patch"
"wl-kmod-023_kernel_6.0_adaptation.patch"
"wl-kmod-024_kernel_6.1_adaptation.patch"
"wl-kmod-025_kernel_6.5_adaptation.patch"
"wl-kmod-026_kernel_6.10_fix_empty_body_in_if_warning.patch"
"wl-kmod-027_wpa_supplicant-2.11_add_max_scan_ie_len.patch"
];
in in
stdenv.mkDerivation { stdenv.mkDerivation {
name = "broadcom-sta-${version}-${kernel.version}"; name = "broadcom-sta-${version}-${kernel.version}";
src = fetchurl { src = fetchurl {
url = "https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/${tarball}"; url = "https://docs.broadcom.com/docs-and-downloads/docs/linux_sta/${tarball}";
sha256 = hashes.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); hash =
hashes.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
}; };
hardeningDisable = [ "pic" ]; hardeningDisable = [ "pic" ];
nativeBuildInputs = kernel.moduleBuildDependencies; nativeBuildInputs = kernel.moduleBuildDependencies;
patches = [ patches = map (patch: "${rpmFusionPatches}/${patch}") patchset;
./license.patch
./linux-4.7.patch
# source: https://git.archlinux.org/svntogit/community.git/tree/trunk/004-linux48.patch?h=packages/broadcom-wl-dkms
./linux-4.8.patch
# source: https://aur.archlinux.org/cgit/aur.git/tree/linux411.patch?h=broadcom-wl
./linux-4.11.patch
# source: https://aur.archlinux.org/cgit/aur.git/tree/linux412.patch?h=broadcom-wl
./linux-4.12.patch
./linux-4.15.patch
./linux-5.1.patch
# source: https://salsa.debian.org/Herrie82-guest/broadcom-sta/-/commit/247307926e5540ad574a17c062c8da76990d056f
./linux-5.6.patch
# source: https://gist.github.com/joanbm/5c640ac074d27fd1d82c74a5b67a1290
./linux-5.9.patch
# source: https://github.com/archlinux/svntogit-community/blob/33b4bd2b9e30679b03f5d7aa2741911d914dcf94/trunk/012-linux517.patch
./linux-5.17.patch
# source: https://github.com/archlinux/svntogit-community/blob/2e1fd240f9ce06f500feeaa3e4a9675e65e6b967/trunk/013-linux518.patch
./linux-5.18.patch
# source: https://gist.github.com/joanbm/207210d74637870c01ef5a3c262a597d
./linux-6.0.patch
# source: https://gist.github.com/joanbm/94323ea99eff1e1d1c51241b5b651549
./linux-6.1.patch
./pedantic-fix.patch
./null-pointer-fix.patch
./gcc.patch
];
makeFlags = [ "KBASE=${kernel.dev}/lib/modules/${kernel.modDirVersion}" ]; makeFlags = [ "KBASE=${kernel.dev}/lib/modules/${kernel.modDirVersion}" ];
unpackPhase = '' unpackPhase = ''
runHook preUnpack
sourceRoot=broadcom-sta sourceRoot=broadcom-sta
mkdir "$sourceRoot" mkdir "$sourceRoot"
tar xvf "$src" -C "$sourceRoot" tar xvf "$src" -C "$sourceRoot"
runHook postUnpack
''; '';
installPhase = '' installPhase = ''
runHook preInstall
binDir="$out/lib/modules/${kernel.modDirVersion}/kernel/net/wireless/" binDir="$out/lib/modules/${kernel.modDirVersion}/kernel/net/wireless/"
docDir="$out/share/doc/broadcom-sta/" docDir="$out/share/doc/broadcom-sta/"
mkdir -p "$binDir" "$docDir" mkdir -p "$binDir" "$docDir"
cp wl.ko "$binDir" cp wl.ko "$binDir"
cp lib/LICENSE.txt "$docDir" cp lib/LICENSE.txt "$docDir"
runHook postInstall
''; '';
meta = { meta = {

View file

@ -1,28 +0,0 @@
From 3e28c2a24c3b3b011506bcaa4fee7e8da347c5ff Mon Sep 17 00:00:00 2001
From: Charles Strahan <charles.c.strahan@gmail.com>
Date: Tue, 5 May 2015 15:09:51 -0400
Subject: [PATCH 01/16] linuxPackages.broadcom_sta: since GCC respects
SOURCE_DATE_EPOCH, set in the stdenv, set -Wno-date-time
---
Makefile | 3 ---
1 file changed, 3 deletions(-)
diff --git a/Makefile b/Makefile
index a323a0d..15e85c8 100644
--- a/Makefile
+++ b/Makefile
@@ -140,10 +140,7 @@ wl-objs += src/wl/sys/wl_cfg80211_hybrid.o
EXTRA_CFLAGS += -I$(src)/src/include -I$(src)/src/common/include
EXTRA_CFLAGS += -I$(src)/src/wl/sys -I$(src)/src/wl/phy -I$(src)/src/wl/ppr/include
EXTRA_CFLAGS += -I$(src)/src/shared/bcmwifi/include
-#EXTRA_CFLAGS += -DBCMDBG_ASSERT -DBCMDBG_ERR
-ifeq "$(GE_49)" "1"
EXTRA_CFLAGS += -Wno-date-time
-endif
EXTRA_LDFLAGS := $(src)/lib/wlc_hybrid.o_shipped
--
2.45.1

View file

@ -1,26 +0,0 @@
From 5a964e14474e4482a4d24c015371856560dacabc Mon Sep 17 00:00:00 2001
From: Shea Levy <shea@shealevy.com>
Date: Sat, 4 Jan 2014 20:57:21 -0500
Subject: [PATCH 02/16] linuxPackages.broadcom_sta: apply MIXED/Proprietary
license
---
src/wl/sys/wl_linux.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 0d05100..14922c0 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -148,6 +148,8 @@ static struct wl_if *wl_alloc_if(wl_info_t *wl, int iftype, uint unit, struct wl
static void wl_free_if(wl_info_t *wl, wl_if_t *wlif);
static void wl_get_driver_info(struct net_device *dev, struct ethtool_drvinfo *info);
+MODULE_LICENSE("MIXED/Proprietary");
+
#if defined(WL_CONFIG_RFKILL)
#include <linux/rfkill.h>
static int wl_init_rfkill(wl_info_t *wl);
--
2.45.1

View file

@ -1,65 +0,0 @@
From 5a0301c2d9c65dbb3c5b8990e635d37f071d26c4 Mon Sep 17 00:00:00 2001
From: georgewhewell <georgerw@gmail.com>
Date: Fri, 2 Jun 2017 14:19:04 +0100
Subject: [PATCH 06/16] linuxPackages.broadcom_sta: fix build for kernel 4.11+
---
src/wl/sys/wl_cfg80211_hybrid.c | 3 +++
src/wl/sys/wl_linux.c | 12 ++++++++++++
2 files changed, 15 insertions(+)
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 84f0068..9fd8ed1 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -30,6 +30,9 @@
#include <linux/kthread.h>
#include <linux/netdevice.h>
#include <linux/ieee80211.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+#include <linux/sched/signal.h>
+#endif
#include <net/cfg80211.h>
#include <linux/nl80211.h>
#include <net/rtnetlink.h>
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 65d7a22..18841d9 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -117,6 +117,9 @@ int wl_found = 0;
typedef struct priv_link {
wl_if_t *wlif;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+ unsigned long last_rx;
+#endif
} priv_link_t;
#define WL_DEV_IF(dev) ((wl_if_t*)((priv_link_t*)DEV_PRIV(dev))->wlif)
@@ -2451,6 +2454,9 @@ wl_monitor(wl_info_t *wl, wl_rxsts_t *rxsts, void *p)
{
struct sk_buff *oskb = (struct sk_buff *)p;
struct sk_buff *skb;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+ priv_link_t *priv_link;
+#endif
uchar *pdata;
uint len;
@@ -2917,7 +2923,13 @@ wl_monitor(wl_info_t *wl, wl_rxsts_t *rxsts, void *p)
if (skb == NULL) return;
skb->dev = wl->monitor_dev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+ priv_link = MALLOC(wl->osh, sizeof(priv_link_t));
+ priv_link = netdev_priv(skb->dev);
+ priv_link->last_rx = jiffies;
+#else
skb->dev->last_rx = jiffies;
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22)
skb_reset_mac_header(skb);
#else
--
2.45.1

View file

@ -1,92 +0,0 @@
From 2e9c7bd146fbc3b4a62940140eafb47df16b6cb4 Mon Sep 17 00:00:00 2001
From: aszlig <aszlig@redmoonstudios.org>
Date: Tue, 18 Jul 2017 21:32:13 +0200
Subject: [PATCH 07/16] linuxPackages.broadcom_sta: fix build for kernel 4.12+
The patch is from Arch Linux at:
https://aur.archlinux.org/cgit/aur.git/tree/linux412.patch?h=broadcom-wl
Tested this by building against the following attributes:
* linuxPackages.broadcom_sta
* linuxPackages_latest.broadcom_sta
* pkgsI686Linux.linuxPackages.broadcom_sta
* pkgsI686Linux.linuxPackages_latest.broadcom_sta
I have not tested whether this works at runtime, because I do not possess the hardware.
---
src/wl/sys/wl_cfg80211_hybrid.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 9fd8ed1..1893a53 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -53,7 +53,11 @@ u32 wl_dbg_level = WL_DBG_ERR;
#endif
static s32 wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+ enum nl80211_iftype type, struct vif_params *params);
+#else
enum nl80211_iftype type, u32 *flags, struct vif_params *params);
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
static s32
wl_cfg80211_scan(struct wiphy *wiphy,
@@ -466,7 +470,11 @@ wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
static s32
wl_cfg80211_change_iface(struct wiphy *wiphy, struct net_device *ndev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+ enum nl80211_iftype type,
+#else
enum nl80211_iftype type, u32 *flags,
+#endif
struct vif_params *params)
{
struct wl_cfg80211_priv *wl = wiphy_to_wl(wiphy);
@@ -2361,6 +2369,20 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
const wl_event_msg_t *e, void *data)
{
struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+ struct cfg80211_bss *bss;
+ struct wlc_ssid *ssid;
+ ssid = &wl->profile->ssid;
+ bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
+ ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
+ struct cfg80211_roam_info roam_info = {
+ .bss = bss,
+ .req_ie = conn_info->req_ie,
+ .req_ie_len = conn_info->req_ie_len,
+ .resp_ie = conn_info->resp_ie,
+ .resp_ie_len = conn_info->resp_ie_len,
+ };
+#endif
s32 err = 0;
wl_get_assoc_ies(wl);
@@ -2368,12 +2390,17 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
memcpy(&wl->bssid, &e->addr, ETHER_ADDR_LEN);
wl_update_bss_info(wl);
cfg80211_roamed(ndev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+ &roam_info,
+#else
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 39)
&wl->conf->channel,
#endif
(u8 *)&wl->bssid,
conn_info->req_ie, conn_info->req_ie_len,
- conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
+ conn_info->resp_ie, conn_info->resp_ie_len,
+#endif
+ GFP_KERNEL);
WL_DBG(("Report roaming result\n"));
set_bit(WL_STATUS_CONNECTED, &wl->status);
--
2.45.1

View file

@ -1,59 +0,0 @@
From ae88c3c0c91d26ca5e4dc1e498a370747d2c3b03 Mon Sep 17 00:00:00 2001
From: Yegor Timoshenko <yegortimoshenko@riseup.net>
Date: Wed, 31 Jan 2018 22:59:09 +0000
Subject: [PATCH 08/16] linuxPackages.broadcom_sta: fix build for kernel 4.15+
See: https://lkml.org/lkml/2017/11/25/90
---
src/wl/sys/wl_linux.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 18841d9..83b8859 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -93,7 +93,11 @@ struct iw_statistics *wl_get_wireless_stats(struct net_device *dev);
#include <wlc_wowl.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
+static void wl_timer(struct timer_list *tl);
+#else
static void wl_timer(ulong data);
+#endif
static void _wl_timer(wl_timer_t *t);
static struct net_device *wl_alloc_linux_if(wl_if_t *wlif);
@@ -2303,9 +2307,15 @@ wl_timer_task(wl_task_t *task)
}
static void
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
+wl_timer(struct timer_list *tl)
+{
+ wl_timer_t *t = from_timer(t, tl, timer);
+#else
wl_timer(ulong data)
{
wl_timer_t *t = (wl_timer_t *)data;
+#endif
if (!WL_ALL_PASSIVE_ENAB(t->wl))
_wl_timer(t);
@@ -2357,9 +2367,13 @@ wl_init_timer(wl_info_t *wl, void (*fn)(void *arg), void *arg, const char *tname
bzero(t, sizeof(wl_timer_t));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
+ timer_setup(&t->timer, wl_timer, 0);
+#else
init_timer(&t->timer);
t->timer.data = (ulong) t;
t->timer.function = wl_timer;
+#endif
t->wl = wl;
t->fn = fn;
t->arg = arg;
--
2.45.1

View file

@ -1,131 +0,0 @@
From bc408ef546b08443dabbe8fcdfec5e1e48494ed8 Mon Sep 17 00:00:00 2001
From: aszlig <aszlig@redmoonstudios.org>
Date: Mon, 1 Aug 2016 20:45:47 +0200
Subject: [PATCH 04/16] linuxPackages.broadcom_sta: fix build for kernel 4.7+
Patch is from Arch Linux at:
https://aur.archlinux.org/cgit/aur.git/tree/?h=broadcom-wl
I've tested building against 3.18.36, 4.4.16 and 4.7.0.
Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Cc: @phreedom, @vcunat
Since Linux 4.7, the enum ieee80211_band is no longer used
This shall cause no problem's since both enums ieee80211_band
and nl80211_band were added in the same commit:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=13ae75b103e07304a34ab40c9136e9f53e06475c
This patch refactors the references of IEEE80211_BAND_* to NL80211_BAND_*
Reference:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=57fbcce37be7c1d2622b56587c10ade00e96afa3
---
src/wl/sys/wl_cfg80211_hybrid.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 7b606e0..3b438ba 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -236,7 +236,7 @@ static s8 wl_dbg_estr[][WL_DBG_ESTR_MAX] = {
#endif
#define CHAN2G(_channel, _freq, _flags) { \
- .band = IEEE80211_BAND_2GHZ, \
+ .band = NL80211_BAND_2GHZ, \
.center_freq = (_freq), \
.hw_value = (_channel), \
.flags = (_flags), \
@@ -245,7 +245,7 @@ static s8 wl_dbg_estr[][WL_DBG_ESTR_MAX] = {
}
#define CHAN5G(_channel, _flags) { \
- .band = IEEE80211_BAND_5GHZ, \
+ .band = NL80211_BAND_5GHZ, \
.center_freq = 5000 + (5 * (_channel)), \
.hw_value = (_channel), \
.flags = (_flags), \
@@ -379,7 +379,7 @@ static struct ieee80211_channel __wl_5ghz_n_channels[] = {
};
static struct ieee80211_supported_band __wl_band_2ghz = {
- .band = IEEE80211_BAND_2GHZ,
+ .band = NL80211_BAND_2GHZ,
.channels = __wl_2ghz_channels,
.n_channels = ARRAY_SIZE(__wl_2ghz_channels),
.bitrates = wl_g_rates,
@@ -387,7 +387,7 @@ static struct ieee80211_supported_band __wl_band_2ghz = {
};
static struct ieee80211_supported_band __wl_band_5ghz_a = {
- .band = IEEE80211_BAND_5GHZ,
+ .band = NL80211_BAND_5GHZ,
.channels = __wl_5ghz_a_channels,
.n_channels = ARRAY_SIZE(__wl_5ghz_a_channels),
.bitrates = wl_a_rates,
@@ -395,7 +395,7 @@ static struct ieee80211_supported_band __wl_band_5ghz_a = {
};
static struct ieee80211_supported_band __wl_band_5ghz_n = {
- .band = IEEE80211_BAND_5GHZ,
+ .band = NL80211_BAND_5GHZ,
.channels = __wl_5ghz_n_channels,
.n_channels = ARRAY_SIZE(__wl_5ghz_n_channels),
.bitrates = wl_a_rates,
@@ -1876,8 +1876,8 @@ static s32 wl_alloc_wdev(struct device *dev, struct wireless_dev **rwdev)
wdev->wiphy->max_num_pmkids = WL_NUM_PMKIDS_MAX;
#endif
wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC);
- wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &__wl_band_2ghz;
- wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_a;
+ wdev->wiphy->bands[NL80211_BAND_2GHZ] = &__wl_band_2ghz;
+ wdev->wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_a;
wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
wdev->wiphy->cipher_suites = __wl_cipher_suites;
wdev->wiphy->n_cipher_suites = ARRAY_SIZE(__wl_cipher_suites);
@@ -2000,7 +2000,7 @@ static s32 wl_inform_single_bss(struct wl_cfg80211_priv *wl, struct wl_bss_info
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
freq = ieee80211_channel_to_frequency(notif_bss_info->channel,
(notif_bss_info->channel <= CH_MAX_2G_CHANNEL) ?
- IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ);
+ NL80211_BAND_2GHZ : NL80211_BAND_5GHZ);
#else
freq = ieee80211_channel_to_frequency(notif_bss_info->channel);
#endif
@@ -2116,7 +2116,7 @@ wl_notify_connect_status(struct wl_cfg80211_priv *wl, struct net_device *ndev,
return err;
}
chan = wf_chspec_ctlchan(chanspec);
- band = (chan <= CH_MAX_2G_CHANNEL) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
+ band = (chan <= CH_MAX_2G_CHANNEL) ? NL80211_BAND_2GHZ : NL80211_BAND_5GHZ;
freq = ieee80211_channel_to_frequency(chan, band);
channel = ieee80211_get_channel(wiphy, freq);
cfg80211_ibss_joined(ndev, (u8 *)&wl->bssid, channel, GFP_KERNEL);
@@ -2250,10 +2250,10 @@ static void wl_ch_to_chanspec(struct ieee80211_channel *chan, struct wl_join_par
join_params->params.chanspec_list[0] =
ieee80211_frequency_to_channel(chan->center_freq);
- if (chan->band == IEEE80211_BAND_2GHZ) {
+ if (chan->band == NL80211_BAND_2GHZ) {
chanspec |= WL_CHANSPEC_BAND_2G;
}
- else if (chan->band == IEEE80211_BAND_5GHZ) {
+ else if (chan->band == NL80211_BAND_5GHZ) {
chanspec |= WL_CHANSPEC_BAND_5G;
}
else {
@@ -2885,7 +2885,7 @@ static s32 wl_update_wiphybands(struct wl_cfg80211_priv *wl)
if (phy == 'n' || phy == 'a' || phy == 'v') {
wiphy = wl_to_wiphy(wl);
- wiphy->bands[IEEE80211_BAND_5GHZ] = &__wl_band_5ghz_n;
+ wiphy->bands[NL80211_BAND_5GHZ] = &__wl_band_5ghz_n;
}
return err;
--
2.45.1

View file

@ -1,66 +0,0 @@
From 8c536235639010135f8dc11a8ec0968f9b200a6e Mon Sep 17 00:00:00 2001
From: Alberto Milone <alberto.milone@canonical.com>
Date: Fri, 2 Sep 2016 17:35:34 +0200
Subject: [PATCH 05/16] linuxPackages.broadcom_sta: fix build for kernel 4.8+
Original author: Krzysztof Kolasa
Source: https://git.archlinux.org/svntogit/community.git/tree/trunk/004-linux48.patch?h=packages/broadcom-wl-dkms
---
src/wl/sys/wl_cfg80211_hybrid.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 3b438ba..84f0068 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -2386,8 +2386,16 @@ wl_bss_connect_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
s32 err = 0;
if (wl->scan_request) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+ struct cfg80211_scan_info info = {
+ .aborted = true,
+ };
+ WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
+ cfg80211_scan_done(wl->scan_request, &info);
+#else
WL_DBG(("%s: Aborting scan\n", __FUNCTION__));
cfg80211_scan_done(wl->scan_request, true);
+#endif
wl->scan_request = NULL;
}
@@ -2488,7 +2496,14 @@ wl_notify_scan_status(struct wl_cfg80211_priv *wl, struct net_device *ndev,
scan_done_out:
if (wl->scan_request) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+ struct cfg80211_scan_info info = {
+ .aborted = false,
+ };
+ cfg80211_scan_done(wl->scan_request, &info);
+#else
cfg80211_scan_done(wl->scan_request, false);
+#endif
wl->scan_request = NULL;
}
rtnl_unlock();
@@ -2913,7 +2928,14 @@ s32 wl_cfg80211_down(struct net_device *ndev)
s32 err = 0;
if (wl->scan_request) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+ struct cfg80211_scan_info info = {
+ .aborted = true,
+ };
+ cfg80211_scan_done(wl->scan_request, &info);
+#else
cfg80211_scan_done(wl->scan_request, true);
+#endif
wl->scan_request = NULL;
}
--
2.45.1

View file

@ -1,39 +0,0 @@
From 35c712b7ad2b20088a1a4e233f1d22d7f6dc2525 Mon Sep 17 00:00:00 2001
From: georgewhewell <georgerw@gmail.com>
Date: Sat, 18 May 2019 21:36:26 +0100
Subject: [PATCH 09/16] linuxPackages.broadcom_sta: fix build for kernel 5.1+
---
src/wl/sys/wl_cfg80211_hybrid.c | 2 +-
src/wl/sys/wl_iw.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 1893a53..4b3298f 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -457,7 +457,7 @@ wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
ifr.ifr_data = (caddr_t)&ioc;
fs = get_fs();
- set_fs(get_ds());
+ set_fs(KERNEL_DS);
#if defined(WL_USE_NETDEV_OPS)
err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
#else
diff --git a/src/wl/sys/wl_iw.c b/src/wl/sys/wl_iw.c
index c4c610b..9c3c74e 100644
--- a/src/wl/sys/wl_iw.c
+++ b/src/wl/sys/wl_iw.c
@@ -117,7 +117,7 @@ dev_wlc_ioctl(
ifr.ifr_data = (caddr_t) &ioc;
fs = get_fs();
- set_fs(get_ds());
+ set_fs(KERNEL_DS);
#if defined(WL_USE_NETDEV_OPS)
ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
#else
--
2.45.1

View file

@ -1,69 +0,0 @@
From a5e450dcdc7bc4ce06379189c3577f8c7a36fbde Mon Sep 17 00:00:00 2001
From: Joan Bruguera <joanbrugueram@gmail.com>
Date: Wed, 12 Jan 2022 20:49:20 +0100
Subject: [PATCH 12/16] linuxPackages.broadcom_sta: fix build for kernel 5.17+
Tentative fix for broadcom-wl 6.30.223.271 driver for Linux 5.17-rc1
Set netdev->dev_addr through dev_addr_mod + PDE_DATA fix
Since Linux 5.17 netdev->dev_addr is const and must be changed through
dev_addr_mod, otherwise a warning is logged in dmesg and bad things may happen.
NB: The #if is not wrong, dev_addr_mod is defined since Linux 5.15-rc1
Plus a trivial fix for PDE_DATA.
Applies on top of all the patches applied to broadcom-wl-dkms 6.30.223.271-28 on Arch Linux.
See also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=adeef3e32146a8d2a73c399dc6f5d76a449131b1
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=359745d78351c6f5442435f81549f0207ece28aa
---
src/wl/sys/wl_linux.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 26ba9fa..25c4706 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -93,6 +93,10 @@ struct iw_statistics *wl_get_wireless_stats(struct net_device *dev);
#include <wlc_wowl.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0))
+#define PDE_DATA pde_data
+#endif
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
static void wl_timer(struct timer_list *tl);
#else
@@ -646,7 +650,7 @@ wl_attach(uint16 vendor, uint16 device, ulong regs,
WL_ERROR(("wl%d: Error setting MAC ADDRESS\n", unit));
}
#endif
- bcopy(&wl->pub->cur_etheraddr, dev->dev_addr, ETHER_ADDR_LEN);
+ eth_hw_addr_set(dev, wl->pub->cur_etheraddr.octet);
online_cpus = 1;
@@ -1852,7 +1856,7 @@ wl_set_mac_address(struct net_device *dev, void *addr)
WL_LOCK(wl);
- bcopy(sa->sa_data, dev->dev_addr, ETHER_ADDR_LEN);
+ eth_hw_addr_set(dev, sa->sa_data);
err = wlc_iovar_op(wl->wlc, "cur_etheraddr", NULL, 0, sa->sa_data, ETHER_ADDR_LEN,
IOV_SET, (WL_DEV_IF(dev))->wlcif);
WL_UNLOCK(wl);
@@ -3033,7 +3037,7 @@ _wl_add_monitor_if(wl_task_t *task)
else
dev->type = ARPHRD_IEEE80211_RADIOTAP;
- bcopy(wl->dev->dev_addr, dev->dev_addr, ETHER_ADDR_LEN);
+ eth_hw_addr_set(dev, wl->dev->dev_addr);
#if defined(WL_USE_NETDEV_OPS)
dev->netdev_ops = &wl_netdev_monitor_ops;
--
2.45.1

View file

@ -1,84 +0,0 @@
From 6c66b0eaaa3e6ebaa84891298715b71f7b2f0b1c Mon Sep 17 00:00:00 2001
From: X9VoiD <oscar.silvestrexx@gmail.com>
Date: Mon, 13 Jun 2022 17:38:18 +0800
Subject: [PATCH 13/16] linuxPackages.broadcom_sta: fix build for kernel 5.18+
---
src/shared/linux_osl.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/shared/linux_osl.c b/src/shared/linux_osl.c
index dcfc075..5a25b82 100644
--- a/src/shared/linux_osl.c
+++ b/src/shared/linux_osl.c
@@ -599,6 +599,8 @@ osl_dma_alloc_consistent(osl_t *osh, uint size, uint16 align_bits, uint *alloced
va = kmalloc(size, GFP_ATOMIC | __GFP_ZERO);
if (va)
*pap = (ulong)__virt_to_phys(va);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ va = dma_alloc_coherent(&((struct pci_dev *)osh->pdev)->dev, size, (dma_addr_t*)pap, GFP_ATOMIC);
#else
va = pci_alloc_consistent(osh->pdev, size, (dma_addr_t*)pap);
#endif
@@ -612,6 +614,8 @@ osl_dma_free_consistent(osl_t *osh, void *va, uint size, ulong pa)
#ifdef __ARM_ARCH_7A__
kfree(va);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ dma_free_coherent(&((struct pci_dev *)osh->pdev)->dev, size, va, (dma_addr_t)pa);
#else
pci_free_consistent(osh->pdev, size, va, (dma_addr_t)pa);
#endif
@@ -623,7 +627,11 @@ osl_dma_map(osl_t *osh, void *va, uint size, int direction, void *p, hnddma_seg_
int dir;
ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ dir = (direction == DMA_TX)? DMA_TO_DEVICE: DMA_FROM_DEVICE;
+#else
dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
+#endif
#if defined(__ARM_ARCH_7A__) && defined(BCMDMASGLISTOSL)
if (dmah != NULL) {
@@ -641,7 +649,11 @@ osl_dma_map(osl_t *osh, void *va, uint size, int direction, void *p, hnddma_seg_
ASSERT(totsegs + nsegs <= MAX_DMA_SEGS);
sg->page_link = 0;
sg_set_buf(sg, PKTDATA(osh, skb), PKTLEN(osh, skb));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ dma_map_single(&((struct pci_dev *)osh->pdev)->dev, PKTDATA(osh, skb), PKTLEN(osh, skb), dir);
+#else
pci_map_single(osh->pdev, PKTDATA(osh, skb), PKTLEN(osh, skb), dir);
+#endif
}
totsegs += nsegs;
totlen += PKTLEN(osh, skb);
@@ -656,7 +668,11 @@ osl_dma_map(osl_t *osh, void *va, uint size, int direction, void *p, hnddma_seg_
}
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ return (dma_map_single(&((struct pci_dev *)osh->pdev)->dev, va, size, dir));
+#else
return (pci_map_single(osh->pdev, va, size, dir));
+#endif
}
void BCMFASTPATH
@@ -665,8 +681,13 @@ osl_dma_unmap(osl_t *osh, uint pa, uint size, int direction)
int dir;
ASSERT((osh && (osh->magic == OS_HANDLE_MAGIC)));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+ dir = (direction == DMA_TX)? DMA_TO_DEVICE: DMA_FROM_DEVICE;
+ dma_unmap_single(&((struct pci_dev *)osh->pdev)->dev, (uint32)pa, size, dir);
+#else
dir = (direction == DMA_TX)? PCI_DMA_TODEVICE: PCI_DMA_FROMDEVICE;
pci_unmap_single(osh->pdev, (uint32)pa, size, dir);
+#endif
}
#if defined(BCMDBG_ASSERT)
--
2.45.1

View file

@ -1,92 +0,0 @@
From 24decccfadc0d95b973e6dd8d476ddde2f0a4b21 Mon Sep 17 00:00:00 2001
From: Herman van Hazendonk <github.com@herrie.org>
Date: Tue, 31 Mar 2020 17:09:55 +0200
Subject: [PATCH 10/16] linuxPackages.broadcom_sta: fix build for kernel 5.6+
Use ioremap instead of ioremap_nocache and proc_ops instead of file_operations on Linux kernel 5.6 and above.
Signed-off-by: Herman van Hazendonk <github.com@herrie.org>
Source: https://salsa.debian.org/Herrie82-guest/broadcom-sta/-/commit/247307926e5540ad574a17c062c8da76990d056f
---
src/shared/linux_osl.c | 6 +++++-
src/wl/sys/wl_linux.c | 21 ++++++++++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/src/shared/linux_osl.c b/src/shared/linux_osl.c
index 6157d18..dcfc075 100644
--- a/src/shared/linux_osl.c
+++ b/src/shared/linux_osl.c
@@ -942,7 +942,11 @@ osl_getcycles(void)
void *
osl_reg_map(uint32 pa, uint size)
{
- return (ioremap_nocache((unsigned long)pa, (unsigned long)size));
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+ return (ioremap((unsigned long)pa, (unsigned long)size));
+ #else
+ return (ioremap_nocache((unsigned long)pa, (unsigned long)size));
+ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */
}
void
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 83b8859..646f1d9 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -591,10 +591,17 @@ wl_attach(uint16 vendor, uint16 device, ulong regs,
}
wl->bcm_bustype = bustype;
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+ if ((wl->regsva = ioremap(dev->base_addr, PCI_BAR0_WINSZ)) == NULL) {
+ WL_ERROR(("wl%d: ioremap() failed\n", unit));
+ goto fail;
+ }
+ #else
if ((wl->regsva = ioremap_nocache(dev->base_addr, PCI_BAR0_WINSZ)) == NULL) {
WL_ERROR(("wl%d: ioremap() failed\n", unit));
goto fail;
}
+ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */
wl->bar1_addr = bar1_addr;
wl->bar1_size = bar1_size;
@@ -781,8 +788,13 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if ((val & 0x0000ff00) != 0)
pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
bar1_size = pci_resource_len(pdev, 2);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+ bar1_addr = (uchar *)ioremap(pci_resource_start(pdev, 2),
+ bar1_size);
+ #else
bar1_addr = (uchar *)ioremap_nocache(pci_resource_start(pdev, 2),
bar1_size);
+ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */
wl = wl_attach(pdev->vendor, pdev->device, pci_resource_start(pdev, 0), PCI_BUS, pdev,
pdev->irq, bar1_addr, bar1_size);
@@ -3363,12 +3375,19 @@ wl_proc_write(struct file *filp, const char __user *buff, size_t length, loff_t
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+static const struct proc_ops wl_fops = {
+ .proc_read = wl_proc_read,
+ .proc_write = wl_proc_write,
+};
+#else
static const struct file_operations wl_fops = {
.owner = THIS_MODULE,
.read = wl_proc_read,
.write = wl_proc_write,
};
-#endif
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) */
static int
wl_reg_proc_entry(wl_info_t *wl)
--
2.45.1

View file

@ -1,214 +0,0 @@
From 34d611f2dcf7d34db2cb413cc7b4f86f3706fec6 Mon Sep 17 00:00:00 2001
From: Joan Bruguera <joanbrugueram@gmail.com>
Date: Tue, 13 Oct 2020 19:35:55 +0200
Subject: [PATCH 11/16] linuxPackages.broadcom_sta: fix build for kernel 5.9+
Get rid of get_fs/set_fs calls in Broadcom WL driver.
Tentative patch for broadcom-wl 6.30.223.271 driver for Linux 5.10 (tested -rc1 up to 5.10.1)
Applies on top of all the patches applied to broadcom-wl-dkms 6.30.223.271-23 on Arch Linux.
NB: Some checks in wlc_ioctl_internal are likely superfluous,
but I'm not familiar enough with the driver to remove them with confidence.
See also: https://lwn.net/Articles/722267/
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=47058bb54b57962b3958a936ddbc59355e4c5504
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5e6e9852d6f76e01b2e6803c74258afa5b432bc5
Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
---
src/wl/sys/wl_cfg80211_hybrid.c | 26 ++-------------------
src/wl/sys/wl_iw.c | 25 ++-------------------
src/wl/sys/wl_linux.c | 40 ++++++++++++++++++++++++++++-----
src/wl/sys/wl_linux.h | 2 ++
src/wl/sys/wlc_pub.h | 1 +
5 files changed, 42 insertions(+), 52 deletions(-)
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 4b3298f..c45ad48 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -41,6 +41,7 @@
#include <wlioctl.h>
#include <proto/802.11.h>
#include <wl_cfg80211_hybrid.h>
+#include <wl_linux.h>
#define EVENT_TYPE(e) dtoh32((e)->event_type)
#define EVENT_FLAGS(e) dtoh16((e)->flags)
@@ -442,30 +443,7 @@ static void key_endian_to_host(struct wl_wsec_key *key)
static s32
wl_dev_ioctl(struct net_device *dev, u32 cmd, void *arg, u32 len)
{
- struct ifreq ifr;
- struct wl_ioctl ioc;
- mm_segment_t fs;
- s32 err = 0;
-
- BUG_ON(len < sizeof(int));
-
- memset(&ioc, 0, sizeof(ioc));
- ioc.cmd = cmd;
- ioc.buf = arg;
- ioc.len = len;
- strcpy(ifr.ifr_name, dev->name);
- ifr.ifr_data = (caddr_t)&ioc;
-
- fs = get_fs();
- set_fs(KERNEL_DS);
-#if defined(WL_USE_NETDEV_OPS)
- err = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#else
- err = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#endif
- set_fs(fs);
-
- return err;
+ return wlc_ioctl_internal(dev, cmd, arg, len);
}
static s32
diff --git a/src/wl/sys/wl_iw.c b/src/wl/sys/wl_iw.c
index 9c3c74e..e346b15 100644
--- a/src/wl/sys/wl_iw.c
+++ b/src/wl/sys/wl_iw.c
@@ -37,6 +37,7 @@ typedef const struct si_pub si_t;
#include <wl_dbg.h>
#include <wl_iw.h>
+#include <wl_linux.h>
extern bool wl_iw_conn_status_str(uint32 event_type, uint32 status,
uint32 reason, char* stringBuf, uint buflen);
@@ -103,29 +104,7 @@ dev_wlc_ioctl(
int len
)
{
- struct ifreq ifr;
- wl_ioctl_t ioc;
- mm_segment_t fs;
- int ret;
-
- memset(&ioc, 0, sizeof(ioc));
- ioc.cmd = cmd;
- ioc.buf = arg;
- ioc.len = len;
-
- strcpy(ifr.ifr_name, dev->name);
- ifr.ifr_data = (caddr_t) &ioc;
-
- fs = get_fs();
- set_fs(KERNEL_DS);
-#if defined(WL_USE_NETDEV_OPS)
- ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#else
- ret = dev->do_ioctl(dev, &ifr, SIOCDEVPRIVATE);
-#endif
- set_fs(fs);
-
- return ret;
+ return wlc_ioctl_internal(dev, cmd, arg, len);
}
static int
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 646f1d9..26ba9fa 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -1664,10 +1664,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
goto done2;
}
- if (segment_eq(get_fs(), KERNEL_DS))
- buf = ioc.buf;
-
- else if (ioc.buf) {
+ if (ioc.buf) {
if (!(buf = (void *) MALLOC(wl->osh, MAX(ioc.len, WLC_IOCTL_MAXLEN)))) {
bcmerror = BCME_NORESOURCE;
goto done2;
@@ -1688,7 +1685,7 @@ wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
WL_UNLOCK(wl);
done1:
- if (ioc.buf && (ioc.buf != buf)) {
+ if (ioc.buf) {
if (copy_to_user(ioc.buf, buf, ioc.len))
bcmerror = BCME_BADADDR;
MFREE(wl->osh, buf, MAX(ioc.len, WLC_IOCTL_MAXLEN));
@@ -1701,6 +1698,39 @@ done2:
return (OSL_ERROR(bcmerror));
}
+int
+wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len)
+{
+ wl_info_t *wl;
+ wl_if_t *wlif;
+ int bcmerror;
+
+ if (!dev)
+ return -ENETDOWN;
+
+ wl = WL_INFO(dev);
+ wlif = WL_DEV_IF(dev);
+ if (wlif == NULL || wl == NULL || wl->dev == NULL)
+ return -ENETDOWN;
+
+ bcmerror = 0;
+
+ WL_TRACE(("wl%d: wlc_ioctl_internal: cmd 0x%x\n", wl->pub->unit, cmd));
+
+ WL_LOCK(wl);
+ if (!capable(CAP_NET_ADMIN)) {
+ bcmerror = BCME_EPERM;
+ } else {
+ bcmerror = wlc_ioctl(wl->wlc, cmd, buf, len, wlif->wlcif);
+ }
+ WL_UNLOCK(wl);
+
+ ASSERT(VALID_BCMERROR(bcmerror));
+ if (bcmerror != 0)
+ wl->pub->bcmerror = bcmerror;
+ return (OSL_ERROR(bcmerror));
+}
+
static struct net_device_stats*
wl_get_stats(struct net_device *dev)
{
diff --git a/src/wl/sys/wl_linux.h b/src/wl/sys/wl_linux.h
index 5b1048e..c8c1f41 100644
--- a/src/wl/sys/wl_linux.h
+++ b/src/wl/sys/wl_linux.h
@@ -22,6 +22,7 @@
#define _wl_linux_h_
#include <wlc_types.h>
+#include <wlc_pub.h>
typedef struct wl_timer {
struct timer_list timer;
@@ -187,6 +188,7 @@ extern irqreturn_t wl_isr(int irq, void *dev_id, struct pt_regs *ptregs);
extern int __devinit wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
extern void wl_free(wl_info_t *wl);
extern int wl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
+extern int wlc_ioctl_internal(struct net_device *dev, int cmd, void *buf, int len);
extern struct net_device * wl_netdev_get(wl_info_t *wl);
#endif
diff --git a/src/wl/sys/wlc_pub.h b/src/wl/sys/wlc_pub.h
index 53a98b8..2b5a029 100644
--- a/src/wl/sys/wlc_pub.h
+++ b/src/wl/sys/wlc_pub.h
@@ -24,6 +24,7 @@
#include <wlc_types.h>
#include <wlc_utils.h>
+#include <siutils.h>
#include "proto/802.11.h"
#include "proto/bcmevent.h"
--
2.45.1

View file

@ -1,34 +0,0 @@
From cec136ba06039aa2e4441771df855894391db298 Mon Sep 17 00:00:00 2001
From: Joan Bruguera <joanbrugueram@gmail.com>
Date: Thu, 30 Jun 2022 02:15:35 +0200
Subject: [PATCH 14/16] linuxPackages.broadcom_sta: fix build for kernel 6.0+
Tentative patch for broadcom-wl 6.30.223.271 driver for Linux 6.0-rc1
Applies on top of all the patches applied to broadcom-wl-dkms 6.30.223.271-33 on Arch Linux.
Source: https://gist.github.com/joanbm/207210d74637870c01ef5a3c262a597d
---
src/wl/sys/wl_cfg80211_hybrid.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index c45ad48..9ae56a1 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -2354,7 +2354,12 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
struct cfg80211_roam_info roam_info = {
+// Rel. commit "cfg80211: Indicate MLO connection info in connect and roam callbacks" (Veerendranath Jakkam, Wed Jun 8)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
.bss = bss,
+#else
+ .links[0].bss = bss,
+#endif
.req_ie = conn_info->req_ie,
.req_ie_len = conn_info->req_ie_len,
.resp_ie = conn_info->resp_ie,
--
2.45.1

View file

@ -1,87 +0,0 @@
From febe94b43294a3155e39e844db4ac4ee81614ad1 Mon Sep 17 00:00:00 2001
From: Joan Bruguera <joanbrugueram@gmail.com>
Date: Mon, 29 Aug 2022 00:06:53 +0200
Subject: [PATCH 16/16] linuxPackages.broadcom_sta: fix build for kernel 6.1+
Tentative patch for broadcom-wl 6.30.223.271 driver for Linux 6.1-rc1
Applies on top of all the patches applied to broadcom-wl-dkms 6.30.223.271-35 on Arch Linux
Source: https://gist.github.com/joanbm/94323ea99eff1e1d1c51241b5b651549
---
src/wl/sys/wl_cfg80211_hybrid.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index a6b2ca2..333866c 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -104,20 +104,25 @@ static s32 wl_cfg80211_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wd
static s32 wl_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm);
#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
+#define MAYBE_INT_LINK_ID int link_id,
+#else
+#define MAYBE_INT_LINK_ID
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
static s32 wl_cfg80211_config_default_key(struct wiphy *wiphy,
- struct net_device *dev, u8 key_idx, bool unicast, bool multicast);
+ struct net_device *dev, MAYBE_INT_LINK_ID u8 key_idx, bool unicast, bool multicast);
#else
static s32 wl_cfg80211_config_default_key(struct wiphy *wiphy,
struct net_device *dev, u8 key_idx);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
static s32 wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
- u8 key_idx, bool pairwise, const u8 *mac_addr, struct key_params *params);
+ MAYBE_INT_LINK_ID u8 key_idx, bool pairwise, const u8 *mac_addr, struct key_params *params);
static s32 wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
- u8 key_idx, bool pairwise, const u8 *mac_addr);
+ MAYBE_INT_LINK_ID u8 key_idx, bool pairwise, const u8 *mac_addr);
static s32 wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
- u8 key_idx, bool pairwise, const u8 *mac_addr,
+ MAYBE_INT_LINK_ID u8 key_idx, bool pairwise, const u8 *mac_addr,
void *cookie, void (*callback) (void *cookie, struct key_params *params));
#else
static s32 wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
@@ -1165,7 +1170,7 @@ static s32 wl_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
static s32
wl_cfg80211_config_default_key(struct wiphy *wiphy,
- struct net_device *dev, u8 key_idx, bool unicast, bool multicast)
+ struct net_device *dev, MAYBE_INT_LINK_ID u8 key_idx, bool unicast, bool multicast)
#else
static s32
wl_cfg80211_config_default_key(struct wiphy *wiphy,
@@ -1190,7 +1195,7 @@ wl_cfg80211_config_default_key(struct wiphy *wiphy,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
static s32
wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
- u8 key_idx, bool pairwise, const u8 *mac_addr, struct key_params *params)
+ MAYBE_INT_LINK_ID u8 key_idx, bool pairwise, const u8 *mac_addr, struct key_params *params)
#else
static s32
wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
@@ -1311,7 +1316,7 @@ wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
static s32
wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
- u8 key_idx, bool pairwise, const u8 *mac_addr)
+ MAYBE_INT_LINK_ID u8 key_idx, bool pairwise, const u8 *mac_addr)
#else
static s32
wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
@@ -1354,7 +1359,7 @@ wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
static s32
wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
- u8 key_idx, bool pairwise, const u8 *mac_addr, void *cookie,
+ MAYBE_INT_LINK_ID u8 key_idx, bool pairwise, const u8 *mac_addr, void *cookie,
void (*callback) (void *cookie, struct key_params * params))
#else
static s32
--
2.45.1

View file

@ -1,34 +0,0 @@
From 507d93e3651d78c1df8bd185b0703872d0c2585b Mon Sep 17 00:00:00 2001
From: aszlig <aszlig@redmoonstudios.org>
Date: Mon, 1 Aug 2016 21:00:02 +0200
Subject: [PATCH 03/16] linuxPackages.broadcom_sta: fix NULL pointer deref
The patch is from the following Gentoo bug:
https://bugs.gentoo.org/show_bug.cgi?id=523326#c24
Built successfully against Linux 3.18.36, 4.4.16 and 4.7.0.
Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Cc: @phreedom, @vcunat
---
src/wl/sys/wl_linux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 14922c0..65d7a22 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -2167,8 +2167,8 @@ wl_start(struct sk_buff *skb, struct net_device *dev)
wlif = WL_DEV_IF(dev);
wl = WL_INFO(dev);
+ skb->prev = NULL;
if (WL_ALL_PASSIVE_ENAB(wl) || (WL_RTR() && WL_CONFIG_SMP())) {
- skb->prev = NULL;
TXQ_LOCK(wl);
--
2.45.1

View file

@ -1,115 +0,0 @@
From 99b1bbc01ea0611e93cb94c2a2532aef96676976 Mon Sep 17 00:00:00 2001
From: X9VoiD <oscar.silvestrexx@gmail.com>
Date: Wed, 19 Oct 2022 00:29:28 +0800
Subject: [PATCH 15/16] linuxPackages.broadcom_sta: fix build issues with
kernel 6.0+
---
src/shared/linux_osl.c | 2 +-
src/wl/sys/wl_cfg80211_hybrid.c | 17 ++++++++---------
src/wl/sys/wl_iw.h | 1 -
src/wl/sys/wl_linux.c | 17 +++++++++--------
4 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/src/shared/linux_osl.c b/src/shared/linux_osl.c
index 5a25b82..18bacb6 100644
--- a/src/shared/linux_osl.c
+++ b/src/shared/linux_osl.c
@@ -1101,7 +1101,7 @@ osl_os_get_image_block(char *buf, int len, void *image)
if (!image)
return 0;
- rdlen = kernel_read(fp, fp->f_pos, buf, len);
+ rdlen = kernel_read(fp, (void *)fp->f_pos, (size_t)len, (loff_t *)buf);
if (rdlen > 0)
fp->f_pos += rdlen;
diff --git a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
index 9ae56a1..a6b2ca2 100644
--- a/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/src/wl/sys/wl_cfg80211_hybrid.c
@@ -790,6 +790,7 @@ wl_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme)
break;
case NL80211_AUTHTYPE_NETWORK_EAP:
WL_DBG(("network eap\n"));
+ break;
default:
val = 2;
WL_ERR(("invalid auth type (%d)\n", sme->auth_type));
@@ -2347,26 +2348,24 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
const wl_event_msg_t *e, void *data)
{
struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
+ s32 err = 0;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
struct cfg80211_bss *bss;
struct wlc_ssid *ssid;
+ struct cfg80211_roam_info roam_info;
ssid = &wl->profile->ssid;
bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
- struct cfg80211_roam_info roam_info = {
// Rel. commit "cfg80211: Indicate MLO connection info in connect and roam callbacks" (Veerendranath Jakkam, Wed Jun 8)
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
- .bss = bss,
+ roam_info.bss = bss;
#else
- .links[0].bss = bss,
+ roam_info.links[0].bss = bss;
#endif
- .req_ie = conn_info->req_ie,
- .req_ie_len = conn_info->req_ie_len,
- .resp_ie = conn_info->resp_ie,
- .resp_ie_len = conn_info->resp_ie_len,
- };
+ roam_info.req_ie = conn_info->req_ie;
+ roam_info.req_ie_len = conn_info->req_ie_len;
+ roam_info.resp_ie = conn_info->resp_ie;
#endif
- s32 err = 0;
wl_get_assoc_ies(wl);
memcpy(wl->profile->bssid, &e->addr, ETHER_ADDR_LEN);
diff --git a/src/wl/sys/wl_iw.h b/src/wl/sys/wl_iw.h
index 3ab084f..471d11f 100644
--- a/src/wl/sys/wl_iw.h
+++ b/src/wl/sys/wl_iw.h
@@ -70,7 +70,6 @@ struct cntry_locales_custom {
#define WL_IW_RSSI_EXCELLENT -57
#define WL_IW_RSSI_INVALID 0
#define MAX_WX_STRING 80
-#define isprint(c) bcm_isprint(c)
#define WL_IW_SET_ACTIVE_SCAN (SIOCIWFIRSTPRIV+1)
#define WL_IW_GET_RSSI (SIOCIWFIRSTPRIV+3)
#define WL_IW_SET_PASSIVE_SCAN (SIOCIWFIRSTPRIV+5)
diff --git a/src/wl/sys/wl_linux.c b/src/wl/sys/wl_linux.c
index 25c4706..4c7e238 100644
--- a/src/wl/sys/wl_linux.c
+++ b/src/wl/sys/wl_linux.c
@@ -791,14 +791,15 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_read_config_dword(pdev, 0x40, &val);
if ((val & 0x0000ff00) != 0)
pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
- bar1_size = pci_resource_len(pdev, 2);
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
- bar1_addr = (uchar *)ioremap(pci_resource_start(pdev, 2),
- bar1_size);
- #else
- bar1_addr = (uchar *)ioremap_nocache(pci_resource_start(pdev, 2),
- bar1_size);
- #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */
+
+ bar1_size = pci_resource_len(pdev, 2);
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+ bar1_addr = (uchar *)ioremap(pci_resource_start(pdev, 2),
+ bar1_size);
+ #else
+ bar1_addr = (uchar *)ioremap_nocache(pci_resource_start(pdev, 2),
+ bar1_size);
+ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */
wl = wl_attach(pdev->vendor, pdev->device, pci_resource_start(pdev, 0), PCI_BUS, pdev,
pdev->irq, bar1_addr, bar1_size);
--
2.45.1

View file

@ -1821,13 +1821,14 @@
habluetooth habluetooth
hassil hassil
home-assistant-intents home-assistant-intents
idasen-ha
ifaddr ifaddr
mutagen mutagen
pymicro-vad pymicro-vad
pyserial pyserial
pyudev pyudev
zeroconf zeroconf
]; # missing inputs: idasen-ha ];
"idteck_prox" = ps: with ps; [ "idteck_prox" = ps: with ps; [
]; # missing inputs: rfk101py ]; # missing inputs: rfk101py
"ifttt" = ps: with ps; [ "ifttt" = ps: with ps; [
@ -5164,6 +5165,7 @@
"iaqualink" "iaqualink"
"ibeacon" "ibeacon"
"icloud" "icloud"
"idasen_desk"
"ifttt" "ifttt"
"ign_sismologia" "ign_sismologia"
"image" "image"

View file

@ -11,11 +11,11 @@
callPackage ../nginx/generic.nix args rec { callPackage ../nginx/generic.nix args rec {
pname = "openresty"; pname = "openresty";
nginxVersion = "1.25.3"; nginxVersion = "1.25.3";
version = "${nginxVersion}.1"; version = "${nginxVersion}.2";
src = fetchurl { src = fetchurl {
url = "https://openresty.org/download/openresty-${version}.tar.gz"; url = "https://openresty.org/download/openresty-${version}.tar.gz";
sha256 = "sha256-MuwaJTpaEyUDVaB1/mW31j7EXFYLviEzUPCZKlfNed8="; sha256 = "sha256-LVZAIrBuM7Rfflz68eXcVx041hgDr5+idU3/81PCjZw=";
}; };
# generic.nix applies fixPatch on top of every patch defined there. # generic.nix applies fixPatch on top of every patch defined there.

View file

@ -7,11 +7,11 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "snappymail"; pname = "snappymail";
version = "2.37.2"; version = "2.37.3";
src = fetchurl { src = fetchurl {
url = "https://github.com/the-djmaze/snappymail/releases/download/v${version}/snappymail-${version}.tar.gz"; url = "https://github.com/the-djmaze/snappymail/releases/download/v${version}/snappymail-${version}.tar.gz";
sha256 = "sha256-kKL3+T4VXhHDYdKfiGVB8cx9/OJajqjvlcImCIrp9yw="; sha256 = "sha256-Fa6VbWPROkdVS8wHkXYCNR+DiBR6SqvfmrjGVlhhkwU=";
}; };
sourceRoot = "snappymail"; sourceRoot = "snappymail";

View file

@ -37,6 +37,7 @@ edk2.mkDerivation "ShellPkg/ShellPkg.dsc" (finalAttrs: {
inherit (edk2.meta) license platforms; inherit (edk2.meta) license platforms;
description = "UEFI Shell from Tianocore EFI development kit"; description = "UEFI Shell from Tianocore EFI development kit";
homepage = "https://github.com/tianocore/tianocore.github.io/wiki/ShellPkg"; homepage = "https://github.com/tianocore/tianocore.github.io/wiki/ShellPkg";
maintainers = with lib.maintainers; [ LunNova ]; maintainers = with lib.maintainers; [ LunNova mjoerg ];
broken = stdenv.isDarwin && stdenv.isAarch64;
}; };
}) })

View file

@ -62,7 +62,6 @@ let
the `tectonic` derivation is updated. the `tectonic` derivation is updated.
*/ */
inherit (emptyFile) inherit (emptyFile)
outputHashAlgo
outputHashMode outputHashMode
outputHash outputHash
; ;

View file

@ -6912,7 +6912,8 @@ with pkgs;
cudaPackages_12_1 = callPackage ./cuda-packages.nix { cudaVersion = "12.1"; }; cudaPackages_12_1 = callPackage ./cuda-packages.nix { cudaVersion = "12.1"; };
cudaPackages_12_2 = callPackage ./cuda-packages.nix { cudaVersion = "12.2"; }; cudaPackages_12_2 = callPackage ./cuda-packages.nix { cudaVersion = "12.2"; };
cudaPackages_12_3 = callPackage ./cuda-packages.nix { cudaVersion = "12.3"; }; cudaPackages_12_3 = callPackage ./cuda-packages.nix { cudaVersion = "12.3"; };
cudaPackages_12 = cudaPackages_12_2; # Latest supported by cudnn cudaPackages_12_4 = callPackage ./cuda-packages.nix { cudaVersion = "12.4"; };
cudaPackages_12 = cudaPackages_12_4; # Latest supported by cudnn
cudaPackages = recurseIntoAttrs cudaPackages_12; cudaPackages = recurseIntoAttrs cudaPackages_12;
@ -12429,8 +12430,6 @@ with pkgs;
setserial = callPackage ../tools/system/setserial { }; setserial = callPackage ../tools/system/setserial { };
setzer = callPackage ../applications/editors/setzer { };
seqdiag = with python3Packages; toPythonApplication seqdiag; seqdiag = with python3Packages; toPythonApplication seqdiag;
sequoia-sqv = callPackage ../tools/security/sequoia-sqv { }; sequoia-sqv = callPackage ../tools/security/sequoia-sqv { };
@ -32782,8 +32781,6 @@ with pkgs;
ponymix = callPackage ../applications/audio/ponymix { }; ponymix = callPackage ../applications/audio/ponymix { };
pop-launcher = callPackage ../applications/misc/pop-launcher { };
pothos = libsForQt5.callPackage ../applications/radio/pothos { }; pothos = libsForQt5.callPackage ../applications/radio/pothos { };
potrace = callPackage ../applications/graphics/potrace { }; potrace = callPackage ../applications/graphics/potrace { };

View file

@ -2717,6 +2717,8 @@ self: super: with self; {
curio = callPackage ../development/python-modules/curio { }; curio = callPackage ../development/python-modules/curio { };
curio-compat = callPackage ../development/python-modules/curio-compat { };
curlify = callPackage ../development/python-modules/curlify { }; curlify = callPackage ../development/python-modules/curlify { };
curl-cffi = callPackage ../development/python-modules/curl-cffi { }; curl-cffi = callPackage ../development/python-modules/curl-cffi { };
@ -5884,6 +5886,8 @@ self: super: with self; {
idasen = callPackage ../development/python-modules/idasen { }; idasen = callPackage ../development/python-modules/idasen { };
idasen-ha = callPackage ../development/python-modules/idasen-ha { };
icoextract = toPythonModule (pkgs.icoextract.override { icoextract = toPythonModule (pkgs.icoextract.override {
python3Packages = self; python3Packages = self;
}); });