From 950f921c09930076a19621bea9730cc866c3c482 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Tue, 14 Mar 2023 10:50:07 +0100 Subject: [PATCH] refactor(nix): use flake-utils Signed-off-by: Sefa Eyeoglu --- flake.lock | 16 ++++++++++++++++ flake.nix | 39 ++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/flake.lock b/flake.lock index 051e1664c..a0f503cd6 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,21 @@ "type": "github" } }, + "flake-utils": { + "locked": { + "lastModified": 1676283394, + "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "libnbtplusplus": { "flake": false, "locked": { @@ -51,6 +66,7 @@ "root": { "inputs": { "flake-compat": "flake-compat", + "flake-utils": "flake-utils", "libnbtplusplus": "libnbtplusplus", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index f173511cf..f476fdf92 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,7 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; flake-compat = { url = "github:edolstra/flake-compat"; flake = false; @@ -16,6 +17,7 @@ outputs = { self, nixpkgs, + flake-utils, libnbtplusplus, ... }: let @@ -23,26 +25,29 @@ version = builtins.substring 0 8 self.lastModifiedDate; # Supported systems (qtbase is currently broken for "aarch64-darwin") - supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux"]; - - # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - - # Nixpkgs instantiated for supported systems. - pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); + supportedSystems = with flake-utils.lib.system; [ + x86_64-linux + x86_64-darwin + aarch64-linux + ]; packagesFn = pkgs: rec { - prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix {inherit version self libnbtplusplus;}; - prismlauncher = pkgs.qt6Packages.callPackage ./nix {inherit version self libnbtplusplus;}; + prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { + inherit version self libnbtplusplus; + }; + prismlauncher = pkgs.qt6Packages.callPackage ./nix { + inherit version self libnbtplusplus; + }; }; - in { - packages = forAllSystems ( - system: let - packages = packagesFn pkgs.${system}; + in + flake-utils.lib.eachSystem supportedSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { + packages = let + packages = packagesFn pkgs; in - packages // {default = packages.prismlauncher;} - ); + packages // {default = packages.prismlauncher;}; - overlay = final: packagesFn; - }; + overlay = final: packagesFn; + }); }