Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and CI static builds #3765

Merged
merged 25 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
88cf6ff
Rename logging->stdout to logging->stdout_
matthewbauer Jun 25, 2020
07dae2f
Setup static building of nix
matthewbauer Jun 25, 2020
70719a9
Add -lz to end of linking
matthewbauer Jun 25, 2020
da77331
Remove lazy lookup in getHome
matthewbauer Jun 25, 2020
289558d
Add unordered_set to globals.cc header
matthewbauer Jun 25, 2020
78fadaf
fix release.nix eval
matthewbauer Jun 25, 2020
ded6589
Fixup coverage build
matthewbauer Jun 25, 2020
24da034
Add possibly missing `<string>` include
Ericson2314 Jun 29, 2020
696bb13
Fix shell.nix
Ericson2314 Jun 29, 2020
baaab2a
Add `nativeBuildInputs` to shell.nix
Ericson2314 Jun 30, 2020
d7ffe32
Merge remote-tracking branch 'origin/master' into fix-and-ci-static-b…
matthewbauer Jul 30, 2020
13ef7a0
Fix build
matthewbauer Jul 30, 2020
3537670
Only enable static on linux
matthewbauer Jul 30, 2020
39ae9a3
Merge remote-tracking branch 'upstream/master' into fix-and-ci-static…
Ericson2314 Aug 7, 2020
e12bcab
Remove duplicate buildInputs
Ericson2314 Sep 4, 2020
25f7ff1
Merge remote-tracking branch 'upstream/master' into fix-and-ci-static…
Ericson2314 Sep 4, 2020
ec14465
Separate lowdown lib and bin to be more precise
Ericson2314 Sep 4, 2020
cfe791a
stdout_ -> cout
Ericson2314 Sep 25, 2020
39de735
Merge remote-tracking branch 'upstream/master' into fix-and-ci-static…
Ericson2314 Oct 9, 2020
f6ed1a9
`build-static` -> `buildStatic` in Nix's flake
Ericson2314 Oct 15, 2020
fccef6a
Merge remote-tracking branch 'upstream/master' into fix-and-ci-static…
Ericson2314 Oct 15, 2020
64be1c1
Add missing include for MAX_PATH
Ericson2314 Oct 15, 2020
48ce627
Make a better -lz hack
Ericson2314 Oct 15, 2020
257090d
Bump Nixpkgs to hopefully fix linkrot
Ericson2314 Oct 15, 2020
1d09923
Merge remote-tracking branch 'obsidian/bump-nixpkgs' into fix-and-ci-…
Ericson2314 Oct 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 86 additions & 33 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

officialRelease = false;

systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ];
linuxSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
systems = linuxSystems ++ [ "x86_64-darwin" ];

forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);

Expand Down Expand Up @@ -60,34 +61,41 @@
"--with-sandbox-shell=${sh}/bin/busybox"
];

buildDeps =
[ bison
flex
mdbook
lowdown
autoconf-archive
autoreconfHook

curl
nativeBuildDeps =
[
buildPackages.bison
buildPackages.flex
(lib.getBin buildPackages.lowdown)
buildPackages.mdbook
buildPackages.autoconf-archive
buildPackages.autoreconfHook
buildPackages.pkgconfig

# Tests
buildPackages.git
buildPackages.mercurial
buildPackages.jq
];

buildDeps =
[ curl
bzip2 xz brotli zlib editline
openssl pkgconfig sqlite
openssl sqlite
libarchive
boost
nlohmann_json

# Tests
git
mercurial
jq
lowdown
gmock
]
++ lib.optionals stdenv.isLinux [libseccomp utillinuxMinimal]
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
++ lib.optional (stdenv.isLinux || stdenv.isDarwin)
(aws-sdk-cpp.override {
apis = ["s3" "transfer"];
customMemoryManagement = false;
});
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium;

awsDeps = lib.optional (stdenv.isLinux || stdenv.isDarwin)
(aws-sdk-cpp.override {
apis = ["s3" "transfer"];
customMemoryManagement = false;
});

propagatedDeps =
[ (boehmgc.override { enableLargeConfig = true; })
Expand All @@ -114,7 +122,8 @@

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

buildInputs = buildDeps;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ awsDeps;

propagatedBuildInputs = propagatedDeps;

Expand Down Expand Up @@ -158,14 +167,17 @@

src = self;

nativeBuildInputs =
[ buildPackages.autoconf-archive
buildPackages.autoreconfHook
buildPackages.pkgconfig
];

buildInputs =
[ autoconf-archive
autoreconfHook
nix
[ nix
curl
bzip2
xz
pkgconfig
pkgs.perl
boost
nlohmann_json
Expand Down Expand Up @@ -196,15 +208,15 @@

src = lowdown-src;

outputs = [ "out" "dev" ];
outputs = [ "out" "bin" "dev" ];

buildInputs = [ which ];
nativeBuildInputs = [ which ];

configurePhase =
''
./configure \
PREFIX=${placeholder "dev"} \
BINDIR=${placeholder "out"}/bin
BINDIR=${placeholder "bin"}/bin
'';
};

Expand All @@ -213,10 +225,12 @@
hydraJobs = {

# Binary package for various platforms.
build = nixpkgs.lib.genAttrs systems (system: nixpkgsFor.${system}.nix);
build = nixpkgs.lib.genAttrs systems (system: self.packages.${system}.nix);

build-static = nixpkgs.lib.genAttrs linuxSystems (system: self.packages.${system}.nix-static);

# Perl bindings for various platforms.
perlBindings = nixpkgs.lib.genAttrs systems (system: nixpkgsFor.${system}.nix.perl-bindings);
perlBindings = nixpkgs.lib.genAttrs systems (system: self.packages.${system}.nix.perl-bindings);

# Binary tarball for various platforms, containing a Nix store
# with the closure of 'nix' package, and the second half of
Expand Down Expand Up @@ -322,7 +336,8 @@

enableParallelBuilding = true;

buildInputs = buildDeps ++ propagatedDeps;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps ++ awsDeps;

dontInstall = false;

Expand Down Expand Up @@ -427,10 +442,47 @@
checks = forAllSystems (system: {
binaryTarball = self.hydraJobs.binaryTarball.${system};
perlBindings = self.hydraJobs.perlBindings.${system};
} // nixpkgs.lib.optionalAttrs (builtins.elem system linuxSystems) {
build-static = self.hydraJobs.build-static.${system};
Ericson2314 marked this conversation as resolved.
Show resolved Hide resolved
});

packages = forAllSystems (system: {
inherit (nixpkgsFor.${system}) nix;
} // nixpkgs.lib.optionalAttrs (builtins.elem system linuxSystems) {
nix-static = let
nixpkgs = nixpkgsFor.${system}.pkgsStatic;
in with commonDeps nixpkgs; nixpkgs.stdenv.mkDerivation {
name = "nix-${version}";

src = self;

VERSION_SUFFIX = versionSuffix;

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

nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps;

configureFlags = [ "--sysconfdir=/etc" ];

enableParallelBuilding = true;

makeFlags = "profiledir=$(out)/etc/profile.d";

doCheck = true;

installFlags = "sysconfdir=$(out)/etc";

postInstall = ''
mkdir -p $doc/nix-support
echo "doc manual $doc/share/doc/nix/manual" >> $doc/nix-support/hydra-build-products
'';

doInstallCheck = true;
installCheckFlags = "sysconfdir=$(out)/etc";

stripAllList = ["bin"];
};
});

defaultPackage = forAllSystems (system: self.packages.${system}.nix);
Expand All @@ -444,7 +496,8 @@

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

buildInputs = buildDeps ++ propagatedDeps ++ perlDeps;
nativeBuildInputs = nativeBuildDeps;
buildInputs = buildDeps ++ propagatedDeps ++ awsDeps ++ perlDeps;

inherit configureFlags;

Expand Down
2 changes: 1 addition & 1 deletion mk/programs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ define build-program
$$(eval $$(call create-dir, $$(_d)))

$$($(1)_PATH): $$($(1)_OBJS) $$(_libs) | $$(_d)/
$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE))
$$(trace-ld) $(CXX) -o $$@ $$(LDFLAGS) $$(GLOBAL_LDFLAGS) $$($(1)_OBJS) $$($(1)_LDFLAGS) $$(foreach lib, $$($(1)_LIBS), $$($$(lib)_LDFLAGS_USE)) -lz
Ericson2314 marked this conversation as resolved.
Show resolved Hide resolved

$(1)_INSTALL_DIR ?= $$(bindir)

Expand Down
1 change: 1 addition & 0 deletions src/libstore/globals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <thread>
#include <dlfcn.h>
#include <sys/utsname.h>
#include <unordered_set>

#include <nlohmann/json.hpp>

Expand Down
48 changes: 0 additions & 48 deletions src/libutil/lazy.hh

This file was deleted.

2 changes: 1 addition & 1 deletion src/libutil/logging.hh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public:
virtual void writeToStdout(std::string_view s);

template<typename... Args>
inline void stdout(const std::string & fs, const Args & ... args)
inline void stdout_(const std::string & fs, const Args & ... args)
{
boost::format f(fs);
formatHelper(f, args...);
Expand Down
1 change: 1 addition & 0 deletions src/libutil/types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <list>
#include <set>
#include <string>
#include <map>
#include <vector>

Expand Down
6 changes: 3 additions & 3 deletions src/libutil/util.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "lazy.hh"
#include "util.hh"
#include "affinity.hh"
#include "sync.hh"
Expand Down Expand Up @@ -512,7 +511,8 @@ std::string getUserName()
}


static Lazy<Path> getHome2([]() {
static Path getHome2()
Ericson2314 marked this conversation as resolved.
Show resolved Hide resolved
{
auto homeDir = getEnv("HOME");
if (!homeDir) {
std::vector<char> buf(16384);
Expand All @@ -524,7 +524,7 @@ static Lazy<Path> getHome2([]() {
homeDir = pw->pw_dir;
}
return *homeDir;
});
};

Path getHome() { return getHome2(); }

Expand Down
2 changes: 1 addition & 1 deletion src/nix/add-to-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand
store->addToStore(info, source);
}

logger->stdout("%s", store->printStorePath(info.path));
logger->stdout_("%s", store->printStorePath(info.path));
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/nix/eval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct CmdEval : MixJSON, InstallableCommand
printValueAsJSON(*state, true, *v, jsonOut, context);
} else {
state->forceValueDeep(*v);
logger->stdout("%s", *v);
logger->stdout_("%s", *v);
}
}
};
Expand Down
Loading