From 372b1861038cbe3bb9e58dc8abc9fb1cf583edcf Mon Sep 17 00:00:00 2001 From: waalge Date: Wed, 19 Jun 2024 15:18:18 +0000 Subject: [PATCH] nix use rustc 1.79. Add analyzer to devshell --- flake.lock | 52 +++------------- flake.nix | 173 ++++++++++++++++++++++++++++------------------------- 2 files changed, 99 insertions(+), 126 deletions(-) diff --git a/flake.lock b/flake.lock index 1d7608817..d72b99ccd 100644 --- a/flake.lock +++ b/flake.lock @@ -18,31 +18,13 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "nixpkgs": { "locked": { - "lastModified": 1709237383, - "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "lastModified": 1718530797, + "narHash": "sha256-pup6cYwtgvzDpvpSCFh1TEUjw2zkNpk8iolbKnyFmmU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "rev": "b60ebf54c15553b393d144357375ea956f89e9a9", "type": "github" }, "original": { @@ -54,11 +36,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1706487304, - "narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=", + "lastModified": 1718428119, + "narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "90f456026d284c22b3e3497be980b2e47d0b28ac", + "rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5", "type": "github" }, "original": { @@ -77,15 +59,14 @@ }, "rust-overlay": { "inputs": { - "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1709519692, - "narHash": "sha256-+ICGcASuUGpx82io6FVkMW7Pv4dvEl1v9A0ZtBKT41A=", + "lastModified": 1718763539, + "narHash": "sha256-JHqQyO5XppLpMSKBaYlxbmPHMc4DpwuavKIch9W+hv4=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "30c3af18405567115958c577c62548bdc5a251e7", + "rev": "69fcfaebbe564d162a85cadeaadd4dec646be4a2", "type": "github" }, "original": { @@ -108,21 +89,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 10d87e312..fcfa73d83 100644 --- a/flake.nix +++ b/flake.nix @@ -5,88 +5,95 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, rust-overlay, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [ rust-overlay.overlays.default ]; + outputs = { + self, + rust-overlay, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { + inherit system; + overlays = [rust-overlay.overlays.default]; + }; + + osxDependencies = with pkgs; + lib.optionals stdenv.isDarwin + [ + darwin.apple_sdk.frameworks.Security + darwin.apple_sdk.frameworks.CoreServices + ]; + + cargoTomlContents = builtins.readFile ./crates/aiken/Cargo.toml; + version = (builtins.fromTOML cargoTomlContents).package.version; + + aiken = pkgs.rustPlatform.buildRustPackage { + inherit version; + + name = "aiken"; + + buildInputs = with pkgs; [openssl] ++ osxDependencies; + nativeBuildInputs = with pkgs; [pkg-config openssl.dev]; + + src = pkgs.lib.cleanSourceWith {src = self;}; + + cargoLock.lockFile = ./Cargo.lock; + + GIT_COMMIT_HASH_SHORT = self.shortRev or "unknown"; + postPatch = '' + substituteInPlace crates/aiken-project/src/config.rs \ + --replace "built_info::GIT_COMMIT_HASH_SHORT" \ + "Some(\"$GIT_COMMIT_HASH_SHORT\")" + ''; + + postInstall = '' + mkdir -p $out/share/zsh/site-functions + $out/bin/aiken completion zsh > $out/share/zsh/site-functions/_aiken + + mkdir -p $out/share/bash-completion/completions + $out/bin/aiken completion bash > $out/share/bash-completion/completions/aiken + + mkdir -p $out/share/fish/vendor_completions.d + $out/bin/aiken completion fish > $out/share/fish/vendor_completions.d/aiken.fish + ''; + + meta = with pkgs.lib; { + description = "Cardano smart contract language and toolchain"; + homepage = "https://github.com/aiken-lang/aiken"; + license = licenses.asl20; + mainProgram = "aiken"; }; - - osxDependencies = with pkgs; - lib.optionals stdenv.isDarwin - [ darwin.apple_sdk.frameworks.Security - darwin.apple_sdk.frameworks.CoreServices - ]; - - cargoTomlContents = builtins.readFile ./crates/aiken/Cargo.toml; - version = (builtins.fromTOML cargoTomlContents).package.version; - - aiken = pkgs.rustPlatform.buildRustPackage { - inherit version; - - name = "aiken"; - - buildInputs = with pkgs; [ openssl ] ++ osxDependencies; - nativeBuildInputs = with pkgs; [ pkg-config openssl.dev ]; - - src = pkgs.lib.cleanSourceWith { src = self; }; - - cargoLock.lockFile = ./Cargo.lock; - - GIT_COMMIT_HASH_SHORT = self.shortRev or "unknown"; - postPatch = '' - substituteInPlace crates/aiken-project/src/config.rs \ - --replace "built_info::GIT_COMMIT_HASH_SHORT" \ - "Some(\"$GIT_COMMIT_HASH_SHORT\")" - ''; - - postInstall = '' - mkdir -p $out/share/zsh/site-functions - $out/bin/aiken completion zsh > $out/share/zsh/site-functions/_aiken - - mkdir -p $out/share/bash-completion/completions - $out/bin/aiken completion bash > $out/share/bash-completion/completions/aiken - - mkdir -p $out/share/fish/vendor_completions.d - $out/bin/aiken completion fish > $out/share/fish/vendor_completions.d/aiken.fish - ''; - - meta = with pkgs.lib; { - description = "Cardano smart contract language and toolchain"; - homepage = "https://github.com/aiken-lang/aiken"; - license = licenses.asl20; - mainProgram = "aiken"; - }; - }; - - packages = { - aiken = aiken; - default = packages.aiken; - }; - - overlays.default = final: prev: { aiken = packages.aiken; }; - - gitRev = if (builtins.hasAttr "rev" self) then self.rev else "dirty"; - in { - inherit packages overlays; - - devShell = pkgs.mkShell { - buildInputs = with pkgs; - [ - pkg-config - openssl - - cargo-insta - - (pkgs.rust-bin.stable.latest.default.override { - extensions = [ "rust-src" "clippy" "rustfmt" ]; - }) - ] ++ osxDependencies; - - shellHook = '' - export GIT_REVISION=${gitRev} - ''; - }; - }); + }; + + packages = { + aiken = aiken; + default = packages.aiken; + }; + + overlays.default = final: prev: {aiken = packages.aiken;}; + + gitRev = + if (builtins.hasAttr "rev" self) + then self.rev + else "dirty"; + in { + inherit packages overlays; + + devShell = pkgs.mkShell { + buildInputs = with pkgs; + [ + pkg-config + openssl + cargo-insta + (pkgs.rust-bin.stable.latest.default.override { + extensions = ["rust-src" "clippy" "rustfmt" "rust-analyzer"]; + }) + ] + ++ osxDependencies; + + shellHook = '' + export GIT_REVISION=${gitRev} + ''; + }; + }); }