Skip to content

Commit

Permalink
Merge pull request #1594 from cachix/use-binary-wrapper
Browse files Browse the repository at this point in the history
package: use binary wrapper and preset locale archive
  • Loading branch information
domenkozar authored Nov 19, 2024
2 parents 635a222 + 69236e0 commit 6473534
Showing 1 changed file with 37 additions and 26 deletions.
63 changes: 37 additions & 26 deletions package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ pkgs.rustPlatform.buildRustPackage {
};

nativeBuildInputs = [
pkgs.makeWrapper
pkgs.pkg-config
pkgs.installShellFiles
pkgs.makeBinaryWrapper
pkgs.pkg-config
] ++ pkgs.lib.optional (!build_tasks) pkgs.sqlx-cli;

buildInputs = [ pkgs.openssl ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
buildInputs = [ pkgs.openssl ]
++ pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.darwin.apple_sdk.frameworks.SystemConfiguration;

# Force sqlx to use the prepared queries
SQLX_OFFLINE = true;
Expand All @@ -48,29 +47,41 @@ pkgs.rustPlatform.buildRustPackage {
cargo sqlx prepare --workspace
'';

postInstall = pkgs.lib.optionalString (!build_tasks) ''
wrapProgram $out/bin/devenv \
--set DEVENV_NIX ${inputs.nix.packages.${pkgs.stdenv.system}.nix} \
--prefix PATH ":" "$out/bin:${inputs.cachix.packages.${pkgs.stdenv.system}.cachix}/bin"
postInstall =
let
inherit (inputs.nix.packages.${pkgs.stdenv.system}) nix;
inherit (inputs.cachix.packages.${pkgs.stdenv.system}) cachix;

# TODO: problematic for our library...
wrapProgram $out/bin/devenv-run-tests \
--set DEVENV_NIX ${inputs.nix.packages.${pkgs.stdenv.system}.nix} \
--prefix PATH ":" "$out/bin:${inputs.cachix.packages.${pkgs.stdenv.system}.cachix}/bin"
localeArchiveFix =
pkgs.lib.optionalString (pkgs.stdenv.isLinux && (pkgs.glibcLocalesUtf8 != null)) ''
--set-default LOCALE_ARCHIVE ${pkgs.glibcLocalesUtf8}/lib/locale/locale-archive
'';
in
pkgs.lib.optionalString (!build_tasks) ''
wrapProgram $out/bin/devenv \
--prefix PATH ":" "$out/bin:${cachix}/bin" \
--set DEVENV_NIX ${nix} \
${localeArchiveFix} \
# Generate manpages
cargo xtask generate-manpages --out-dir man
installManPage man/*
# TODO: problematic for our library...
wrapProgram $out/bin/devenv-run-tests \
--prefix PATH ":" "$out/bin:${cachix}/bin" \
--set DEVENV_NIX ${nix} \
${localeArchiveFix} \
# Generate shell completions
compdir=./completions
for shell in bash fish zsh; do
cargo xtask generate-shell-completion $shell --out-dir $compdir
done
# Generate manpages
cargo xtask generate-manpages --out-dir man
installManPage man/*
installShellCompletion --cmd devenv \
--bash $compdir/devenv.bash \
--fish $compdir/devenv.fish \
--zsh $compdir/_devenv
'';
# Generate shell completions
compdir=./completions
for shell in bash fish zsh; do
cargo xtask generate-shell-completion $shell --out-dir $compdir
done
installShellCompletion --cmd devenv \
--bash $compdir/devenv.bash \
--fish $compdir/devenv.fish \
--zsh $compdir/_devenv
'';
}

0 comments on commit 6473534

Please sign in to comment.