···34{ lib }:
5000006rec {
78···83 We can inject these into a pattern for the whole of a structured platform,
84 and then match that.
85 */
86- platformMatch = platform: elem: let
87- pattern =
88- if builtins.isString elem
89- then { system = elem; }
90- else if elem?parsed
91- then elem
92- else { parsed = elem; };
93- in lib.matchAttrs pattern platform;
00000009495 /* Check if a package is available on a given platform.
96···102 2. None of `meta.badPlatforms` pattern matches the given platform.
103 */
104 availableOn = platform: pkg:
105- ((!pkg?meta.platforms) || lib.any (platformMatch platform) pkg.meta.platforms) &&
106- lib.all (elem: !platformMatch platform elem) (pkg.meta.badPlatforms or []);
107108 /* Get the corresponding attribute in lib.licenses
109 from the SPDX ID.
···34{ lib }:
56+let
7+ inherit (lib) matchAttrs any all;
8+ inherit (builtins) isString;
9+10+in
11rec {
1213···88 We can inject these into a pattern for the whole of a structured platform,
89 and then match that.
90 */
91+ platformMatch = platform: elem: (
92+ # Check with simple string comparison if elem was a string.
93+ #
94+ # The majority of comparisons done with this function will be against meta.platforms
95+ # which contains a simple platform string.
96+ #
97+ # Avoiding an attrset allocation results in significant performance gains (~2-30) across the board in OfBorg
98+ # because this is a hot path for nixpkgs.
99+ if isString elem then platform ? system && elem == platform.system
100+ else matchAttrs (
101+ # Normalize platform attrset.
102+ if elem ? parsed then elem
103+ else { parsed = elem; }
104+ ) platform
105+ );
106107 /* Check if a package is available on a given platform.
108···114 2. None of `meta.badPlatforms` pattern matches the given platform.
115 */
116 availableOn = platform: pkg:
117+ ((!pkg?meta.platforms) || any (platformMatch platform) pkg.meta.platforms) &&
118+ all (elem: !platformMatch platform elem) (pkg.meta.badPlatforms or []);
119120 /* Get the corresponding attribute in lib.licenses
121 from the SPDX ID.
···2223- [`sudo-rs`], a reimplementation of `sudo` in Rust, is now supported.
24 An experimental new module `security.sudo-rs` was added.
25- Switching to it (via `security.sudo.enable = false; security.sudo-rs.enable = true;`) introduces
26 slight changes in sudo behaviour, due to `sudo-rs`' current limitations:
27 - terminfo-related environment variables aren't preserved for `root` and `wheel`;
28 - `root` and `wheel` are not given the ability to set (or preserve)
29 arbitrary environment variables.
3031-- [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.
003233[`sudo-rs`]: https://github.com/memorysafety/sudo-rs/
003435- `linuxPackages_testing_bcachefs` is now soft-deprecated by `linuxPackages_testing`.
36 - Please consider changing your NixOS configuration's `boot.kernelPackages` to `linuxPackages_testing` until a stable kernel with bcachefs support is released.
···2223- [`sudo-rs`], a reimplementation of `sudo` in Rust, is now supported.
24 An experimental new module `security.sudo-rs` was added.
25+ Switching to it (via ` security.sudo-rs.enable = true;`) introduces
26 slight changes in sudo behaviour, due to `sudo-rs`' current limitations:
27 - terminfo-related environment variables aren't preserved for `root` and `wheel`;
28 - `root` and `wheel` are not given the ability to set (or preserve)
29 arbitrary environment variables.
3031+ **Note:** The `sudo-rs` module only takes configuration through `security.sudo-rs`,
32+ and in particular does not automatically use previously-set rules; this could be
33+ achieved with `security.sudo-rs.extraRules = security.sudo.extraRules;` for instance.
3435[`sudo-rs`]: https://github.com/memorysafety/sudo-rs/
36+37+- [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.
3839- `linuxPackages_testing_bcachefs` is now soft-deprecated by `linuxPackages_testing`.
40 - 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
···943 value.source = pkgs.writeText "${name}.pam" service.text;
944 };
94500000946in
947948{
···1532 concatLines
1533 ]);
15341535- security.sudo.extraConfig = optionalString config.security.pam.enableSSHAgentAuth ''
1536- # Keep SSH_AUTH_SOCK so that pam_ssh_agent_auth.so can do its magic.
1537- Defaults env_keep+=SSH_AUTH_SOCK
1538- '';
1539- };
1540}
···943 value.source = pkgs.writeText "${name}.pam" service.text;
944 };
945946+ optionalSudoConfigForSSHAgentAuth = optionalString config.security.pam.enableSSHAgentAuth ''
947+ # Keep SSH_AUTH_SOCK so that pam_ssh_agent_auth.so can do its magic.
948+ Defaults env_keep+=SSH_AUTH_SOCK
949+ '';
950+951in
952953{
···1537 concatLines
1538 ]);
15391540+ security.sudo.extraConfig = optionalSudoConfigForSSHAgentAuth;
1541+ security.sudo-rs.extraConfig = optionalSudoConfigForSSHAgentAuth;
1542+ };
001543}
+26-51
nixos/modules/security/sudo-rs.nix
···45let
67- inherit (pkgs) sudo sudo-rs;
8-9 cfg = config.security.sudo-rs;
1011- enableSSHAgentAuth =
12- with config.security;
13- pam.enableSSHAgentAuth && pam.sudo.sshAgentAuth;
14-15- usingMillersSudo = cfg.package.pname == sudo.pname;
16- usingSudoRs = cfg.package.pname == sudo-rs.pname;
1718 toUserString = user: if (isInt user) then "#${toString user}" else "${user}";
19 toGroupString = group: if (isInt group) then "%#${toString group}" else "%${group}";
···4142 defaultOptions = mkOption {
43 type = with types; listOf str;
44- default = optional usingMillersSudo "SETENV";
45- defaultText = literalMD ''
46- `[ "SETENV" ]` if using the default `sudo` implementation
47- '';
48 description = mdDoc ''
49 Options used for the default rules, granting `root` and the
50 `wheel` group permission to run any command as any user.
51 '';
52 };
5354- enable = mkOption {
55- type = types.bool;
56- default = false;
57- description = mdDoc ''
58- Whether to enable the {command}`sudo` command, which
59- allows non-root users to execute commands as root.
60- '';
61- };
6263- package = mkOption {
64- type = types.package;
65- default = pkgs.sudo-rs;
66- defaultText = literalExpression "pkgs.sudo-rs";
67- description = mdDoc ''
68- Which package to use for `sudo`.
69- '';
70- };
7172 wheelNeedsPassword = mkOption {
73 type = types.bool;
···208 ###### implementation
209210 config = mkIf cfg.enable {
000000211 security.sudo-rs.extraRules =
212 let
213 defaultRule = { users ? [], groups ? [], opts ? [] }: [ {
···235 # Don't edit this file. Set the NixOS options ‘security.sudo-rs.configFile’
236 # or ‘security.sudo-rs.extraRules’ instead.
237 ''
238- (optionalString enableSSHAgentAuth ''
239- # Keep SSH_AUTH_SOCK so that pam_ssh_agent_auth.so can do its magic.
240- Defaults env_keep+=SSH_AUTH_SOCK
241- '')
242- (concatStringsSep "\n" (
243- lists.flatten (
244- map (
245- rule: optionals (length rule.commands != 0) [
246- (map (user: "${toUserString user} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.users)
247- (map (group: "${toGroupString group} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.groups)
248- ]
249- ) cfg.extraRules
250- )
251- ) + "\n")
252 (optionalString (cfg.extraConfig != "") ''
253 # extraConfig
254 ${cfg.extraConfig}
···265 source = "${cfg.package.out}/bin/sudo";
266 inherit owner group setuid permissions;
267 };
268- # sudo-rs does not yet ship a sudoedit (as of v0.2.0)
269- sudoedit = mkIf usingMillersSudo {
270- source = "${cfg.package.out}/bin/sudoedit";
271- inherit owner group setuid permissions;
272- };
273 };
274275- environment.systemPackages = [ sudo ];
276277 security.pam.services.sudo = { sshAgentAuth = true; usshAuth = true; };
278- security.pam.services.sudo-i = mkIf usingSudoRs
279- { sshAgentAuth = true; usshAuth = true; };
280281 environment.etc.sudoers =
282 { source =
···285 src = pkgs.writeText "sudoers-in" cfg.configFile;
286 preferLocalBuild = true;
287 }
288- "${pkgs.buildPackages."${cfg.package.pname}"}/bin/visudo -f $src -c && cp $src $out";
289 mode = "0440";
290 };
291
···45let
6007 cfg = config.security.sudo-rs;
89+ inherit (config.security.pam) enableSSHAgentAuth;
000001011 toUserString = user: if (isInt user) then "#${toString user}" else "${user}";
12 toGroupString = group: if (isInt group) then "%#${toString group}" else "%${group}";
···3435 defaultOptions = mkOption {
36 type = with types; listOf str;
37+ default = [];
00038 description = mdDoc ''
39 Options used for the default rules, granting `root` and the
40 `wheel` group permission to run any command as any user.
41 '';
42 };
4344+ enable = mkEnableOption (mdDoc ''
45+ a memory-safe implementation of the {command}`sudo` command,
46+ which allows non-root users to execute commands as root.
47+ '');
00004849+ package = mkPackageOption pkgs "sudo-rs" { };
00000005051 wheelNeedsPassword = mkOption {
52 type = types.bool;
···187 ###### implementation
188189 config = mkIf cfg.enable {
190+ assertions = [ {
191+ assertion = ! config.security.sudo.enable;
192+ message = "`security.sudo` and `security.sudo-rs` cannot both be enabled";
193+ }];
194+ security.sudo.enable = mkDefault false;
195+196 security.sudo-rs.extraRules =
197 let
198 defaultRule = { users ? [], groups ? [], opts ? [] }: [ {
···220 # Don't edit this file. Set the NixOS options ‘security.sudo-rs.configFile’
221 # or ‘security.sudo-rs.extraRules’ instead.
222 ''
223+ (pipe cfg.extraRules [
224+ (filter (rule: length rule.commands != 0))
225+ (map (rule: [
226+ (map (user: "${toUserString user} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.users)
227+ (map (group: "${toGroupString group} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.groups)
228+ ]))
229+ flatten
230+ (concatStringsSep "\n")
231+ ])
232+ "\n"
0000233 (optionalString (cfg.extraConfig != "") ''
234 # extraConfig
235 ${cfg.extraConfig}
···246 source = "${cfg.package.out}/bin/sudo";
247 inherit owner group setuid permissions;
248 };
00000249 };
250251+ environment.systemPackages = [ cfg.package ];
252253 security.pam.services.sudo = { sshAgentAuth = true; usshAuth = true; };
254+ security.pam.services.sudo-i = { sshAgentAuth = true; usshAuth = true; };
0255256 environment.etc.sudoers =
257 { source =
···260 src = pkgs.writeText "sudoers-in" cfg.configFile;
261 preferLocalBuild = true;
262 }
263+ "${pkgs.buildPackages.sudo-rs}/bin/visudo -f $src -c && cp $src $out";
264 mode = "0440";
265 };
266
+18-17
nixos/modules/services/backup/btrbk.nix
···47 then [ "${name} ${value}" ]
48 else concatLists (mapAttrsToList (genSection name) value);
49000000000000050 sudo_doas =
51- if config.security.sudo.enable then "sudo"
52 else if config.security.doas.enable then "doas"
53 else throw "The btrbk nixos module needs either sudo or doas enabled in the configuration";
54···157 };
158 config = mkIf (sshEnabled || serviceEnabled) {
159 environment.systemPackages = [ pkgs.btrbk ] ++ cfg.extraPackages;
160- security.sudo = mkIf (sudo_doas == "sudo") {
161- extraRules = [
162- {
163- users = [ "btrbk" ];
164- commands = [
165- { command = "${pkgs.btrfs-progs}/bin/btrfs"; options = [ "NOPASSWD" ]; }
166- { command = "${pkgs.coreutils}/bin/mkdir"; options = [ "NOPASSWD" ]; }
167- { command = "${pkgs.coreutils}/bin/readlink"; options = [ "NOPASSWD" ]; }
168- # for ssh, they are not the same than the one hard coded in ${pkgs.btrbk}
169- { command = "/run/current-system/sw/bin/btrfs"; options = [ "NOPASSWD" ]; }
170- { command = "/run/current-system/sw/bin/mkdir"; options = [ "NOPASSWD" ]; }
171- { command = "/run/current-system/sw/bin/readlink"; options = [ "NOPASSWD" ]; }
172- ];
173- }
174- ];
175- };
176 security.doas = mkIf (sudo_doas == "doas") {
177 extraRules = let
178 doasCmdNoPass = cmd: { users = [ "btrbk" ]; cmd = cmd; noPass = true; };
···47 then [ "${name} ${value}" ]
48 else concatLists (mapAttrsToList (genSection name) value);
4950+ sudoRule = {
51+ users = [ "btrbk" ];
52+ commands = [
53+ { command = "${pkgs.btrfs-progs}/bin/btrfs"; options = [ "NOPASSWD" ]; }
54+ { command = "${pkgs.coreutils}/bin/mkdir"; options = [ "NOPASSWD" ]; }
55+ { command = "${pkgs.coreutils}/bin/readlink"; options = [ "NOPASSWD" ]; }
56+ # for ssh, they are not the same than the one hard coded in ${pkgs.btrbk}
57+ { command = "/run/current-system/sw/bin/btrfs"; options = [ "NOPASSWD" ]; }
58+ { command = "/run/current-system/sw/bin/mkdir"; options = [ "NOPASSWD" ]; }
59+ { command = "/run/current-system/sw/bin/readlink"; options = [ "NOPASSWD" ]; }
60+ ];
61+ };
62+63 sudo_doas =
64+ if config.security.sudo.enable || config.security.sudo-rs.enable then "sudo"
65 else if config.security.doas.enable then "doas"
66 else throw "The btrbk nixos module needs either sudo or doas enabled in the configuration";
67···170 };
171 config = mkIf (sshEnabled || serviceEnabled) {
172 environment.systemPackages = [ pkgs.btrbk ] ++ cfg.extraPackages;
173+174+ security.sudo.extraRules = mkIf (sudo_doas == "sudo") [ sudoRule ];
175+ security.sudo-rs.extraRules = mkIf (sudo_doas == "sudo") [ sudoRule ];
176+000000000000177 security.doas = mkIf (sudo_doas == "doas") {
178 extraRules = let
179 doasCmdNoPass = cmd: { users = [ "btrbk" ]; cmd = cmd; noPass = true; };
+8-11
nixos/modules/services/misc/amazon-ssm-agent.nix
···15 -r) echo "${config.system.nixos.version}";;
16 esac
17 '';
0000018in {
19 imports = [
20 (mkRenamedOptionModule [ "services" "ssm-agent" "enable" ] [ "services" "amazon-ssm-agent" "enable" ])
···5455 # Add user that Session Manager needs, and give it sudo.
56 # This is consistent with Amazon Linux 2 images.
57- security.sudo.extraRules = [
58- {
59- users = [ "ssm-user" ];
60- commands = [
61- {
62- command = "ALL";
63- options = [ "NOPASSWD" ];
64- }
65- ];
66- }
67- ];
68 # On Amazon Linux 2 images, the ssm-user user is pretty much a
69 # normal user with its own group. We do the same.
70 users.groups.ssm-user = {};
···15 -r) echo "${config.system.nixos.version}";;
16 esac
17 '';
18+19+ sudoRule = {
20+ users = [ "ssm-user" ];
21+ commands = [ { command = "ALL"; options = [ "NOPASSWD" ]; } ];
22+ };
23in {
24 imports = [
25 (mkRenamedOptionModule [ "services" "ssm-agent" "enable" ] [ "services" "amazon-ssm-agent" "enable" ])
···5960 # Add user that Session Manager needs, and give it sudo.
61 # This is consistent with Amazon Linux 2 images.
62+ security.sudo.extraRules = [ sudoRule ];
63+ security.sudo-rs.extraRules = [ sudoRule ];
64+0000000065 # On Amazon Linux 2 images, the ssm-user user is pretty much a
66 # normal user with its own group. We do the same.
67 users.groups.ssm-user = {};
···1+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+# yarn lockfile v1
3+4+5+"@org/somepack@file:vendor/orgpacks/somepack/assets":
6+ version "1.0.0"
7+8+"otherpack@file:vendor/otherpack":
9+ version "1.0.0"
···108 dontConfigure = true;
109 enableParallelBuilding = true;
11000000111 postPatch = ''
112 # aarch64 code is compiled on all targets, which causes our Apple SDK headers to error out.
113 # Since multilib doesnt work on darwin i dont know of a better way of handling this.
···108 dontConfigure = true;
109 enableParallelBuilding = true;
110111+ env = {
112+ # silence service.h error
113+ NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
114+ };
115+116 postPatch = ''
117 # aarch64 code is compiled on all targets, which causes our Apple SDK headers to error out.
118 # 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
···18 # check the release notes for compatible kernels
19 kernelCompatible =
20 if stdenv'.isx86_64 || removeLinuxDRM
21- then kernel.kernelOlder "6.6"
22 else kernel.kernelOlder "6.2";
2324 latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM
25- then linuxKernel.packages.linux_6_5
26 else linuxKernel.packages.linux_6_1;
2728 # this package should point to the latest release.
29- version = "2.2.0";
3031 tests = [
32 nixosTests.zfs.installer
33 nixosTests.zfs.stable
34 ];
3536- hash = "sha256-s1sdXSrLu6uSOmjprbUa4cFsE2Vj7JX5i75e4vRnlvg=";
37}
···18 # check the release notes for compatible kernels
19 kernelCompatible =
20 if stdenv'.isx86_64 || removeLinuxDRM
21+ then kernel.kernelOlder "6.7"
22 else kernel.kernelOlder "6.2";
2324 latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM
25+ then linuxKernel.packages.linux_6_6
26 else linuxKernel.packages.linux_6_1;
2728 # this package should point to the latest release.
29+ version = "2.2.1";
3031 tests = [
32 nixosTests.zfs.installer
33 nixosTests.zfs.stable
34 ];
3536+ hash = "sha256-2Q/Nhp3YKgMCLPNRNBq5r9U4GeuYlWMWAsjsQy3vFW4=";
37}
+4-5
pkgs/os-specific/linux/zfs/unstable.nix
···16 kernelModuleAttribute = "zfsUnstable";
17 # check the release notes for compatible kernels
18 kernelCompatible = if stdenv'.isx86_64 || removeLinuxDRM
19- then kernel.kernelOlder "6.6"
20 else kernel.kernelOlder "6.2";
2122 latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM
23- then linuxKernel.packages.linux_6_5
24 else linuxKernel.packages.linux_6_1;
2526 # this package should point to a version / git revision compatible with the latest kernel release
27 # IMPORTANT: Always use a tagged release candidate or commits from the
28 # zfs-<version>-staging branch, because this is tested by the OpenZFS
29 # maintainers.
30- version = "2.2.1-unstable-2023-10-21";
31- rev = "95785196f26e92d82cf4445654ba84e4a9671c57";
3233- hash = "sha256-s1sdXSrLu6uSOmjprbUa4cFsE2Vj7JX5i75e4vRnlvg=";
3435 isUnstable = true;
36 tests = [
···16 kernelModuleAttribute = "zfsUnstable";
17 # check the release notes for compatible kernels
18 kernelCompatible = if stdenv'.isx86_64 || removeLinuxDRM
19+ then kernel.kernelOlder "6.7"
20 else kernel.kernelOlder "6.2";
2122 latestCompatibleLinuxPackages = if stdenv'.isx86_64 || removeLinuxDRM
23+ then linuxKernel.packages.linux_6_6
24 else linuxKernel.packages.linux_6_1;
2526 # this package should point to a version / git revision compatible with the latest kernel release
27 # IMPORTANT: Always use a tagged release candidate or commits from the
28 # zfs-<version>-staging branch, because this is tested by the OpenZFS
29 # maintainers.
30+ version = "2.2.1";
03132+ hash = "sha256-2Q/Nhp3YKgMCLPNRNBq5r9U4GeuYlWMWAsjsQy3vFW4=";
3334 isUnstable = true;
35 tests = [
···585 miopen-opencl = throw "'miopen-opencl' has been replaced with 'rocmPackages.miopen-opencl'"; # Added 2023-10-08
586 mime-types = mailcap; # Added 2022-01-21
587 minizip2 = pkgs.minizip-ng; # Added 2022-12-28
0588 monero = monero-cli; # Added 2021-11-28
589 mongodb-4_0 = throw "mongodb-4_0 has been removed, it's end of life since April 2022"; # Added 2023-01-05
590 mongodb-4_2 = throw "mongodb-4_2 has been removed, it's end of life since April 2023"; # Added 2023-06-06
···585 miopen-opencl = throw "'miopen-opencl' has been replaced with 'rocmPackages.miopen-opencl'"; # Added 2023-10-08
586 mime-types = mailcap; # Added 2022-01-21
587 minizip2 = pkgs.minizip-ng; # Added 2022-12-28
588+ mirage-im = throw "'mirage-im' has been removed, as it was broken and unmaintained"; # Added 2023-11-26
589 monero = monero-cli; # Added 2021-11-28
590 mongodb-4_0 = throw "mongodb-4_0 has been removed, it's end of life since April 2022"; # Added 2023-01-05
591 mongodb-4_2 = throw "mongodb-4_2 has been removed, it's end of life since April 2023"; # Added 2023-06-06