aboutsummaryrefslogtreecommitdiff
path: root/nix/compile.nix
diff options
context:
space:
mode:
authorAlex <lx@deuxfleurs.fr>2025-01-13 10:19:53 +0000
committerAlex <lx@deuxfleurs.fr>2025-01-13 10:19:53 +0000
commit39ac034de55c7040b61a08ecb95c58afa983501c (patch)
tree9776372019bdc60906e65e0021a09bf4b5d856c5 /nix/compile.nix
parent4b1a7fb5e3c2f6a58780165955e49d8e24a1d018 (diff)
parent8ddb0dd485cf8290b7e3462f5614ca6d858ea8c3 (diff)
downloadgarage-39ac034de55c7040b61a08ecb95c58afa983501c.tar.gz
garage-39ac034de55c7040b61a08ecb95c58afa983501c.zip
Merge pull request 'update toolchain' (#924) from nix-update into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/924
Diffstat (limited to 'nix/compile.nix')
-rw-r--r--nix/compile.nix97
1 files changed, 8 insertions, 89 deletions
diff --git a/nix/compile.nix b/nix/compile.nix
index c9cbebd5..2755f5be 100644
--- a/nix/compile.nix
+++ b/nix/compile.nix
@@ -1,4 +1,4 @@
-{ system, target ? null, pkgsSrc, cargo2nixOverlay, compiler ? "rustc"
+{ system, target ? null, pkgsSrc, cargo2nixOverlay
, release ? false, git_version ? null, features ? null, }:
let
@@ -20,24 +20,10 @@ let
};
toolchainOptions = {
- rustVersion = "1.77.0";
+ rustVersion = "1.78.0";
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]
};
})
];