Skip to content

Commit

Permalink
Cross-compilation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tathougies committed Oct 27, 2018
1 parent 591ba73 commit 4177dc3
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 5 deletions.
6 changes: 3 additions & 3 deletions nixos/modules/config/networking.nix
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ in
# /etc/protocols: IP protocol numbers.
"protocols".source = pkgs.iana-etc + "/etc/protocols";

# /etc/rpc: RPC program numbers.
"rpc".source = pkgs.glibc.out + "/etc/rpc";

# /etc/hosts: Hostname-to-IP mappings.
"hosts".text =
let oneToString = set : ip : ip + " " + concatStringsSep " " ( getAttr ip set );
Expand Down Expand Up @@ -251,6 +248,9 @@ in
"resolv.conf".source = "${pkgs.systemd}/lib/systemd/resolv.conf";
} // optionalAttrs (config.services.resolved.enable && dnsmasqResolve) {
"dnsmasq-resolv.conf".source = "/run/systemd/resolve/resolv.conf";
} // optionalAttrs (!pkgs.stdenv.hostPlatform.isMusl) {
# /etc/rpc: RPC program numbers.
"rpc".source = pkgs.glibc.out + "/etc/rpc";
};

networking.proxy.envVars =
Expand Down
4 changes: 3 additions & 1 deletion nixos/modules/config/system-path.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ let
pkgs.diffutils
pkgs.findutils
pkgs.gawk
pkgs.glibc # for ldd, getent
(if pkgs.stdenv.hostPlatform.isMusl
then pkgs.musl-utils
else pkgs.glibc) # for ldd, getent
pkgs.gnugrep
pkgs.gnupatch
pkgs.gnused
Expand Down
4 changes: 3 additions & 1 deletion nixos/modules/system/activation/activation-script.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ let
[ coreutils
gnugrep
findutils
glibc # needed for getent
(if pkgs.stdenv.hostPlatform.isMusl
then pkgs.musl-utils
else glibc) # needed for getent
shadow
nettools # needed for hostname
utillinux # needed for mount and mountpoint
Expand Down
42 changes: 42 additions & 0 deletions pkgs/os-specific/linux/musl-utils/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ stdenv, lib, musl, ... }:

with lib;

let
getent_c = builtins.fetchurl {
url = https://raw.githubusercontent.com/alpinelinux/aports/89a718d88ec7466e721f3bbe9ede5ffe58061d78/main/musl/getent.c;
sha256 = "0b4jqnsmv1hjgcz7db3vd61k682aphl59c3yhwya2q7mkc6g48xk";
};

getconf_c = builtins.fetchurl {
url = https://raw.githubusercontent.com/alpinelinux/aports/89a718d88ec7466e721f3bbe9ede5ffe58061d78/main/musl/getconf.c;
sha256 = "0z14ml5343p5gapxw9fnbn2r72r7v2gk8662iifjrblh6sxhqzfq";
};

iconv_c = builtins.fetchurl {
url = https://raw.githubusercontent.com/alpinelinux/aports/89a718d88ec7466e721f3bbe9ede5ffe58061d78/main/musl/iconv.c;
sha256 = "1mzxnc2ncq8lw9x6n7p00fvfklc9p3wfv28m68j0dfz5l8q2k6pp";
};

in stdenv.mkDerivation rec {
name = "musl-utils-${version}";
version = "1.1.20";

buildInputs = [ musl ];

unpackPhase = "true";

buildPhase = ''
${getBin stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc ${getent_c} -o getent
${getBin stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc ${getconf_c} -o getconf
${getBin stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc ${iconv_c} -o iconv
'';

installPhase = ''
mkdir -p $out/bin
cp getent $out/bin/getent
cp getconf $out/bin/getconf
cp iconv $out/bin/iconv
ln -s ${musl}/lib/libc.so $out/bin/ldd
'';
}
1 change: 1 addition & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14662,6 +14662,7 @@ with pkgs;
multipath-tools = callPackage ../os-specific/linux/multipath-tools { };

musl = callPackage ../os-specific/linux/musl { };
musl-utils = callPackage ../os-specific/linux/musl-utils { };

nettools = if stdenv.isLinux then callPackage ../os-specific/linux/net-tools { }
else unixtools.nettools;
Expand Down

0 comments on commit 4177dc3

Please sign in to comment.