1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-13 20:30:02 +00:00

system: use preferLocalBuild for simple derivations

Most of the builds like system.build.etc will be faster when built
locally, they also don't depend on CC.
This commit is contained in:
Daiderd Jordan 2018-01-21 13:46:30 +01:00
parent b761ee79a3
commit dc33fe3d89
No known key found for this signature in database
GPG key ID: D02435D05B810C96
3 changed files with 46 additions and 40 deletions

View file

@ -16,31 +16,33 @@ let
sh = pkgs.stdenv.shell;
binshDeps = pkgs.writeReferencesToFile sh;
in
pkgs.runCommand "nix.conf" { extraOptions = cfg.extraOptions; } ''
cat > $out <<END
# WARNING: this file is generated from the nix.* options in
# your NixOS configuration, typically
# /etc/nixos/configuration.nix. Do not edit it!
${optionalString config.services.nix-daemon.enable ''
build-users-group = nixbld
''}
build-max-jobs = ${toString cfg.maxJobs}
build-cores = ${toString cfg.buildCores}
build-use-sandbox = ${if (builtins.isBool cfg.useSandbox) then (if cfg.useSandbox then "true" else "false") else cfg.useSandbox}
${optionalString (cfg.sandboxPaths != []) ''
build-sandbox-paths = ${toString cfg.sandboxPaths}
''}
binary-caches = ${toString cfg.binaryCaches}
trusted-binary-caches = ${toString cfg.trustedBinaryCaches}
binary-cache-public-keys = ${toString cfg.binaryCachePublicKeys}
${optionalString cfg.requireSignedBinaryCaches ''
signed-binary-caches = *
''}
trusted-users = ${toString cfg.trustedUsers}
allowed-users = ${toString cfg.allowedUsers}
$extraOptions
END
'';
pkgs.runCommandNoCC "nix.conf"
{ preferLocalBuild = true; extraOptions = cfg.extraOptions; }
''
cat > $out <<END
# WARNING: this file is generated from the nix.* options in
# your NixOS configuration, typically
# /etc/nixos/configuration.nix. Do not edit it!
${optionalString config.services.nix-daemon.enable ''
build-users-group = nixbld
''}
build-max-jobs = ${toString cfg.maxJobs}
build-cores = ${toString cfg.buildCores}
build-use-sandbox = ${if (builtins.isBool cfg.useSandbox) then (if cfg.useSandbox then "true" else "false") else cfg.useSandbox}
${optionalString (cfg.sandboxPaths != []) ''
build-sandbox-paths = ${toString cfg.sandboxPaths}
''}
binary-caches = ${toString cfg.binaryCaches}
trusted-binary-caches = ${toString cfg.trustedBinaryCaches}
binary-cache-public-keys = ${toString cfg.binaryCachePublicKeys}
${optionalString cfg.requireSignedBinaryCaches ''
signed-binary-caches = *
''}
trusted-users = ${toString cfg.trustedUsers}
allowed-users = ${toString cfg.allowedUsers}
$extraOptions
END
'';
in
{

View file

@ -31,12 +31,14 @@ in
config = {
system.build.etc = pkgs.runCommand "etc" {} ''
mkdir -p $out/etc
cd $out/etc
${concatMapStringsSep "\n" (attr: "mkdir -p $(dirname '${attr.target}')") etc}
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") etc}
'';
system.build.etc = pkgs.runCommandNoCC "etc"
{ preferLocalBuild = true; }
''
mkdir -p $out/etc
cd $out/etc
${concatMapStringsSep "\n" (attr: "mkdir -p $(dirname '${attr.target}')") etc}
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") etc}
'';
system.activationScripts.etc.text = ''
# Set up the statically computed bits of /etc.

View file

@ -84,15 +84,17 @@ in
config = {
system.build.launchd = pkgs.runCommand "launchd" {} ''
mkdir -p $out/Library/LaunchAgents $out/Library/LaunchDaemons $out/user/Library/LaunchAgents
cd $out/Library/LaunchAgents
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") launchAgents}
cd $out/Library/LaunchDaemons
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") launchDaemons}
cd $out/user/Library/LaunchAgents
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") userLaunchAgents}
'';
system.build.launchd = pkgs.runCommandNoCC "launchd"
{ preferLocalBuild = true; }
''
mkdir -p $out/Library/LaunchAgents $out/Library/LaunchDaemons $out/user/Library/LaunchAgents
cd $out/Library/LaunchAgents
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") launchAgents}
cd $out/Library/LaunchDaemons
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") launchDaemons}
cd $out/user/Library/LaunchAgents
${concatMapStringsSep "\n" (attr: "ln -s '${attr.source}' '${attr.target}'") userLaunchAgents}
'';
system.activationScripts.launchd.text = ''
# Set up launchd services in /Library/LaunchAgents and /Library/LaunchDaemons