From 03d55d051f920af56a49d84b22c0e0bfd2c783c2 Mon Sep 17 00:00:00 2001 From: Michael Raitza Date: Mon, 28 Oct 2024 16:06:12 +0100 Subject: [PATCH] flake: Convert to flake-parts improves compositionality --- flake.lock | 47 ++++++++++++++++++++++------------------------- flake.nix | 41 ++++++++++++++++++++--------------------- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/flake.lock b/flake.lock index fc9c76fa..022e965c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,20 +1,20 @@ { "nodes": { - "flake-utils": { + "flake-parts": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "lastModified": 1727826117, + "narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, @@ -52,6 +52,18 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1727825735, + "narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1721821769, @@ -70,25 +82,10 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", + "flake-parts": "flake-parts", "makes": "makes", "nixpkgs": "nixpkgs_2" } - }, - "systems": { - "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 77b96aa0..47915c72 100644 --- a/flake.nix +++ b/flake.nix @@ -2,44 +2,43 @@ description = "A core language for rule-based hardware design"; inputs = { - flake-utils.url = "github:numtide/flake-utils"; + flake-parts.url = "github:hercules-ci/flake-parts"; makes.url = "github:fluidattacks/makes/24.02"; nixpkgs.url = "github:nixos/nixpkgs/release-24.05"; }; - outputs = { - self, - flake-utils, - makes, - nixpkgs, - ... - }: - with flake-utils.lib; - eachDefaultSystem (system: let - pkgs = import nixpkgs { + outputs = { self, flake-parts, makes, nixpkgs, ... } @ inputs: + flake-parts.lib.mkFlake { inherit inputs; } { + # Original flake.outputs attribute set. Everything in this set behaves like + # usual flake outputs. + flake = { + # NOTE: To use this flake, apply the following overlay to nixpkgs and use + # koika from its respective coqPackages_VER attribute set! + # See _module.args.pkgs = ... below for an example! + overlays.default = import ./overlay.nix; + }; + systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ]; + perSystem = { inputs', self', system, pkgs, ... }: { + _module.args.pkgs = import inputs.nixpkgs { inherit system; - overlays = [self.overlays.default]; + overlays = [ inputs.self.overlays.default ]; }; - in { + checks = { koika = self.packages.${system}.default.override { doCheck = true; }; }; - devShells.default = self.checks.${system}.koika; + devShells.default = self'.checks.koika; packages = { - default = self.packages.${system}.coq8_18-koika; + default = self'.packages.coq8_18-koika; coq8_18-koika = pkgs.coqPackages_8_18.koika; coqDev-koika = pkgs.coqPackages_koika.koika; }; - apps.makes = makes.apps.${system}.default; - }) - // { - # NOTE: To use this flake, apply the following overlay to nixpkgs and use - # koika from its respective coqPackages_VER attribute set! - overlays.default = import ./overlay.nix; + apps.makes = inputs'.makes.apps.default; }; + }; }