Unverified Commit e87e89f3 authored by John Ericson's avatar John Ericson Committed by GitHub
Browse files

nixVersions.{nix_2_28,nix_2_26}: switch simplified meson build (#393509)

parents 95bf21ec 28d057ef
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@

builtins.mapAttrs (
  attr: pkg:
  if lib.versionAtLeast pkg.version "2.26" then
  if lib.versionAtLeast pkg.version "2.29pre" then
    pkg.overrideScope (finalScope: prevScope: { aws-sdk-cpp = null; })
  else
    pkg.override { withAWS = false; }
+3 −2
Original line number Diff line number Diff line
@@ -14,24 +14,25 @@
stdenv.mkDerivation rec {
  pname = "nix-eval-jobs";
  version = "2.28.0";

  src = fetchFromGitHub {
    owner = "nix-community";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-v5n6t49X7MOpqS9j0FtI6TWOXvxuZMmGsp2OfUK5QfA=";
  };

  buildInputs = [
    boost
    nix
    curl
    nlohmann_json
  ];

  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    # nlohmann_json can be only discovered via cmake files
    cmake
  ];

  # Since this package is intimately tied to a specific Nix release, we
+287 −0
Original line number Diff line number Diff line
{
  lib,
  fetchFromGitHub,
  version,
  suffix ? "",
  hash ? null,
  src ? fetchFromGitHub {
    owner = "NixOS";
    repo = "nix";
    rev = version;
    inherit hash;
  },
  patches ? [ ],
  maintainers ? lib.teams.nix.members ++ [
    lib.maintainers.lovesegfault
    lib.maintainers.artturin
  ],
  self_attribute_name,
}@args:
assert (hash == null) -> (src != null);
{
  stdenv,
  bison,
  boehmgc,
  boost,
  brotli,
  busybox-sandbox-shell,
  bzip2,
  callPackage,
  cmake,
  curl,
  darwin,
  doxygen,
  editline,
  flex,
  git,
  gtest,
  jq,
  lib,
  libarchive,
  libblake3,
  libcpuid,
  libgit2,
  libsodium,
  lowdown,
  lowdown-unsandboxed,
  toml11,
  man,
  meson,
  ninja,
  mdbook,
  mdbook-linkcheck,
  nlohmann_json,
  nixosTests,
  openssl,
  perl,
  python3,
  pkg-config,
  rapidcheck,
  rsync,
  Security,
  sqlite,
  util-linuxMinimal,
  xz,
  enableDocumentation ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
  enableStatic ? stdenv.hostPlatform.isStatic,
  withAWS ? !enableStatic && (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin),
  aws-sdk-cpp,
  withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp,
  libseccomp,

  confDir,
  stateDir,
  storeDir,

  # passthru tests
  pkgsi686Linux,
  pkgsStatic,
  runCommand,
  pkgs,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "nix";

  version = "${version}${suffix}";
  VERSION_SUFFIX = suffix;

  inherit src patches;

  outputs =
    [
      "out"
      "dev"
    ]
    ++ lib.optionals enableDocumentation [
      "man"
      "doc"
    ];

  hardeningEnable = lib.optionals (!stdenv.hostPlatform.isDarwin) [ "pie" ];

  hardeningDisable = [
    "shadowstack"
  ] ++ lib.optional stdenv.hostPlatform.isMusl "fortify";

  nativeCheckInputs = [
    git
    man
  ];

  nativeBuildInputs =
    [
      bison
      cmake
      flex
      jq
      meson
      ninja
      pkg-config
      rsync
    ]
    ++ lib.optionals enableDocumentation [
      (lib.getBin lowdown-unsandboxed)
      mdbook
      mdbook-linkcheck
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      util-linuxMinimal
    ]
    ++ lib.optionals enableDocumentation [
      python3
      doxygen
    ];

  buildInputs =
    [
      boost
      brotli
      bzip2
      curl
      editline
      libgit2
      libsodium
      lowdown
      openssl
      sqlite
      toml11
      xz
    ]
    ++ lib.optionals (lib.versionAtLeast version "2.26") [
      libblake3
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      Security
    ]
    ++ lib.optionals stdenv.hostPlatform.isx86_64 [
      libcpuid
    ]
    ++ lib.optionals withLibseccomp [
      libseccomp
    ]
    ++ lib.optionals withAWS [
      aws-sdk-cpp
    ]
    ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
      darwin.apple_sdk.libs.sandbox
    ];

  propagatedBuildInputs = [
    boehmgc
    nlohmann_json
    libarchive
  ];

  checkInputs = [
    gtest
    rapidcheck
  ];

  postPatch = ''
    patchShebangs --build tests
  '';

  preConfigure =
    # Copy libboost_context so we don't get all of Boost in our closure.
    # https://github.com/NixOS/nixpkgs/issues/45462
    lib.optionalString (!enableStatic) ''
      mkdir -p $out/lib
      cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
      rm -f $out/lib/*.a
      ${lib.optionalString stdenv.hostPlatform.isLinux ''
        chmod u+w $out/lib/*.so.*
        patchelf --set-rpath $out/lib:${lib.getLib stdenv.cc.cc}/lib $out/lib/libboost_thread.so.*
      ''}
    '';

  dontUseCmakeConfigure = true;

  mesonFlags =
    [
      (lib.mesonBool "bindings" false)
      (lib.mesonOption "libstore:store-dir" storeDir)
      (lib.mesonOption "libstore:localstatedir" stateDir)
      (lib.mesonOption "libstore:sysconfdir" confDir)
      (lib.mesonEnable "libutil:cpuid" stdenv.hostPlatform.isx86_64)
      (lib.mesonEnable "libstore:seccomp-sandboxing" withLibseccomp)
      (lib.mesonBool "libstore:embedded-sandbox-shell" (
        stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isStatic
      ))
      (lib.mesonBool "doc-gen" enableDocumentation)
    ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      (lib.mesonOption "libstore:sandbox-shell" "${busybox-sandbox-shell}/bin/busybox")
      # RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50
    ]
    ++ lib.optionals (stdenv.cc.isGNU && !enableStatic) [
      # TODO: do we still need this?
      # "--enable-lto"
    ];

  doCheck = true;

  # socket path becomes too long otherwise
  preInstallCheck =
    lib.optionalString stdenv.hostPlatform.isDarwin ''
      export TMPDIR=$NIX_BUILD_TOP
    ''
    # See https://github.com/NixOS/nix/issues/5687
    + lib.optionalString (stdenv.hostPlatform.system == "aarch64-linux") ''
      echo "exit 0" > tests/functional/flakes/show.sh
    ''
    + ''
      # nixStatic otherwise does not find its man pages in tests.
      export MANPATH=$man/share/man:$MANPATH
    '';

  separateDebugInfo = stdenv.hostPlatform.isLinux && enableStatic;

  passthru = {
    inherit aws-sdk-cpp boehmgc;

    # TODO:
    perl-bindings = perl.pkgs.toPerlModule (
      callPackage ./nix-perl.nix {
        nix = finalAttrs.finalPackage;
        inherit Security;
      }
    );

    tests = import ./tests.nix {
      inherit
        runCommand
        version
        src
        lib
        stdenv
        pkgs
        pkgsi686Linux
        pkgsStatic
        nixosTests
        self_attribute_name
        ;
      nix = finalAttrs.finalPackage;
    };
  };

  # point 'nix edit' and ofborg at the file that defines the attribute,
  # not this common file.
  pos = builtins.unsafeGetAttrPos "version" args;
  meta = with lib; {
    description = "Powerful package manager that makes package management reliable and reproducible";
    longDescription = ''
      Nix is a powerful package manager for Linux and other Unix systems that
      makes package management reliable and reproducible. It provides atomic
      upgrades and rollbacks, side-by-side installation of multiple versions of
      a package, multi-user package management and easy setup of build
      environments.
    '';
    homepage = "https://nixos.org/";
    license = licenses.lgpl21Plus;
    inherit maintainers;
    platforms = platforms.unix;
    outputsToInstall = [ "out" ] ++ optional enableDocumentation "man";
    mainProgram = "nix";
  };
})
+31 −34
Original line number Diff line number Diff line
@@ -20,9 +20,11 @@
let

  # Called for Nix < 2.26
  common =
  commonAutoconf =
    args:
    nixDependencies.callPackage (import ./common.nix ({ inherit lib fetchFromGitHub; } // args)) {
    nixDependencies.callPackage
      (import ./common-autoconf.nix ({ inherit lib fetchFromGitHub; } // args))
      {
        inherit
          Security
          storeDir
@@ -36,6 +38,19 @@ let
            nixDependencies.aws-sdk-cpp-old;
      };

  # Called for Nix == 2.28. Transitional until we always use
  # per-component packages.
  commonMeson =
    args:
    nixDependencies.callPackage (import ./common-meson.nix ({ inherit lib fetchFromGitHub; } // args)) {
      inherit
        Security
        storeDir
        stateDir
        confDir
        ;
    };

  # https://github.com/NixOS/nix/pull/7585
  patch-monitorfdhup = fetchpatch2 {
    name = "nix-7585-monitor-fd-hup.patch";
@@ -140,7 +155,7 @@ lib.makeExtensible (
  (
    {
      nix_2_3 =
        (common {
        (commonAutoconf {
          version = "2.3.18";
          hash = "sha256-jBz2Ub65eFYG+aWgSI3AJYvLSghio77fWQiIW1svA9U=";
          patches = [
@@ -155,47 +170,29 @@ lib.makeExtensible (
            enableParallelChecking = false;
          };

      nix_2_24 = common {
      nix_2_24 = commonAutoconf {
        version = "2.24.14";
        hash = "sha256-SthMCsj6POjawLnJq9+lj/UzObX9skaeN1UGmMZiwTY=";
        self_attribute_name = "nix_2_24";
      };

      nix_2_25 = common {
      nix_2_25 = commonAutoconf {
        version = "2.25.5";
        hash = "sha256-9xrQhrqHCSqWsQveykZvG/ZMu0se66fUQw3xVSg6BpQ=";
        self_attribute_name = "nix_2_25";
      };

      nixComponents_2_26 = nixDependencies.callPackage ./modular/packages.nix rec {
      nix_2_26 = commonMeson {
        version = "2.26.3";
        inherit (self.nix_2_24.meta) maintainers;
        otherSplices = generateSplicesForNixComponents "nixComponents_2_26";
        src = fetchFromGitHub {
          owner = "NixOS";
          repo = "nix";
          tag = version;
          hash = "sha256-5ZV8YqU8mfFmoAMiUEuBqNwk0T3vUR//x1D12BiYCeY=";
        };
        hash = "sha256-R+HAPvD+AjiyRHZP/elkvka33G499EKT8ntyF/EPPRI=";
        self_attribute_name = "nix_2_28";
      };

      # Note, this might eventually become an alias, as packages should
      # depend on the components they need in `nixComponents_2_26`.
      nix_2_26 = addTests "nix_2_26" self.nixComponents_2_26.nix-everything;

      nixComponents_2_28 = nixDependencies.callPackage ./modular/packages.nix rec {
      nix_2_28 = commonMeson {
        version = "2.28.1";
        inherit (self.nix_2_24.meta) maintainers;
        otherSplices = generateSplicesForNixComponents "nixComponents_2_28";
        src = fetchFromGitHub {
          owner = "NixOS";
          repo = "nix";
          rev = version;
        hash = "sha256-R+HAPvD+AjiyRHZP/elkvka33G499EKT8ntyF/EPPRI=";
        self_attribute_name = "nix_2_28";
      };
      };

      nix_2_28 = addTests "nix_2_28" self.nixComponents_2_28.nix-everything;

      nixComponents_git = nixDependencies.callPackage ./modular/packages.nix rec {
        version = "2.29pre20250407_${lib.substring 0 8 src.rev}";
Loading