enable all-features in nix for CI builds
CI is running `cargo build --all-features`, so we should be passing all the features to nix as well. The only thing this currently affects is the jemalloc_prof feature, but if we add any non-default features that affect nix in the future they should also be handled correctly now.
This commit is contained in:
parent
0fd0a5d73c
commit
c0f8253fc5
5 changed files with 23 additions and 5 deletions
2
.envrc
2
.envrc
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
use flake
|
use flake ".#${DIRENV_DEVSHELL:-default}"
|
||||||
|
|
||||||
PATH_add bin
|
PATH_add bin
|
||||||
|
|
||||||
|
|
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
|
@ -35,6 +35,9 @@ env:
|
||||||
# Custom nix binary cache if fork is being used
|
# Custom nix binary cache if fork is being used
|
||||||
ATTIC_ENDPOINT: ${{ vars.ATTIC_ENDPOINT }}
|
ATTIC_ENDPOINT: ${{ vars.ATTIC_ENDPOINT }}
|
||||||
ATTIC_PUBLIC_KEY: ${{ vars.ATTIC_PUBLIC_KEY }}
|
ATTIC_PUBLIC_KEY: ${{ vars.ATTIC_PUBLIC_KEY }}
|
||||||
|
# Use the all-features devshell instead of default, to ensure that features
|
||||||
|
# match between nix and cargo
|
||||||
|
DIRENV_DEVSHELL: all-features
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
|
@ -92,7 +95,7 @@ jobs:
|
||||||
echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > "$HOME/.direnvrc"
|
echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > "$HOME/.direnvrc"
|
||||||
nix profile install --impure --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv
|
nix profile install --impure --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv
|
||||||
direnv allow
|
direnv allow
|
||||||
nix develop --command true
|
nix develop .#all-features --command true
|
||||||
|
|
||||||
- name: Run CI tests
|
- name: Run CI tests
|
||||||
run: |
|
run: |
|
||||||
|
@ -202,7 +205,7 @@ jobs:
|
||||||
echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > "$HOME/.direnvrc"
|
echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > "$HOME/.direnvrc"
|
||||||
nix profile install --impure --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv
|
nix profile install --impure --inputs-from . nixpkgs#direnv nixpkgs#nix-direnv
|
||||||
direnv allow
|
direnv allow
|
||||||
nix develop --command true
|
nix develop .#all-features --command true
|
||||||
|
|
||||||
- name: Build static ${{ matrix.target }}
|
- name: Build static ${{ matrix.target }}
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -70,7 +70,7 @@ ci() {
|
||||||
--inputs-from "$toplevel"
|
--inputs-from "$toplevel"
|
||||||
|
|
||||||
# Keep sorted
|
# Keep sorted
|
||||||
"$toplevel#devShells.x86_64-linux.default"
|
"$toplevel#devShells.x86_64-linux.all-features"
|
||||||
attic#default
|
attic#default
|
||||||
nixpkgs#direnv
|
nixpkgs#direnv
|
||||||
nixpkgs#jq
|
nixpkgs#jq
|
||||||
|
|
|
@ -188,5 +188,9 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
devShells.default = mkDevShell scopeHostStatic;
|
devShells.default = mkDevShell scopeHostStatic;
|
||||||
|
devShells.all-features = mkDevShell
|
||||||
|
(scopeHostStatic.overrideScope (final: prev: {
|
||||||
|
main = prev.main.override { all_features = true; };
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
# Options (keep sorted)
|
# Options (keep sorted)
|
||||||
, default_features ? true
|
, default_features ? true
|
||||||
|
, all_features ? false
|
||||||
, features ? []
|
, features ? []
|
||||||
, profile ? "release"
|
, profile ? "release"
|
||||||
}:
|
}:
|
||||||
|
@ -20,13 +21,23 @@ let
|
||||||
# on the nix side depend on feature values.
|
# on the nix side depend on feature values.
|
||||||
workspaceMembers = builtins.map (member: "${inputs.self}/src/${member}")
|
workspaceMembers = builtins.map (member: "${inputs.self}/src/${member}")
|
||||||
(builtins.attrNames (builtins.readDir "${inputs.self}/src"));
|
(builtins.attrNames (builtins.readDir "${inputs.self}/src"));
|
||||||
|
crateFeatures = path:
|
||||||
|
let manifest = lib.importTOML "${path}/Cargo.toml"; in
|
||||||
|
lib.remove "default" (lib.attrNames manifest.features) ++
|
||||||
|
lib.attrNames
|
||||||
|
(lib.filterAttrs
|
||||||
|
(_: dependency: dependency.optional or false)
|
||||||
|
manifest.dependencies);
|
||||||
crateDefaultFeatures = path:
|
crateDefaultFeatures = path:
|
||||||
(lib.importTOML "${path}/Cargo.toml").features.default;
|
(lib.importTOML "${path}/Cargo.toml").features.default;
|
||||||
allDefaultFeatures = lib.unique
|
allDefaultFeatures = lib.unique
|
||||||
(lib.flatten (builtins.map crateDefaultFeatures workspaceMembers));
|
(lib.flatten (builtins.map crateDefaultFeatures workspaceMembers));
|
||||||
|
allFeatures = lib.unique
|
||||||
|
(lib.flatten (builtins.map crateFeatures workspaceMembers));
|
||||||
features' = lib.unique
|
features' = lib.unique
|
||||||
(features ++
|
(features ++
|
||||||
lib.optionals default_features allDefaultFeatures);
|
lib.optionals default_features allDefaultFeatures ++
|
||||||
|
lib.optionals all_features allFeatures);
|
||||||
|
|
||||||
featureEnabled = feature : builtins.elem feature features';
|
featureEnabled = feature : builtins.elem feature features';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue