From 094a77a2fc58794f28a8713ed7da35268d7826fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elizabeth=20Pa=C5=BA?= Date: Sat, 25 Nov 2023 11:07:18 +0100 Subject: [PATCH] refactor: use nci instead of buildRustPackage --- flake.lock | 221 +++++++++++++++++++++++++++++++++++++++++++++++++---- flake.nix | 63 +++++++-------- 2 files changed, 238 insertions(+), 46 deletions(-) diff --git a/flake.lock b/flake.lock index 6fd2506..513e9d6 100644 --- a/flake.lock +++ b/flake.lock @@ -1,13 +1,53 @@ { "nodes": { + "crane": { + "flake": false, + "locked": { + "lastModified": 1699217310, + "narHash": "sha256-xpW3VFUG7yE6UE6Wl0dhqencuENSkV7qpnpe9I8VbPw=", + "owner": "ipetkov", + "repo": "crane", + "rev": "d535642bbe6f377077f7c23f0febb78b1463f449", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "ref": "v0.15.0", + "repo": "crane", + "type": "github" + } + }, + "dream2nix": { + "inputs": { + "nixpkgs": [ + "nci", + "nixpkgs" + ], + "purescript-overlay": "purescript-overlay", + "pyproject-nix": "pyproject-nix" + }, + "locked": { + "lastModified": 1700448730, + "narHash": "sha256-5dQTWQgCY1/XXDgxuYP1bT5S6rNdoukFRRmGdaL8uBw=", + "owner": "nix-community", + "repo": "dream2nix", + "rev": "427b5e94f4b57d35466c37bc962eb9122e6df2ad", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "dream2nix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { - "lastModified": 1668681692, - "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -16,28 +56,57 @@ "type": "github" } }, - "flake-utils": { + "mk-naked-shell": { + "flake": false, "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "lastModified": 1681286841, + "narHash": "sha256-3XlJrwlR0nBiREnuogoa5i1b4+w/XPe0z8bbrJASw0g=", + "owner": "yusdacra", + "repo": "mk-naked-shell", + "rev": "7612f828dd6f22b7fb332cc69440e839d7ffe6bd", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "yusdacra", + "repo": "mk-naked-shell", + "type": "github" + } + }, + "nci": { + "inputs": { + "crane": "crane", + "dream2nix": "dream2nix", + "mk-naked-shell": "mk-naked-shell", + "nixpkgs": [ + "nixpkgs" + ], + "parts": [ + "parts" + ], + "rust-overlay": "rust-overlay", + "treefmt": "treefmt" + }, + "locked": { + "lastModified": 1700892607, + "narHash": "sha256-U8bbP5ELI9MOSn2tiDByvsCjRO3CK40CtD01gr5Ga3U=", + "owner": "yusdacra", + "repo": "nix-cargo-integration", + "rev": "24113f8d3fe1ea603b4fde6cd0ff94bcaf28f6e1", + "type": "github" + }, + "original": { + "owner": "yusdacra", + "repo": "nix-cargo-integration", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1671722432, - "narHash": "sha256-ojcZUekIQeOZkHHzR81st7qxX99dB1Eaaq6PU5MNeKc=", + "lastModified": 1700612854, + "narHash": "sha256-yrQ8osMD+vDLGFX7pcwsY/Qr5PUd6OmDMYJZzZi0+zc=", "owner": "nixos", "repo": "nixpkgs", - "rev": "652e92b8064949a11bc193b90b74cb727f2a1405", + "rev": "19cbff58383a4ae384dea4d1d0c823d72b49d614", "type": "github" }, "original": { @@ -47,11 +116,131 @@ "type": "github" } }, + "parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698882062, + "narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8c9fa2545007b49a5db5f650ae91f227672c3877", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "purescript-overlay": { + "inputs": { + "nixpkgs": [ + "nci", + "dream2nix", + "nixpkgs" + ], + "slimlock": "slimlock" + }, + "locked": { + "lastModified": 1696022621, + "narHash": "sha256-eMjFmsj2G1E0Q5XiibUNgFjTiSz0GxIeSSzzVdoN730=", + "owner": "thomashoneyman", + "repo": "purescript-overlay", + "rev": "047c7933abd6da8aa239904422e22d190ce55ead", + "type": "github" + }, + "original": { + "owner": "thomashoneyman", + "repo": "purescript-overlay", + "type": "github" + } + }, + "pyproject-nix": { + "flake": false, + "locked": { + "lastModified": 1699067645, + "narHash": "sha256-SJOEPVFARVfS0qQQqbnGywt8uOZMmlV1PazQtGNNCfQ=", + "owner": "adisbladis", + "repo": "pyproject.nix", + "rev": "56b5a6ae1ac63a0a3a044d602a3b5d09a5d10dc0", + "type": "github" + }, + "original": { + "owner": "adisbladis", + "repo": "pyproject.nix", + "type": "github" + } + }, "root": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nci": "nci", + "nixpkgs": "nixpkgs", + "parts": "parts" + } + }, + "rust-overlay": { + "flake": false, + "locked": { + "lastModified": 1700878361, + "narHash": "sha256-O30hSOliHJhSdhZw5T8JFtxlL309mNLI+agYffuccIo=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "0309d58c91c57e8d519de68312430074de3ef5f8", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "slimlock": { + "inputs": { + "nixpkgs": [ + "nci", + "dream2nix", + "purescript-overlay", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688610262, + "narHash": "sha256-Wg0ViDotFWGWqKIQzyYCgayeH8s4U1OZcTiWTQYdAp4=", + "owner": "thomashoneyman", + "repo": "slimlock", + "rev": "b5c6cdcaf636ebbebd0a1f32520929394493f1a6", + "type": "github" + }, + "original": { + "owner": "thomashoneyman", + "repo": "slimlock", + "type": "github" + } + }, + "treefmt": { + "inputs": { + "nixpkgs": [ + "nci", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1699786194, + "narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index eb5c175..64cd1b5 100644 --- a/flake.nix +++ b/flake.nix @@ -1,41 +1,44 @@ { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; - + parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + nci = { + url = "github:yusdacra/nix-cargo-integration"; + inputs = { + nixpkgs.follows = "nixpkgs"; + parts.follows = "parts"; + }; + }; }; - outputs = { self, nixpkgs, flake-utils, flake-compat }: { - overlays.default = _: prev: - let - inherit (prev.rustPlatform) buildRustPackage; - toml = builtins.fromTOML (builtins.readFile ./Cargo.toml); - in - { - muc = buildRustPackage { - pname = "muc"; - src = self; - inherit (toml.package) version; - cargoHash = "sha256-w/b4qps4z1HrtSlSklflU6i1QfSFQw20+uALIpCIk8I="; + outputs = inputs@{ parts, ... }: + parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.nci.flakeModule + parts.flakeModules.easyOverlay + ]; + + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + perSystem = { config, ... }: + let crateOutputs = config.nci.outputs.muc; in + { + nci.projects.muc.path = ./.; + overlayAttrs.muc = config.packages.default; + packages.default = crateOutputs.packages.release; + devShells.default = crateOutputs.devShell; }; - }; - } // - (flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { - inherit system; - overlays = [ self.overlays.default ]; - }; - inherit (pkgs) muc; - in - { - packages = { - inherit muc; - default = muc; - }; - })); + }; }