git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #109626 from holymonson/darwin-impure-cmds

darwin: add impure-cmds

commit0829a518621f95aea784e8fd68c42d497a9a8946 authorSandro <sandro.jaeckel@gmail.com> dateWed 3 Feb 2021, 18:11 (6 years ago) parent7cbec405f1d105
3 files changed+38−2
pkgs/os-specific/darwin/impure-cmds/default.nix+34 pkgs/top-level/all-packages.nix+1−1 pkgs/top-level/darwin-packages.nix+3−1
pkgs/os-specific/darwin/impure-cmds/default.nixnew file+34
@@ -0,0 +1,34 @@
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
pkgs/top-level/all-packages.nix+1−1
@@ -8039,7 +8039,7 @@ in
80398039
80408040 subsurface = libsForQt514.callPackage ../applications/misc/subsurface { };
80418041
8042− sudo = callPackage ../tools/security/sudo { };
8042+ sudo = if stdenv.isDarwin then darwin.sudo else callPackage ../tools/security/sudo { };
80438043
80448044 suidChroot = callPackage ../tools/system/suid-chroot { };
80458045
pkgs/top-level/darwin-packages.nix+3−1
@@ -4,9 +4,11 @@
44
55let
66 apple-source-releases = callPackage ../os-specific/darwin/apple-source-releases { };
7+
8+ impure-cmds = callPackage ../os-specific/darwin/impure-cmds { };
79in
810
9−(apple-source-releases // {
11+(impure-cmds // apple-source-releases // {
1012
1113 callPackage = newScope (darwin.apple_sdk.frameworks // darwin);
1214