From ee653392e3f2f65c7904bad5ffa5e0f49fd325f7 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Sat, 9 May 2026 14:09:25 -0400 Subject: [PATCH] feat(flake): migrate to crane --- default.nix | 14 +++++------- flake.lock | 64 ++++++++++++++++++++++++++++++++++++++++------------- flake.nix | 31 +++++++++----------------- 3 files changed, 65 insertions(+), 44 deletions(-) diff --git a/default.nix b/default.nix index 3f79c42..6f625a1 100644 --- a/default.nix +++ b/default.nix @@ -1,19 +1,15 @@ { - lib, + craneLib, pkgs, - rust, - self, }: -pkgs.rustPlatform.buildRustPackage { +craneLib.buildPackage { pname = "errornowatcher"; - version = self.shortRev or self.dirtyShortRev; + version = "0.2.0"; - cargoLock.lockFile = ./Cargo.lock; - src = lib.cleanSource ./.; + src = craneLib.cleanCargoSource ./.; nativeBuildInputs = with pkgs; [ - rust - + clang mold pkg-config ]; diff --git a/flake.lock b/flake.lock index 768861b..1be03e4 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,41 @@ { "nodes": { + "crane": { + "locked": { + "lastModified": 1778106249, + "narHash": "sha256-cM/AuKy5tMhwOOQIbha8ZRRMHVfNf7cv2aljIw+qoCg=", + "owner": "ipetkov", + "repo": "crane", + "rev": "6d015ea29630b7ad2402841386da2cb617a470a7", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1778314245, + "narHash": "sha256-a8p3JMunVzj0o86V9CNTyEFw7z4105QWl+bEz6Du8Jw=", + "owner": "nix-community", + "repo": "fenix", + "rev": "f54d645218048a7abe226983a922cdaca63cd845", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -51,28 +87,26 @@ }, "root": { "inputs": { + "crane": "crane", + "fenix": "fenix", "flake-parts": "flake-parts", - "nixpkgs": "nixpkgs", - "rust-overlay": "rust-overlay" + "nixpkgs": "nixpkgs" } }, - "rust-overlay": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, + "rust-analyzer-src": { + "flake": false, "locked": { - "lastModified": 1778296574, - "narHash": "sha256-DVmg1JCjG0VJTa+FF6tH6tkQChaxzK1EzPL98RiRWU0=", - "owner": "oxalica", - "repo": "rust-overlay", - "rev": "1d634a90dffb59ec9ba52652de311b15528c1595", + "lastModified": 1778246258, + "narHash": "sha256-RUZuOfzouSaK/VjcOCU/P5Nb3EhpM8qGnIcHWIIo4Sw=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "73ca1d4ef136e2367627d698f00db94882b49440", "type": "github" }, "original": { - "owner": "oxalica", - "repo": "rust-overlay", + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", "type": "github" } } diff --git a/flake.nix b/flake.nix index 6bdd7c6..348c1aa 100644 --- a/flake.nix +++ b/flake.nix @@ -1,21 +1,22 @@ { inputs = { + crane.url = "github:ipetkov/crane"; + + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-parts.url = "github:hercules-ci/flake-parts"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - - rust-overlay = { - url = "github:oxalica/rust-overlay"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = { + crane, + fenix, flake-parts, - nixpkgs, - rust-overlay, - self, ... }@inputs: flake-parts.lib.mkFlake { inherit inputs; } { @@ -32,19 +33,9 @@ ... }: let - rust = pkgs.rust-bin.nightly.latest.default.override { - extensions = [ - "rust-src" - "rust-analyzer-preview" - ]; - }; + craneLib = (crane.mkLib pkgs).overrideToolchain fenix.packages.${system}.complete.toolchain; in { - _module.args.pkgs = import nixpkgs { - inherit system; - overlays = [ rust-overlay.overlays.default ]; - }; - devShells.default = pkgs.mkShell { name = "errornowatcher"; @@ -58,7 +49,7 @@ packages = rec { default = errornowatcher; - errornowatcher = pkgs.callPackage ./. { inherit rust self; }; + errornowatcher = pkgs.callPackage ./. { inherit craneLib; }; }; }; };