aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-03-24 10:28:53 +0100
committerAlex Auvolat <alex@adnab.me>2022-03-24 14:23:47 +0100
commit055c94450c00fe3c6605da32650b5a0391e900bf (patch)
tree77e31cc2bb74fa0c31f966504ec55681db837864
parent5c7e8a5d1742f82039be75d84103c73379f2f6ca (diff)
downloadgarage-kube-feature-flag.tar.gz
garage-kube-feature-flag.zip
Compile kuberetes-discovery only when release=truekube-feature-flag
-rw-r--r--default.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/default.nix b/default.nix
index 053176f7..21a413b2 100644
--- a/default.nix
+++ b/default.nix
@@ -47,6 +47,13 @@ in let
];
};
+ /*
+ Cargo2nix provides many overrides by default, you can take inspiration from them:
+ https://github.com/cargo2nix/cargo2nix/blob/master/overlay/overrides.nix
+
+ You can have a complete list of the available options by looking at the overriden object, mkcrate:
+ https://github.com/cargo2nix/cargo2nix/blob/master/overlay/mkcrate.nix
+ */
overrides = pkgs.rustBuilder.overrides.all ++ [
/*
[1] We need to alter Nix hardening to be able to statically compile: PIE,
@@ -73,6 +80,21 @@ in let
'';
} else {});
})
+
+ /*
+ We ship some parts of the code disabled by default by putting them behind a flag.
+ It speeds up the compilation (when the feature is not required) and released crates have less dependency by default (less attack surface, disk space, etc.).
+ But we want to ship these additional features when we release Garage.
+ In the end, we chose to exclude all features from debug builds while putting (all of) them in the release builds.
+ Currently, the only feature of Garage is kubernetes-discovery from the garage_rpc crate.
+ */
+ (pkgs.rustBuilder.rustLib.makeOverride {
+ name = "garage_rpc";
+ overrideArgs = old:
+ {
+ features = if release then [ "kubernetes-discovery" ] else [];
+ };
+ })
];
packageFun = import ./Cargo.nix;