darwin: add impure-cmds

On darwin, there are some commands neither opensource nor able to build in nixpkgs.
We have no choice but to use those system-shipped impure ones.

+38 -2
+34
pkgs/os-specific/darwin/impure-cmds/default.nix
··· 1 + { lib, runCommandLocal }: 2 + 3 + # On darwin, there are some commands neither opensource nor able to build in nixpkgs. 4 + # We have no choice but to use those system-shipped impure ones. 5 + 6 + let 7 + commands = { 8 + ditto = "/usr/bin/ditto"; # ditto is not opensource 9 + sudo = "/usr/bin/sudo"; # sudo must be owned by uid 0 and have the setuid bit set 10 + }; 11 + 12 + mkImpureDrv = name: path: 13 + runCommandLocal "${name}-impure-darwin" { 14 + __impureHostDeps = [ path ]; 15 + 16 + meta = { 17 + platforms = lib.platforms.darwin; 18 + }; 19 + } '' 20 + if ! [ -x ${path} ]; then 21 + echo Cannot find command ${path} 22 + exit 1 23 + fi 24 + 25 + mkdir -p $out/bin 26 + ln -s ${path} $out/bin 27 + 28 + manpage="/usr/share/man/man1/${name}.1" 29 + if [ -f $manpage ]; then 30 + mkdir -p $out/share/man/man1 31 + ln -s $manpage $out/share/man/man1 32 + fi 33 + ''; 34 + in lib.mapAttrs mkImpureDrv commands
+1 -1
pkgs/top-level/all-packages.nix
··· 7901 7901 7902 7902 subsurface = libsForQt514.callPackage ../applications/misc/subsurface { }; 7903 7903 7904 - sudo = callPackage ../tools/security/sudo { }; 7904 + sudo = if stdenv.isDarwin then darwin.sudo else callPackage ../tools/security/sudo { }; 7905 7905 7906 7906 suidChroot = callPackage ../tools/system/suid-chroot { }; 7907 7907
+3 -1
pkgs/top-level/darwin-packages.nix
··· 4 4 5 5 let 6 6 apple-source-releases = callPackage ../os-specific/darwin/apple-source-releases { }; 7 + 8 + impure-cmds = callPackage ../os-specific/darwin/impure-cmds { }; 7 9 in 8 10 9 - (apple-source-releases // { 11 + (impure-cmds // apple-source-releases // { 10 12 11 13 callPackage = newScope (darwin.apple_sdk.frameworks // darwin); 12 14