nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
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
6let
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 =
13 name: path:
14 runCommandLocal "${name}-impure-darwin"
15 {
16 __impureHostDeps = [ path ];
17
18 meta = {
19 platforms = lib.platforms.darwin;
20 };
21 }
22 ''
23 if ! [ -x ${path} ]; then
24 echo Cannot find command ${path}
25 exit 1
26 fi
27
28 mkdir -p $out/bin
29 ln -s ${path} $out/bin
30
31 manpage="/usr/share/man/man1/${name}.1"
32 if [ -f $manpage ]; then
33 mkdir -p $out/share/man/man1
34 ln -s $manpage $out/share/man/man1
35 fi
36 '';
37in
38lib.mapAttrs mkImpureDrv commands