Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package: rework to make consistent with upstream nixpkgs version #1648

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
let
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
mkPackage = pkgs: import ./package.nix { inherit pkgs inputs; };
mkPackage = pkgs: pkgs.callPackage ./package.nix {
inherit (inputs.nix.packages.${pkgs.stdenv.system}) nix;
inherit (inputs.cachix.packages.${pkgs.stdenv.system}) cachix;
};
mkDevShellPackage = config: pkgs: import ./src/devenv-devShell.nix { inherit config pkgs; };
mkDocOptions = pkgs:
let
Expand Down
48 changes: 29 additions & 19 deletions package.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
{ pkgs, inputs, build_tasks ? false }:
{ lib
, stdenv
, makeBinaryWrapper
, installShellFiles
, rustPlatform
, nix
, cachix
, darwin
, sqlx-cli
, openssl
, pkg-config
, glibcLocalesUtf8
, build_tasks ? false
}:

pkgs.rustPlatform.buildRustPackage {
rustPlatform.buildRustPackage {
pname = "devenv";
version = "1.3.1";

# WARN: building this from src/modules/tasks.nix fails.
# There is something being prepended to the path, hence the .*.
src = pkgs.lib.sourceByRegex ./. [
src = lib.sourceByRegex ./. [
".*\.cargo(/.*)?$"
".*Cargo\.toml"
".*Cargo\.lock"
Expand All @@ -30,45 +43,42 @@ pkgs.rustPlatform.buildRustPackage {
};

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

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

# Force sqlx to use the prepared queries
SQLX_OFFLINE = true;
# A local database to use for preparing queries
DATABASE_URL = "sqlite:nix-eval-cache.db";

preBuild = pkgs.lib.optionalString (!build_tasks) ''
preBuild = lib.optionalString (!build_tasks) ''
cargo sqlx database setup --source devenv-eval-cache/migrations
cargo sqlx prepare --workspace
'';

postInstall =
let
inherit (inputs.nix.packages.${pkgs.stdenv.system}) nix;
inherit (inputs.cachix.packages.${pkgs.stdenv.system}) cachix;

localeArchiveFix =
pkgs.lib.optionalString (pkgs.stdenv.isLinux && (pkgs.glibcLocalesUtf8 != null)) ''
--set-default LOCALE_ARCHIVE ${pkgs.glibcLocalesUtf8}/lib/locale/locale-archive
setDefaultLocaleArchive =
lib.optionalString (glibcLocalesUtf8 != null) ''
--set-default LOCALE_ARCHIVE ${glibcLocalesUtf8}/lib/locale/locale-archive
'';
in
pkgs.lib.optionalString (!build_tasks) ''
lib.optionalString (!build_tasks) ''
wrapProgram $out/bin/devenv \
--prefix PATH ":" "$out/bin:${cachix}/bin" \
--set DEVENV_NIX ${nix} \
${localeArchiveFix} \
${setDefaultLocaleArchive} \

# TODO: problematic for our library...
wrapProgram $out/bin/devenv-run-tests \
--prefix PATH ":" "$out/bin:${cachix}/bin" \
--set DEVENV_NIX ${nix} \
${localeArchiveFix} \
${setDefaultLocaleArchive} \

# Generate manpages
cargo xtask generate-manpages --out-dir man
Expand Down
6 changes: 5 additions & 1 deletion src/modules/tasks.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{ pkgs, lib, config, ... }@inputs:
let
types = lib.types;
devenv = import ./../../package.nix { inherit pkgs inputs; build_tasks = true; };
devenv = pkgs.callPackage ./../../package.nix {
build_tasks = true;
inherit (inputs.nix.packages.${pkgs.stdenv.system}) nix;
inherit (inputs.cachix.packages.${pkgs.stdenv.system}) cachix;
};
taskType = types.submodule
({ name, config, ... }:
let
Expand Down
Loading