Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: df45c65aaea5
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 700e21d6dac4
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Jan 31, 2018

  1. Revert "Restore "nixUnstable: rename to nix-unstable""

    This reverts commit 695027f.
    
    We really can't have "nix-env -i nix" *not* upgrade nixUnstable to a
    newer nixStable. For instance, it would cause "nix upgrade-nix" to
    produce a user environment with collisions.
    edolstra committed Jan 31, 2018
    Copy the full SHA
    ef35164 View commit details
  2. Copy the full SHA
    75a2028 View commit details
  3. nix-daemon.nix: Updates for Nix 2.0

    * The environment variables NIX_CONF_DIR, NIX_BUILD_HOOK and
      NIX_REMOTE are no longer needed.
    
    * A /bin/sh (from busybox) is provided by default in sandboxes.
    
    * Various options were renamed.
    edolstra committed Jan 31, 2018
    1
    Copy the full SHA
    700e21d View commit details
Showing with 40 additions and 36 deletions.
  1. +31 −27 nixos/modules/services/misc/nix-daemon.nix
  2. +9 −9 pkgs/tools/package-management/nix/default.nix
58 changes: 31 additions & 27 deletions nixos/modules/services/misc/nix-daemon.nix
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ let

nix = cfg.package.out;

isNix112 = versionAtLeast (getVersion nix) "1.12pre";
isNix20 = versionAtLeast (getVersion nix) "2.0pre";

makeNixBuildUser = nr:
{ name = "nixbld${toString nr}";
@@ -26,32 +26,40 @@ let

nixConf =
let
# If we're using sandbox for builds, then provide /bin/sh in
# the sandbox as a bind-mount to bash. This means we also need to
# include the entire closure of bash.
# In Nix < 2.0, If we're using sandbox for builds, then provide
# /bin/sh in the sandbox as a bind-mount to bash. This means we
# also need to include the entire closure of bash. Nix >= 2.0
# provides a /bin/sh by default.
sh = pkgs.stdenv.shell;
binshDeps = pkgs.writeReferencesToFile sh;
in
pkgs.runCommand "nix.conf" {extraOptions = cfg.extraOptions; } ''
extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done)
pkgs.runCommand "nix.conf" { extraOptions = cfg.extraOptions; inherit binshDeps; } ''
${optionalString (!isNix20) ''
extraPaths=$(for i in $(cat binshDeps); do if test -d $i; then echo $i; fi; done)
''}
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!
build-users-group = nixbld
build-max-jobs = ${toString (cfg.maxJobs)}
build-cores = ${toString (cfg.buildCores)}
build-use-sandbox = ${if (builtins.isBool cfg.useSandbox) then boolToString cfg.useSandbox else cfg.useSandbox}
build-sandbox-paths = ${toString cfg.sandboxPaths} /bin/sh=${sh} $(echo $extraPaths)
binary-caches = ${toString cfg.binaryCaches}
trusted-binary-caches = ${toString cfg.trustedBinaryCaches}
binary-cache-public-keys = ${toString cfg.binaryCachePublicKeys}
${if isNix20 then "max-jobs" else "build-max-jobs"} = ${toString (cfg.maxJobs)}
${if isNix20 then "cores" else "build-cores"} = ${toString (cfg.buildCores)}
${if isNix20 then "sandbox" else "build-use-sandbox"} = ${if (builtins.isBool cfg.useSandbox) then boolToString cfg.useSandbox else cfg.useSandbox}
${if isNix20 then "extra-sandbox-paths" else "build-sandbox-paths"} = ${toString cfg.sandboxPaths} ${optionalString (!isNix20) "/bin/sh=${sh} $(echo $extraPaths)"}
${if isNix20 then "substituters" else "binary-caches"} = ${toString cfg.binaryCaches}
${if isNix20 then "trusted-substituters" else "trusted-binary-caches"} = ${toString cfg.trustedBinaryCaches}
${if isNix20 then "trusted-public-keys" else "binary-cache-public-keys"} = ${toString cfg.binaryCachePublicKeys}
auto-optimise-store = ${boolToString cfg.autoOptimiseStore}
${optionalString cfg.requireSignedBinaryCaches ''
signed-binary-caches = *
${if isNix20 then ''
require-sigs = ${if cfg.requireSignedBinaryCaches then "true" else "false"}
'' else ''
signed-binary-caches = ${if cfg.requireSignedBinaryCaches then "*" else ""}
''}
trusted-users = ${toString cfg.trustedUsers}
allowed-users = ${toString cfg.allowedUsers}
${optionalString (isNix20 && !cfg.distributedBuilds) ''
builders =
''}
$extraOptions
END
'';
@@ -377,8 +385,9 @@ in
systemd.sockets.nix-daemon.wantedBy = [ "sockets.target" ];

systemd.services.nix-daemon =
{ path = [ nix pkgs.openssl.bin pkgs.utillinux config.programs.ssh.package ]
++ optionals cfg.distributedBuilds [ pkgs.gzip ];
{ path = [ nix pkgs.utillinux ]
++ optionals cfg.distributedBuilds [ config.programs.ssh.package pkgs.gzip ]
++ optionals (!isNix20) [ pkgs.openssl.bin ];

environment = cfg.envVars
// { CURL_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt"; }
@@ -396,31 +405,26 @@ in
};

nix.envVars =
{ NIX_CONF_DIR = "/etc/nix";
}
optionalAttrs (!isNix20) {
NIX_CONF_DIR = "/etc/nix";

// optionalAttrs (!isNix112) {
# Enable the copy-from-other-stores substituter, which allows
# builds to be sped up by copying build results from remote
# Nix stores. To do this, mount the remote file system on a
# subdirectory of /run/nix/remote-stores.
NIX_OTHER_STORES = "/run/nix/remote-stores/*/nix";
}

// optionalAttrs cfg.distributedBuilds {
NIX_BUILD_HOOK =
if isNix112 then
"${nix}/libexec/nix/build-remote"
else
"${nix}/libexec/nix/build-remote.pl";
// optionalAttrs (cfg.distributedBuilds && !isNix20) {
NIX_BUILD_HOOK = "${nix}/libexec/nix/build-remote.pl";
};

# Set up the environment variables for running Nix.
environment.sessionVariables = cfg.envVars //
{ NIX_PATH = concatStringsSep ":" cfg.nixPath;
};

environment.extraInit =
environment.extraInit = optionalString (!isNix20)
''
# Set up secure multi-user builds: non-root users build through the
# Nix daemon.
18 changes: 9 additions & 9 deletions pkgs/tools/package-management/nix/default.nix
Original file line number Diff line number Diff line change
@@ -26,22 +26,22 @@ let
inherit name src;
version = lib.getVersion name;

is112 = lib.versionAtLeast version "1.12pre";
is20 = lib.versionAtLeast version "2.0pre";

VERSION_SUFFIX = lib.optionalString fromGit suffix;

outputs = [ "out" "dev" "man" "doc" ];

nativeBuildInputs =
[ pkgconfig ]
++ lib.optionals (!is112) [ perl ]
++ lib.optionals (!is20) [ perl ]
++ lib.optionals fromGit [ autoreconfHook autoconf-archive bison flex libxml2 libxslt docbook5 docbook5_xsl ];

buildInputs = [ curl openssl sqlite xz ]
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
++ lib.optionals fromGit [ brotli ] # Since 1.12
++ lib.optional stdenv.isLinux libseccomp
++ lib.optional ((stdenv.isLinux || stdenv.isDarwin) && is112)
++ lib.optional ((stdenv.isLinux || stdenv.isDarwin) && is20)
(aws-sdk-cpp.override {
apis = ["s3"];
customMemoryManagement = false;
@@ -65,11 +65,11 @@ let
"--disable-init-state"
"--enable-gc"
]
++ lib.optionals (!is112) [
++ lib.optionals (!is20) [
"--with-dbi=${perlPackages.DBI}/${perl.libPrefix}"
"--with-dbd-sqlite=${perlPackages.DBDSQLite}/${perl.libPrefix}"
"--with-www-curl=${perlPackages.WWWCurl}/${perl.libPrefix}"
] ++ lib.optionals (is112 && stdenv.isLinux) [
] ++ lib.optionals (is20 && stdenv.isLinux) [
"--with-sandbox-shell=${sh}/bin/busybox"
];

@@ -160,13 +160,13 @@ in rec {
}) // { perl-bindings = nixStable; };

nixUnstable = (lib.lowPrio (common rec {
name = "nix-unstable-1.12${suffix}";
suffix = "pre5873_b76e282d";
name = "nix-2.0${suffix}";
suffix = "pre5889_c287d731";
src = fetchFromGitHub {
owner = "NixOS";
repo = "nix";
rev = "b76e282da8824b679368370e43c994e588994a9a";
sha256 = "11clfc8fh8q8s3k4canmn36xhh3zcl2zd8wwddp4pdvdal16b5n6";
rev = "c287d7312103bae5e154c0c4dd493371a22ea207";
sha256 = "1dwhz93dlk62prh3wfwf8vxfcqjdn21wk0ms65kf5r8ahkfgpgq4";
};
fromGit = true;
})) // { perl-bindings = perl-bindings { nix = nixUnstable; }; };