diff options
Diffstat (limited to 'flake.nix')
-rw-r--r-- | flake.nix | 100 |
1 files changed, 77 insertions, 23 deletions
@@ -3,35 +3,89 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; - libnbtplusplus = { url = "github:PrismLauncher/libnbtplusplus"; flake = false; }; + flake-utils.url = "github:numtide/flake-utils"; + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + libnbtplusplus = { + url = "github:PrismLauncher/libnbtplusplus"; + flake = false; + }; }; - outputs = { self, nixpkgs, libnbtplusplus, ... }: - let - # User-friendly version number. - version = builtins.substring 0 8 self.lastModifiedDate; + outputs = { + self, + nixpkgs, + flake-utils, + pre-commit-hooks, + libnbtplusplus, + ... + }: let + # User-friendly version number. + version = builtins.substring 0 8 self.lastModifiedDate; + + # Supported systems (qtbase is currently broken for "aarch64-darwin") + supportedSystems = with flake-utils.lib.system; [ + x86_64-linux + x86_64-darwin + aarch64-linux + ]; + + packagesFn = pkgs: { + prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { + inherit version self libnbtplusplus; + }; + prismlauncher = pkgs.qt6Packages.callPackage ./nix { + inherit version self libnbtplusplus; + }; + }; + in + flake-utils.lib.eachSystem supportedSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { + checks = { + pre-commit-check = pre-commit-hooks.lib.${system}.run { + src = ./.; + hooks = { + markdownlint.enable = true; - # Supported systems (qtbase is currently broken for "aarch64-darwin") - supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ]; + alejandra.enable = true; + deadnix.enable = true; + + clang-format = { + enable = + false; # As most of the codebase is **not** formatted, we don't want clang-format yet + types_or = ["c" "c++"]; + }; + }; + }; + }; - # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'. - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + packages = let + packages = packagesFn pkgs; + in + packages // {default = packages.prismlauncher;}; - # Nixpkgs instantiated for supported systems. - pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); + devShells.default = pkgs.mkShell { + inherit (self.checks.${system}.pre-commit-check) shellHook; + packages = with pkgs; [ + nodePackages.markdownlint-cli + alejandra + deadnix + clang-tools + ]; - packagesFn = pkgs: rec { - prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; }; - prismlauncher = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; }; + inputsFrom = [self.packages.${system}.default]; + buildInputs = with pkgs; [ccache ninja]; }; - in - { - packages = forAllSystems (system: - let packages = packagesFn pkgs.${system}; in - packages // { default = packages.prismlauncher; } - ); - - overlay = final: packagesFn; + }) + // { + overlays.default = final: _: (packagesFn final); }; } |