···3344{ lib }:
5566+let
77+ inherit (lib) matchAttrs any all;
88+ inherit (builtins) isString;
99+1010+in
611rec {
712813···8388 We can inject these into a pattern for the whole of a structured platform,
8489 and then match that.
8590 */
8686- platformMatch = platform: elem: let
8787- pattern =
8888- if builtins.isString elem
8989- then { system = elem; }
9090- else if elem?parsed
9191- then elem
9292- else { parsed = elem; };
9393- in lib.matchAttrs pattern platform;
9191+ platformMatch = platform: elem: (
9292+ # Check with simple string comparison if elem was a string.
9393+ #
9494+ # The majority of comparisons done with this function will be against meta.platforms
9595+ # which contains a simple platform string.
9696+ #
9797+ # Avoiding an attrset allocation results in significant performance gains (~2-30) across the board in OfBorg
9898+ # because this is a hot path for nixpkgs.
9999+ if isString elem then platform ? system && elem == platform.system
100100+ else matchAttrs (
101101+ # Normalize platform attrset.
102102+ if elem ? parsed then elem
103103+ else { parsed = elem; }
104104+ ) platform
105105+ );
9410695107 /* Check if a package is available on a given platform.
96108···102114 2. None of `meta.badPlatforms` pattern matches the given platform.
103115 */
104116 availableOn = platform: pkg:
105105- ((!pkg?meta.platforms) || lib.any (platformMatch platform) pkg.meta.platforms) &&
106106- lib.all (elem: !platformMatch platform elem) (pkg.meta.badPlatforms or []);
117117+ ((!pkg?meta.platforms) || any (platformMatch platform) pkg.meta.platforms) &&
118118+ all (elem: !platformMatch platform elem) (pkg.meta.badPlatforms or []);
107119108120 /* Get the corresponding attribute in lib.licenses
109121 from the SPDX ID.
···22222323- [`sudo-rs`], a reimplementation of `sudo` in Rust, is now supported.
2424 An experimental new module `security.sudo-rs` was added.
2525- Switching to it (via `security.sudo.enable = false; security.sudo-rs.enable = true;`) introduces
2525+ Switching to it (via ` security.sudo-rs.enable = true;`) introduces
2626 slight changes in sudo behaviour, due to `sudo-rs`' current limitations:
2727 - terminfo-related environment variables aren't preserved for `root` and `wheel`;
2828 - `root` and `wheel` are not given the ability to set (or preserve)
2929 arbitrary environment variables.
30303131-- [glibc](https://www.gnu.org/software/libc/) has been updated from version 2.37 to 2.38, see [the release notes](https://sourceware.org/glibc/wiki/Release/2.38) for what was changed.
3131+ **Note:** The `sudo-rs` module only takes configuration through `security.sudo-rs`,
3232+ and in particular does not automatically use previously-set rules; this could be
3333+ achieved with `security.sudo-rs.extraRules = security.sudo.extraRules;` for instance.
32343335[`sudo-rs`]: https://github.com/memorysafety/sudo-rs/
3636+3737+- [glibc](https://www.gnu.org/software/libc/) has been updated from version 2.37 to 2.38, see [the release notes](https://sourceware.org/glibc/wiki/Release/2.38) for what was changed.
34383539- `linuxPackages_testing_bcachefs` is now soft-deprecated by `linuxPackages_testing`.
3640 - Please consider changing your NixOS configuration's `boot.kernelPackages` to `linuxPackages_testing` until a stable kernel with bcachefs support is released.
+8-5
nixos/modules/security/pam.nix
···943943 value.source = pkgs.writeText "${name}.pam" service.text;
944944 };
945945946946+ optionalSudoConfigForSSHAgentAuth = optionalString config.security.pam.enableSSHAgentAuth ''
947947+ # Keep SSH_AUTH_SOCK so that pam_ssh_agent_auth.so can do its magic.
948948+ Defaults env_keep+=SSH_AUTH_SOCK
949949+ '';
950950+946951in
947952948953{
···15321537 concatLines
15331538 ]);
1534153915351535- security.sudo.extraConfig = optionalString config.security.pam.enableSSHAgentAuth ''
15361536- # Keep SSH_AUTH_SOCK so that pam_ssh_agent_auth.so can do its magic.
15371537- Defaults env_keep+=SSH_AUTH_SOCK
15381538- '';
15391539- };
15401540+ security.sudo.extraConfig = optionalSudoConfigForSSHAgentAuth;
15411541+ security.sudo-rs.extraConfig = optionalSudoConfigForSSHAgentAuth;
15421542+ };
15401543}
+26-51
nixos/modules/security/sudo-rs.nix
···4455let
6677- inherit (pkgs) sudo sudo-rs;
88-97 cfg = config.security.sudo-rs;
1081111- enableSSHAgentAuth =
1212- with config.security;
1313- pam.enableSSHAgentAuth && pam.sudo.sshAgentAuth;
1414-1515- usingMillersSudo = cfg.package.pname == sudo.pname;
1616- usingSudoRs = cfg.package.pname == sudo-rs.pname;
99+ inherit (config.security.pam) enableSSHAgentAuth;
17101811 toUserString = user: if (isInt user) then "#${toString user}" else "${user}";
1912 toGroupString = group: if (isInt group) then "%#${toString group}" else "%${group}";
···41344235 defaultOptions = mkOption {
4336 type = with types; listOf str;
4444- default = optional usingMillersSudo "SETENV";
4545- defaultText = literalMD ''
4646- `[ "SETENV" ]` if using the default `sudo` implementation
4747- '';
3737+ default = [];
4838 description = mdDoc ''
4939 Options used for the default rules, granting `root` and the
5040 `wheel` group permission to run any command as any user.
5141 '';
5242 };
53435454- enable = mkOption {
5555- type = types.bool;
5656- default = false;
5757- description = mdDoc ''
5858- Whether to enable the {command}`sudo` command, which
5959- allows non-root users to execute commands as root.
6060- '';
6161- };
4444+ enable = mkEnableOption (mdDoc ''
4545+ a memory-safe implementation of the {command}`sudo` command,
4646+ which allows non-root users to execute commands as root.
4747+ '');
62486363- package = mkOption {
6464- type = types.package;
6565- default = pkgs.sudo-rs;
6666- defaultText = literalExpression "pkgs.sudo-rs";
6767- description = mdDoc ''
6868- Which package to use for `sudo`.
6969- '';
7070- };
4949+ package = mkPackageOption pkgs "sudo-rs" { };
71507251 wheelNeedsPassword = mkOption {
7352 type = types.bool;
···208187 ###### implementation
209188210189 config = mkIf cfg.enable {
190190+ assertions = [ {
191191+ assertion = ! config.security.sudo.enable;
192192+ message = "`security.sudo` and `security.sudo-rs` cannot both be enabled";
193193+ }];
194194+ security.sudo.enable = mkDefault false;
195195+211196 security.sudo-rs.extraRules =
212197 let
213198 defaultRule = { users ? [], groups ? [], opts ? [] }: [ {
···235220 # Don't edit this file. Set the NixOS options ‘security.sudo-rs.configFile’
236221 # or ‘security.sudo-rs.extraRules’ instead.
237222 ''
238238- (optionalString enableSSHAgentAuth ''
239239- # Keep SSH_AUTH_SOCK so that pam_ssh_agent_auth.so can do its magic.
240240- Defaults env_keep+=SSH_AUTH_SOCK
241241- '')
242242- (concatStringsSep "\n" (
243243- lists.flatten (
244244- map (
245245- rule: optionals (length rule.commands != 0) [
246246- (map (user: "${toUserString user} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.users)
247247- (map (group: "${toGroupString group} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.groups)
248248- ]
249249- ) cfg.extraRules
250250- )
251251- ) + "\n")
223223+ (pipe cfg.extraRules [
224224+ (filter (rule: length rule.commands != 0))
225225+ (map (rule: [
226226+ (map (user: "${toUserString user} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.users)
227227+ (map (group: "${toGroupString group} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.groups)
228228+ ]))
229229+ flatten
230230+ (concatStringsSep "\n")
231231+ ])
232232+ "\n"
252233 (optionalString (cfg.extraConfig != "") ''
253234 # extraConfig
254235 ${cfg.extraConfig}
···265246 source = "${cfg.package.out}/bin/sudo";
266247 inherit owner group setuid permissions;
267248 };
268268- # sudo-rs does not yet ship a sudoedit (as of v0.2.0)
269269- sudoedit = mkIf usingMillersSudo {
270270- source = "${cfg.package.out}/bin/sudoedit";
271271- inherit owner group setuid permissions;
272272- };
273249 };
274250275275- environment.systemPackages = [ sudo ];
251251+ environment.systemPackages = [ cfg.package ];
276252277253 security.pam.services.sudo = { sshAgentAuth = true; usshAuth = true; };
278278- security.pam.services.sudo-i = mkIf usingSudoRs
279279- { sshAgentAuth = true; usshAuth = true; };
254254+ security.pam.services.sudo-i = { sshAgentAuth = true; usshAuth = true; };
280255281256 environment.etc.sudoers =
282257 { source =
···285260 src = pkgs.writeText "sudoers-in" cfg.configFile;
286261 preferLocalBuild = true;
287262 }
288288- "${pkgs.buildPackages."${cfg.package.pname}"}/bin/visudo -f $src -c && cp $src $out";
263263+ "${pkgs.buildPackages.sudo-rs}/bin/visudo -f $src -c && cp $src $out";
289264 mode = "0440";
290265 };
291266
+18-17
nixos/modules/services/backup/btrbk.nix
···4747 then [ "${name} ${value}" ]
4848 else concatLists (mapAttrsToList (genSection name) value);
49495050+ sudoRule = {
5151+ users = [ "btrbk" ];
5252+ commands = [
5353+ { command = "${pkgs.btrfs-progs}/bin/btrfs"; options = [ "NOPASSWD" ]; }
5454+ { command = "${pkgs.coreutils}/bin/mkdir"; options = [ "NOPASSWD" ]; }
5555+ { command = "${pkgs.coreutils}/bin/readlink"; options = [ "NOPASSWD" ]; }
5656+ # for ssh, they are not the same than the one hard coded in ${pkgs.btrbk}
5757+ { command = "/run/current-system/sw/bin/btrfs"; options = [ "NOPASSWD" ]; }
5858+ { command = "/run/current-system/sw/bin/mkdir"; options = [ "NOPASSWD" ]; }
5959+ { command = "/run/current-system/sw/bin/readlink"; options = [ "NOPASSWD" ]; }
6060+ ];
6161+ };
6262+5063 sudo_doas =
5151- if config.security.sudo.enable then "sudo"
6464+ if config.security.sudo.enable || config.security.sudo-rs.enable then "sudo"
5265 else if config.security.doas.enable then "doas"
5366 else throw "The btrbk nixos module needs either sudo or doas enabled in the configuration";
5467···157170 };
158171 config = mkIf (sshEnabled || serviceEnabled) {
159172 environment.systemPackages = [ pkgs.btrbk ] ++ cfg.extraPackages;
160160- security.sudo = mkIf (sudo_doas == "sudo") {
161161- extraRules = [
162162- {
163163- users = [ "btrbk" ];
164164- commands = [
165165- { command = "${pkgs.btrfs-progs}/bin/btrfs"; options = [ "NOPASSWD" ]; }
166166- { command = "${pkgs.coreutils}/bin/mkdir"; options = [ "NOPASSWD" ]; }
167167- { command = "${pkgs.coreutils}/bin/readlink"; options = [ "NOPASSWD" ]; }
168168- # for ssh, they are not the same than the one hard coded in ${pkgs.btrbk}
169169- { command = "/run/current-system/sw/bin/btrfs"; options = [ "NOPASSWD" ]; }
170170- { command = "/run/current-system/sw/bin/mkdir"; options = [ "NOPASSWD" ]; }
171171- { command = "/run/current-system/sw/bin/readlink"; options = [ "NOPASSWD" ]; }
172172- ];
173173- }
174174- ];
175175- };
173173+174174+ security.sudo.extraRules = mkIf (sudo_doas == "sudo") [ sudoRule ];
175175+ security.sudo-rs.extraRules = mkIf (sudo_doas == "sudo") [ sudoRule ];
176176+176177 security.doas = mkIf (sudo_doas == "doas") {
177178 extraRules = let
178179 doasCmdNoPass = cmd: { users = [ "btrbk" ]; cmd = cmd; noPass = true; };
+8-11
nixos/modules/services/misc/amazon-ssm-agent.nix
···1515 -r) echo "${config.system.nixos.version}";;
1616 esac
1717 '';
1818+1919+ sudoRule = {
2020+ users = [ "ssm-user" ];
2121+ commands = [ { command = "ALL"; options = [ "NOPASSWD" ]; } ];
2222+ };
1823in {
1924 imports = [
2025 (mkRenamedOptionModule [ "services" "ssm-agent" "enable" ] [ "services" "amazon-ssm-agent" "enable" ])
···54595560 # Add user that Session Manager needs, and give it sudo.
5661 # This is consistent with Amazon Linux 2 images.
5757- security.sudo.extraRules = [
5858- {
5959- users = [ "ssm-user" ];
6060- commands = [
6161- {
6262- command = "ALL";
6363- options = [ "NOPASSWD" ];
6464- }
6565- ];
6666- }
6767- ];
6262+ security.sudo.extraRules = [ sudoRule ];
6363+ security.sudo-rs.extraRules = [ sudoRule ];
6464+6865 # On Amazon Linux 2 images, the ssm-user user is pretty much a
6966 # normal user with its own group. We do the same.
7067 users.groups.ssm-user = {};
···11+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
22+# yarn lockfile v1
33+44+55+"@org/somepack@file:vendor/orgpacks/somepack/assets":
66+ version "1.0.0"
77+88+"otherpack@file:vendor/otherpack":
99+ version "1.0.0"
···108108 dontConfigure = true;
109109 enableParallelBuilding = true;
110110111111+ env = {
112112+ # silence service.h error
113113+ NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
114114+ };
115115+111116 postPatch = ''
112117 # aarch64 code is compiled on all targets, which causes our Apple SDK headers to error out.
113118 # Since multilib doesnt work on darwin i dont know of a better way of handling this.
+4-4
pkgs/os-specific/linux/zfs/stable.nix
···1818 # check the release notes for compatible kernels
1919 kernelCompatible =
2020 if stdenv'.isx86_64 || removeLinuxDRM
2121- then kernel.kernelOlder "6.6"
2121+ then kernel.kernelOlder "6.7"
2222 else kernel.kernelOlder "6.2";
23232424 latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM
2525- then linuxKernel.packages.linux_6_5
2525+ then linuxKernel.packages.linux_6_6
2626 else linuxKernel.packages.linux_6_1;
27272828 # this package should point to the latest release.
2929- version = "2.2.0";
2929+ version = "2.2.1";
30303131 tests = [
3232 nixosTests.zfs.installer
3333 nixosTests.zfs.stable
3434 ];
35353636- hash = "sha256-s1sdXSrLu6uSOmjprbUa4cFsE2Vj7JX5i75e4vRnlvg=";
3636+ hash = "sha256-2Q/Nhp3YKgMCLPNRNBq5r9U4GeuYlWMWAsjsQy3vFW4=";
3737}
+4-5
pkgs/os-specific/linux/zfs/unstable.nix
···1616 kernelModuleAttribute = "zfsUnstable";
1717 # check the release notes for compatible kernels
1818 kernelCompatible = if stdenv'.isx86_64 || removeLinuxDRM
1919- then kernel.kernelOlder "6.6"
1919+ then kernel.kernelOlder "6.7"
2020 else kernel.kernelOlder "6.2";
21212222 latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM
2323- then linuxKernel.packages.linux_6_5
2323+ then linuxKernel.packages.linux_6_6
2424 else linuxKernel.packages.linux_6_1;
25252626 # this package should point to a version / git revision compatible with the latest kernel release
2727 # IMPORTANT: Always use a tagged release candidate or commits from the
2828 # zfs-<version>-staging branch, because this is tested by the OpenZFS
2929 # maintainers.
3030- version = "2.2.1-unstable-2023-10-21";
3131- rev = "95785196f26e92d82cf4445654ba84e4a9671c57";
3030+ version = "2.2.1";
32313333- hash = "sha256-s1sdXSrLu6uSOmjprbUa4cFsE2Vj7JX5i75e4vRnlvg=";
3232+ hash = "sha256-2Q/Nhp3YKgMCLPNRNBq5r9U4GeuYlWMWAsjsQy3vFW4=";
34333534 isUnstable = true;
3635 tests = [
···585585 miopen-opencl = throw "'miopen-opencl' has been replaced with 'rocmPackages.miopen-opencl'"; # Added 2023-10-08
586586 mime-types = mailcap; # Added 2022-01-21
587587 minizip2 = pkgs.minizip-ng; # Added 2022-12-28
588588+ mirage-im = throw "'mirage-im' has been removed, as it was broken and unmaintained"; # Added 2023-11-26
588589 monero = monero-cli; # Added 2021-11-28
589590 mongodb-4_0 = throw "mongodb-4_0 has been removed, it's end of life since April 2022"; # Added 2023-01-05
590591 mongodb-4_2 = throw "mongodb-4_2 has been removed, it's end of life since April 2023"; # Added 2023-06-06