git.delta.rocks / jrsonnet / refs/commits / a6dd70c0570f

difftreelog

ci build current binaries with crane

Yaroslav Bolyukin2024-03-25parent: #c2313a2.patch.diff
in: master

5 files changed

modifiedflake.lockdiffbeforeafterboth
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,25 @@
 {
   "nodes": {
+    "crane": {
+      "inputs": {
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1711299236,
+        "narHash": "sha256-6/JsyozOMKN8LUGqWMopKTSiK8N79T8Q+hcxu2KkTXg=",
+        "owner": "ipetkov",
+        "repo": "crane",
+        "rev": "880573f80d09e18a11713f402b9e6172a085449f",
+        "type": "github"
+      },
+      "original": {
+        "owner": "ipetkov",
+        "repo": "crane",
+        "type": "github"
+      }
+    },
     "flake-utils": {
       "inputs": {
         "systems": "systems"
@@ -35,6 +55,7 @@
     },
     "root": {
       "inputs": {
+        "crane": "crane",
         "flake-utils": "flake-utils",
         "nixpkgs": "nixpkgs",
         "rust-overlay": "rust-overlay"
modifiedflake.nixdiffbeforeafterboth
--- a/flake.nix
+++ b/flake.nix
@@ -5,14 +5,21 @@
     flake-utils.url = "github:numtide/flake-utils";
     rust-overlay = {
       url = "github:oxalica/rust-overlay";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+        flake-utils.follows = "flake-utils";
+      };
+    };
+    crane = {
+      url = "github:ipetkov/crane";
       inputs.nixpkgs.follows = "nixpkgs";
-      inputs.flake-utils.follows = "flake-utils";
     };
   };
   outputs = {
     nixpkgs,
     flake-utils,
     rust-overlay,
+    crane,
     ...
   }:
     flake-utils.lib.eachDefaultSystem (
@@ -22,16 +29,8 @@
           overlays = [rust-overlay.overlays.default];
           config.allowUnsupportedSystem = true;
         };
-        lib = pkgs.lib;
-        rust =
-          (pkgs.rustChannelOf {
-            date = "2024-01-10";
-            channel = "nightly";
-          })
-          .default
-          .override {
-            extensions = ["rust-src" "miri" "rust-analyzer" "clippy"];
-          };
+        rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
+        craneLib = (crane.mkLib pkgs).overrideToolchain rust;
       in {
         packages = rec {
           default = jrsonnet;
@@ -40,19 +39,19 @@
           jsonnet = pkgs.callPackage ./nix/jsonnet.nix {};
           # I didn't managed to build it, and nixpkgs version is marked as broken
           # haskell-jsonnet = pkgs.callPackage ./nix/haskell-jsonnet.nix { };
+
           jrsonnet = pkgs.callPackage ./nix/jrsonnet.nix {
-            rustPlatform = pkgs.makeRustPlatform {
-              rustc = rust;
-              cargo = rust;
-            };
+            inherit craneLib;
           };
           jrsonnet-nightly = pkgs.callPackage ./nix/jrsonnet.nix {
-            rustPlatform = pkgs.makeRustPlatform {
-              rustc = rust;
-              cargo = rust;
-            };
+            inherit craneLib;
             withNightlyFeatures = true;
           };
+          jrsonnet-experimental = pkgs.callPackage ./nix/jrsonnet.nix {
+            inherit craneLib;
+            withExperimentalFeatures = true;
+          };
+
           jrsonnet-release = pkgs.callPackage ./nix/jrsonnet-release.nix {
             rustPlatform = pkgs.makeRustPlatform {
               rustc = rust;
@@ -115,20 +114,9 @@
             ];
           };
         };
-        packagesCross = lib.genAttrs ["mingwW64"] (crossSystem: let
-          callPackage = pkgs.pkgsCross.${crossSystem}.callPackage;
-        in {
-          jrsonnet = callPackage ./nix/jrsonnet.nix {
-            # rustPlatform = pkgs.makeRustPlatform {
-            #   rustc = rust;
-            #   cargo = rust;
-            # };
-          };
-        });
-        devShells.default = pkgs.mkShell {
+        devShells.default = craneLib.devShell {
           nativeBuildInputs = with pkgs; [
             alejandra
-            rust
             cargo-edit
             cargo-asm
             cargo-outdated
modifiednix/jrsonnet-release.nixdiffbeforeafterboth
--- a/nix/jrsonnet-release.nix
+++ b/nix/jrsonnet-release.nix
@@ -1,6 +1,8 @@
-{ lib, fetchFromGitHub, rustPlatform, runCommand, makeWrapper }:
-
-
+{
+  fetchFromGitHub,
+  rustPlatform,
+  makeWrapper,
+}:
 rustPlatform.buildRustPackage rec {
   pname = "jrsonnet";
   version = "pre9";
@@ -13,11 +15,10 @@
   };
   cargoHash = "sha256-y2YiktT1h263vpFaC+kRL8yaAWQThhEkS+NSQ6B6Ylk=";
 
-
-  cargoTestFlags = [ "--package=jrsonnet --features=mimalloc,legacy-this-file" ];
-  cargoBuildFlags = [ "--package=jrsonnet --features=mimalloc,legacy-this-file" ];
+  cargoTestFlags = ["--package=jrsonnet --features=mimalloc,legacy-this-file"];
+  cargoBuildFlags = ["--package=jrsonnet --features=mimalloc,legacy-this-file"];
 
-  buildInputs = [ makeWrapper ];
+  buildInputs = [makeWrapper];
 
   postInstall = ''
     wrapProgram $out/bin/jrsonnet --add-flags "--max-stack=200000 --os-stack=200000"
modifiednix/jrsonnet.nixdiffbeforeafterboth
--- a/nix/jrsonnet.nix
+++ b/nix/jrsonnet.nix
@@ -1,33 +1,24 @@
 {
   lib,
-  rustPlatform,
-  runCommand,
+  craneLib,
   makeWrapper,
   withNightlyFeatures ? false,
+  withExperimentalFeatures ? false,
   forBenchmarks ? false,
 }:
-with lib; let
-  filteredSrc = builtins.path {
-    name = "jrsonnet-src-filtered";
-    filter = path: type: !(builtins.baseNameOf path == "flake.nix" || builtins.baseNameOf path == "nix");
-    path = ../.;
-  };
-
-  # for some reason, filteredSrc hash still depends on nix directory contents
-  # Moving it into a CA store drops leftover references
-  src =
-    runCommand "jrsonnet-src"
-    {
-      __contentAddressed = true;
-    } "cp -r '${filteredSrc}' $out";
-in
-  rustPlatform.buildRustPackage rec {
-    inherit src;
+with lib;
+  craneLib.buildPackage rec {
+    src = lib.cleanSourceWith {
+      src = ../.;
+      filter = path: type:
+        (lib.hasSuffix "\.jsonnet" path)
+        || (craneLib.filterCargoSources path type);
+    };
     pname = "jrsonnet";
-    version = "current${optionalString withNightlyFeatures "-nightly"}";
+    version = "current${optionalString withNightlyFeatures "-nightly"}${optionalString withExperimentalFeatures "-experimental"}";
 
     cargoTestFlags = [
-      "--features=mimalloc,legacy-this-file${optionalString withNightlyFeatures ",nightly"}"
+      "--features=mimalloc,legacy-this-file${optionalString withNightlyFeatures ",nightly"}${optionalString withExperimentalFeatures ",experimental"}"
     ];
     cargoBuildFlags = cargoTestFlags;
 
@@ -37,8 +28,4 @@
     postInstall = optionalString forBenchmarks ''
       wrapProgram $out/bin/jrsonnet --add-flags "--max-stack=200000 --os-stack=200000"
     '';
-
-    cargoLock = {
-      lockFile = ../Cargo.lock;
-    };
   }
modifiedrust-toolchain.tomldiffbeforeafterboth
1[toolchain]1[toolchain]
2channel = "nightly-2023-10-28"2channel = "nightly-2024-01-10"
3components = ["rustfmt", "clippy"]3components = ["rustfmt", "clippy", "rust-analyzer", "rust-src"]
44