From 3290074618e70a5e131e1e41fcb8f57a1f6b670a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Sun, 24 Nov 2024 00:32:11 +0100 Subject: [PATCH] clean implem part 1 --- default.nix | 40 ++++++++++++++++++++-------------------- package.nix | 21 ++++----------------- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/default.nix b/default.nix index 17003c77..8454fcee 100644 --- a/default.nix +++ b/default.nix @@ -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; diff --git a/package.nix b/package.nix index 0f537d02..dbc1c205 100644 --- a/package.nix +++ b/package.nix @@ -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;