From 2ba4cb13aae43b948b408617579c61fd336f924b Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Fri, 9 Aug 2024 10:38:54 -0700 Subject: [PATCH] Cleanup old package files --- crane.nix | 122 ---------------------------------------------------- package.nix | 58 ------------------------- 2 files changed, 180 deletions(-) delete mode 100644 crane.nix delete mode 100644 package.nix diff --git a/crane.nix b/crane.nix deleted file mode 100644 index a30fed8..0000000 --- a/crane.nix +++ /dev/null @@ -1,122 +0,0 @@ -{ stdenv -, pkgs -, lib -, crane -, rust -, rust-bin -, nix-gitignore -, supportedSystems -, nix-flake -}: - -let - inherit (stdenv.hostPlatform) system; - - nightlyVersion = "2024-03-28"; - rustNightly = (pkgs.rust-bin.nightly.${nightlyVersion}.default.override { - extensions = [ "rust-src" "rust-analyzer-preview" ]; - targets = cargoTargets; - }).overrideAttrs (old: { - # Remove the propagated libiconv since we want to add our static version - depsTargetTargetPropagated = lib.filter (d: d.pname != "libiconv") - (lib.flatten (old.depsTargetTargetPropagated or [ ])); - }); - - # For easy cross-compilation in devShells - # We are just composing the pkgsCross.*.stdenv.cc together - crossPlatforms = - let - makeCrossPlatform = crossSystem: - let - pkgsCross = - if crossSystem == system then pkgs - else - import pkgs.path { - inherit system crossSystem; - overlays = [ nix-flake.overlays.default ]; - }; - - rustTargetSpec = rust.toRustTargetSpec pkgsCross.pkgsStatic.stdenv.hostPlatform; - rustTargetSpecUnderscored = builtins.replaceStrings [ "-" ] [ "_" ] rustTargetSpec; - - cargoLinkerEnv = lib.strings.toUpper "CARGO_TARGET_${rustTargetSpecUnderscored}_LINKER"; - cargoCcEnv = "CC_${rustTargetSpecUnderscored}"; # for ring - - ccbin = "${pkgsCross.stdenv.cc}/bin/${pkgsCross.stdenv.cc.targetPrefix}cc"; - in - { - name = crossSystem; - value = { - inherit rustTargetSpec; - cc = pkgsCross.stdenv.cc; - pkgs = pkgsCross; - buildInputs = makeBuildInputs pkgsCross; - env = { - "${cargoLinkerEnv}" = ccbin; - "${cargoCcEnv}" = ccbin; - }; - }; - }; - systems = lib.filter (s: s == system || lib.hasInfix "linux" s) supportedSystems - # Cross from aarch64-darwin -> x86_64-darwin doesn't work yet - # Hopefully the situation will improve with the SDK bumps - ++ lib.optional (system == "x86_64-darwin") "aarch64-darwin"; - in - builtins.listToAttrs (map makeCrossPlatform systems); - - cargoTargets = lib.mapAttrsToList (_: p: p.rustTargetSpec) crossPlatforms; - cargoCrossEnvs = lib.foldl (acc: p: acc // p.env) { } (builtins.attrValues crossPlatforms); - - makeBuildInputs = pkgs: - [ pkgs.nix - pkgs.boost # needed for clippy - ] - ++ lib.optionals pkgs.stdenv.isDarwin [ - pkgs.darwin.apple_sdk.frameworks.Security - (pkgs.libiconv.override { enableStatic = true; enableShared = false; }) - ]; - - buildFor = system: - let - crossPlatform = crossPlatforms.${system}; - inherit (crossPlatform) pkgs; - craneLib = (crane.mkLib pkgs).overrideToolchain rustNightly; - crateName = craneLib.crateNameFromCargoToml { - cargoToml = ./magic-nix-cache/Cargo.toml; - }; - - src = nix-gitignore.gitignoreSource [ ] ./.; - - commonArgs = { - inherit (crateName) pname version; - inherit src; - - nativeBuildInputs = [ pkgs.pkg-config ]; - - buildInputs = makeBuildInputs pkgs; - - cargoExtraArgs = "--target ${crossPlatform.rustTargetSpec}"; - - cargoVendorDir = craneLib.vendorMultipleCargoDeps { - inherit (craneLib.findCargoFiles src) cargoConfigs; - cargoLockList = [ - ./Cargo.lock - "${rustNightly.passthru.availableComponents.rust-src}/lib/rustlib/src/rust/Cargo.lock" - ]; - }; - } // crossPlatform.env; - - crate = craneLib.buildPackage (commonArgs // { - cargoArtifacts = craneLib.buildDepsOnly commonArgs; - - # The resulting executable must be standalone - allowedRequisites = [ ]; - }); - in - crate; -in -{ - inherit crossPlatforms cargoTargets cargoCrossEnvs rustNightly; - - magic-nix-cache = buildFor system; -} diff --git a/package.nix b/package.nix deleted file mode 100644 index 63dbc30..0000000 --- a/package.nix +++ /dev/null @@ -1,58 +0,0 @@ -{ lib -, stdenv -, rustPlatform -, pkg-config -, installShellFiles -, nix -, boost -, darwin -, rust-analyzer -, clippy -, rustfmt -}: - -let - ignoredPaths = [ ".github" "target" "book" ]; - version = (builtins.fromTOML (builtins.readFile ./magic-nix-cache/Cargo.toml)).package.version; -in -rustPlatform.buildRustPackage rec { - pname = "magic-nix-cache"; - inherit version; - - src = lib.cleanSourceWith { - filter = name: type: !(type == "directory" && builtins.elem (baseNameOf name) ignoredPaths); - src = lib.cleanSource ./.; - }; - - nativeBuildInputs = [ - pkg-config - installShellFiles - rust-analyzer - clippy - rustfmt - ]; - - buildInputs = [ - nix - boost - ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ - SystemConfiguration - ]); - - cargoLock = { - lockFile = ./Cargo.lock; - allowBuiltinFetchGit = true; - }; - - ATTIC_DISTRIBUTOR = "attic"; - - # Hack to fix linking on macOS. - NIX_CFLAGS_LINK = lib.optionalString stdenv.isDarwin "-lc++abi"; - - # Recursive Nix is not stable yet - doCheck = false; - - postFixup = '' - rm -f $out/nix-support/propagated-build-inputs - ''; -}