clean implem part 1

This commit is contained in:
Clément DOUIN
2024-11-24 00:32:11 +01:00
parent 2b115dd284
commit 3290074618
2 changed files with 24 additions and 37 deletions
+20 -20
View File
@@ -6,13 +6,15 @@ let
else { crossSystem.config = target; }
);
inherit (pkgs) lib hostPlatform;
fenix = import (fetchTarball "https://github.com/soywod/fenix/archive/main.tar.gz") { };
mkToolchain = import ./rust-toolchain.nix fenix;
rustToolchain = mkToolchain.fromTarget {
lib = pkgs.lib;
targetSystem = pkgs.hostPlatform.config;
inherit lib;
targetSystem = hostPlatform.config;
};
rustPlatform = pkgs.makeRustPlatform {
@@ -21,47 +23,45 @@ let
};
himalaya = import ./package.nix {
inherit rustPlatform;
darwin = pkgs.darwin;
windows = pkgs.windows;
lib = pkgs.lib;
hostPlatform = pkgs.hostPlatform;
inherit lib hostPlatform rustPlatform;
fetchFromGitHub = pkgs.fetchFromGitHub;
pkg-config = pkgs.pkg-config;
stdenv = pkgs.stdenv;
darwin = pkgs.darwin;
installShellFiles = false;
installShellCompletions = false;
installManPages = false;
notmuch = pkgs.notmuch;
gpgme = pkgs.gpgme;
stdenv = pkgs.stdenv;
pkgsCross = pkgs.pkgsCross;
};
in
himalaya.overrideAttrs (drv: {
version = "1.0.0";
postInstall = ''
export WINEPREFIX="$(mktemp -d)"
postInstall = lib.optionalString hostPlatform.isWindows ''
export WINEPREFIX="$(${lib.getExe pkgs.buildPackages.mktemp} -d)"
'' + ''
mkdir -p $out/bin/share/{applications,completions,man,services}
cp assets/himalaya.desktop $out/bin/share/applications/
cp assets/himalaya-watch@.service $out/bin/share/services/
cd $out/bin
${pkgs.hostPlatform.emulator pkgs.buildPackages} himalaya man ./share/man
${pkgs.hostPlatform.emulator pkgs.buildPackages} himalaya completion bash > ./share/completions/himalaya.bash
${pkgs.hostPlatform.emulator pkgs.buildPackages} himalaya completion elvish > ./share/completions/himalaya.elvish
${pkgs.hostPlatform.emulator pkgs.buildPackages} himalaya completion fish > ./share/completions/himalaya.fish
${pkgs.hostPlatform.emulator pkgs.buildPackages} himalaya completion powershell > ./share/completions/himalaya.powershell
${pkgs.hostPlatform.emulator pkgs.buildPackages} himalaya completion zsh > ./share/completions/himalaya.zsh
${hostPlatform.emulator pkgs.buildPackages} himalaya man ./share/man
${hostPlatform.emulator pkgs.buildPackages} himalaya completion bash > ./share/completions/himalaya.bash
${hostPlatform.emulator pkgs.buildPackages} himalaya completion elvish > ./share/completions/himalaya.elvish
${hostPlatform.emulator pkgs.buildPackages} himalaya completion fish > ./share/completions/himalaya.fish
${hostPlatform.emulator pkgs.buildPackages} himalaya completion powershell > ./share/completions/himalaya.powershell
${hostPlatform.emulator pkgs.buildPackages} himalaya completion zsh > ./share/completions/himalaya.zsh
tar -czf himalaya.tgz himalaya* share
${lib.getExe pkgs.buildPackages.gnutar} -czf himalaya.tgz himalaya* share
mv himalaya.tgz ../
${pkgs.buildPackages.zip}/bin/zip -r himalaya.zip himalaya* share
${lib.getExe pkgs.buildPackages.zip} -r himalaya.zip himalaya* share
mv himalaya.zip ../
'';
src = pkgs.nix-gitignore.gitignoreSource [ ] ./.;
cargoDeps = rustPlatform.importCargoLock {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
+4 -17
View File
@@ -1,24 +1,20 @@
{ lib
, darwin
, windows
, hostPlatform
, rustPlatform
, fetchFromGitHub
, hostPlatform
, stdenv
, pkg-config
, darwin
, installShellFiles
, installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
, installManPages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform
, notmuch
, gpgme
, pkgsCross
, buildNoDefaultFeatures ? false
, buildFeatures ? [ ]
, cargoLock ? null
}:
rustPlatform.buildRustPackage rec {
inherit buildNoDefaultFeatures buildFeatures cargoLock;
inherit buildNoDefaultFeatures buildFeatures;
pname = "himalaya";
version = "1.0.0-beta.4";
@@ -32,24 +28,15 @@ rustPlatform.buildRustPackage rec {
cargoHash = "sha256-YS8IamapvmdrOPptQh2Ef9Yold0IK1XIeGs0kDIQ5b8=";
NIX_BUILD_CORES = 4;
# CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
TARGET_CC = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc";
CARGO_BUILD_RUSTFLAGS = [ "-Ctarget-feature=+crt-static" "-Clinker=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" ];
# CARGO_BUILD_RUSTFLAGS = [ "-Clinker=${stdenv.cc}/bin/${stdenv.cc.targetPrefix}cc" ];
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
CARGO_BUILD_RUSTFLAGS = [ "-Ctarget-feature=+crt-static" ];
doCheck = false;
auditable = false;
strictDeps = true;
cargoTestFlags = [
# Only run lib tests (unit tests)
# All other tests are integration tests which should not be run with Nix build
"--lib"
];
depsBuildBuild = [ stdenv.cc windows.pthreads ];
nativeBuildInputs = [ ]
++ lib.optional (installManPages || installShellCompletions) installShellFiles;