diff --git a/nix/compile.nix b/nix/compile.nix index 61955d8a..849f971f 100644 --- a/nix/compile.nix +++ b/nix/compile.nix @@ -24,20 +24,6 @@ let extraRustComponents = [ "clippy" ]; }; - buildEnv = (drv: - { - rustc = drv.setBuildEnv; - clippy = '' - ${drv.setBuildEnv or ""} - echo - echo --- BUILDING WITH CLIPPY --- - echo - - export NIX_RUST_BUILD_FLAGS="''${NIX_RUST_BUILD_FLAGS} --deny warnings" - export RUSTC="''${CLIPPY_DRIVER}" - ''; - }.${compiler}); - /* Cargo2nix provides many overrides by default, you can take inspiration from them: https://github.com/cargo2nix/cargo2nix/blob/master/overlay/overrides.nix @@ -46,9 +32,7 @@ let */ packageOverrides = pkgs: pkgs.rustBuilder.overrides.all ++ [ - /* [1] We add some logic to compile our crates with clippy, it provides us many additional lints - - [2] We need to alter Nix hardening to make static binaries: PIE, + /* [1] We need to alter Nix hardening to make static binaries: PIE, Position Independent Executables seems to be supported only on amd64. Having this flag set either 1. make our executables crash or 2. compile as dynamic on some platforms. Here, we deactivate it. Later (find `codegenOpts`), we reactivate it for supported targets @@ -56,11 +40,11 @@ let PIE is a feature used by ASLR, which helps mitigate security issues. Learn more about Nix Hardening at: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/cc-wrapper/add-hardening.sh - [3] We want to inject the git version while keeping the build deterministic. + [2] We want to inject the git version while keeping the build deterministic. As we do not want to consider the .git folder as part of the input source, we ask the user (the CI often) to pass the value to Nix. - [4] We don't want libsodium-sys and zstd-sys to try to use pkgconfig to build against a system library. + [3] We don't want libsodium-sys and zstd-sys to try to use pkgconfig to build against a system library. However the features to do so get activated for some reason (due to a bug in cargo2nix?), so disable them manually here. */ @@ -68,7 +52,7 @@ let name = "garage"; overrideAttrs = drv: (if git_version != null then { - # [3] + # [2] preConfigure = '' ${drv.preConfigure or ""} export GIT_VERSION="${git_version}" @@ -76,86 +60,21 @@ let } else { }) // { # [1] - setBuildEnv = (buildEnv drv); - # [2] hardeningDisable = [ "pie" ]; }; }) - (pkgs.rustBuilder.rustLib.makeOverride { - name = "garage_rpc"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - - (pkgs.rustBuilder.rustLib.makeOverride { - name = "garage_db"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - - (pkgs.rustBuilder.rustLib.makeOverride { - name = "garage_util"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - - (pkgs.rustBuilder.rustLib.makeOverride { - name = "garage_table"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - - (pkgs.rustBuilder.rustLib.makeOverride { - name = "garage_block"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - - (pkgs.rustBuilder.rustLib.makeOverride { - name = "garage_model"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - - (pkgs.rustBuilder.rustLib.makeOverride { - name = "garage_api"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - - (pkgs.rustBuilder.rustLib.makeOverride { - name = "garage_web"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - - (pkgs.rustBuilder.rustLib.makeOverride { - name = "k2v-client"; - overrideAttrs = drv: { # [1] - setBuildEnv = (buildEnv drv); - }; - }) - (pkgs.rustBuilder.rustLib.makeOverride { name = "libsodium-sys"; overrideArgs = old: { - features = [ ]; # [4] + features = [ ]; # [3] }; }) (pkgs.rustBuilder.rustLib.makeOverride { name = "zstd-sys"; overrideArgs = old: { - features = [ ]; # [4] + features = [ ]; # [3] }; }) ];