Unverified Commit 1636ec1b authored by Domen Kožar's avatar Domen Kožar Committed by GitHub
Browse files

devenv: fix locale warnings, install shell completions, and more (#367567)

parents b467e92d aa9162f5
Loading
Loading
Loading
Loading
+33 −12
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  makeWrapper,
  makeBinaryWrapper,
  installShellFiles,
  rustPlatform,
  testers,
  cachix,
  darwin,
  sqlx-cli,
  nixVersions,
  openssl,
  pkg-config,
  glibcLocalesUtf8,
  devenv, # required to run version test
}:

@@ -55,19 +55,40 @@ rustPlatform.buildRustPackage {
  '';

  nativeBuildInputs = [
    makeWrapper
    installShellFiles
    makeBinaryWrapper
    pkg-config
    sqlx-cli
  ];

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

  postInstall =
    let
      setDefaultLocaleArchive = lib.optionalString (glibcLocalesUtf8 != null) ''
        --set-default LOCALE_ARCHIVE ${glibcLocalesUtf8}/lib/locale/locale-archive
      '';
    in
    ''
      wrapProgram $out/bin/devenv \
        --prefix PATH ":" "$out/bin:${cachix}/bin" \
        --set DEVENV_NIX ${devenv_nix} \
        ${setDefaultLocaleArchive}

      # Generate manpages
      cargo xtask generate-manpages --out-dir man
      installManPage man/*

      # Generate shell completions
      compdir=./completions
      for shell in bash fish zsh; do
        cargo xtask generate-shell-completion $shell --out-dir $compdir
      done

  postInstall = ''
    wrapProgram $out/bin/devenv --set DEVENV_NIX ${devenv_nix} --prefix PATH ":" "$out/bin:${cachix}/bin"
      installShellCompletion --cmd devenv \
        --bash $compdir/devenv.bash \
        --fish $compdir/devenv.fish \
        --zsh $compdir/_devenv
    '';

  passthru.tests = {