From 21a0f3af2e716ba5e8198ede9737726a39af5b34 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Sun, 29 Jan 2023 18:40:51 +0100 Subject: [PATCH] refactor: switch from `numtide/flake-utils` to `flake-parts` --- flake.lock | 56 ++++++++++++++++++++++++++++++++++++------------------ flake.nix | 35 +++++++++++++++++++++++----------- 2 files changed, 62 insertions(+), 29 deletions(-) diff --git a/flake.lock b/flake.lock index 7c056c64..42b853f8 100644 --- a/flake.lock +++ b/flake.lock @@ -16,13 +16,30 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1674771137, + "narHash": "sha256-Zpk1GbEsYrqKmuIZkx+f+8pU0qcCYJoSUwNz1Zk+R00=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "7c7a8bce3dffe71203dcd4276504d1cb49dfe05f", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, "nixpkgs": { "locked": { - "lastModified": 1674236650, - "narHash": "sha256-B4GKL1YdJnII6DQNNJ4wDW1ySJVx2suB1h/v4Ql8J0Q=", + "lastModified": 1674958881, + "narHash": "sha256-p1E20TGSgzs+EUhRPMe6fyZIxUV6CbcwilZEzy+XmAk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cfb43ad7b941d9c3606fb35d91228da7ebddbfc5", + "rev": "a0feb36dc510bfa8f8809980a8230617fb9eb618", "type": "github" }, "original": { @@ -32,27 +49,30 @@ "type": "github" } }, - "root": { - "inputs": { - "flake-compat": "flake-compat", - "nixpkgs": "nixpkgs", - "utils": "utils" - } - }, - "utils": { + "nixpkgs-lib": { "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "dir": "lib", + "lastModified": 1672350804, + "narHash": "sha256-jo6zkiCabUBn3ObuKXHGqqORUMH27gYDIFFfLq5P4wg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "677ed08a50931e38382dbef01cba08a8f7eac8f6", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", "type": "github" } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index a5ecb1a5..d79b2c69 100644 --- a/flake.nix +++ b/flake.nix @@ -9,25 +9,40 @@ }; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - - utils.url = "github:numtide/flake-utils"; }; - outputs = { self, flake-compat, nixpkgs, utils }: - # For each supported platform, - utils.lib.eachDefaultSystem (system: - let + outputs = inputs @ {flake-parts, ...}: + inputs.flake-parts.lib.mkFlake {inherit inputs;} { + flake = { + overlays.default = import ./pkgs/phps.nix inputs.nixpkgs; + }; + + systems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; + + perSystem = { + config, + pkgs, + system, + ... + }: let # Let’s merge the package set from Nixpkgs with our custom PHP versions. - pkgs = import nixpkgs.outPath { + pkgs = import inputs.nixpkgs { config = { allowUnfree = true; }; inherit system; overlays = [ - self.overlays.default + inputs.self.overlays.default ]; }; in rec { + formatter = pkgs.alejandra; + packages = { inherit (pkgs) php php56 php70 php71 php72 php73 php74 php80 php81 php82; }; @@ -35,8 +50,6 @@ checks = import ./checks.nix { inherit packages pkgs system; }; - } - ) // { - overlays.default = import ./pkgs/phps.nix nixpkgs.outPath; + }; }; }