refactor(nix): use flake-utils

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu
2023-03-14 10:50:07 +01:00
parent 9dff1bac83
commit 950f921c09
2 changed files with 38 additions and 17 deletions

View File

@ -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;
});
}