nix: refactor flake (drop flake-utils)

This commit is contained in:
Ilan Joselevich 2022-03-13 18:18:46 +02:00
parent 269c1bbf58
commit 2c07f758a0
3 changed files with 41 additions and 72 deletions

View File

@ -16,21 +16,6 @@
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"libnbtplusplus": {
"flake": false,
"locked": {
@ -49,16 +34,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1643169865,
"narHash": "sha256-+KIpNRazbc8Gac9jdWCKQkFv9bjceaLaLhlwqUEYu8c=",
"lastModified": 1646955661,
"narHash": "sha256-AYLta1PubJnrkv15+7G+6ErW5m9NcI9wSdJ+n7pKAe0=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "945ec499041db73043f745fad3b2a3a01e826081",
"rev": "e9545762b032559c27d8ec9141ed63ceca1aa1ac",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
@ -82,7 +67,6 @@
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs",
"quazip": "quazip"

View File

@ -1,50 +1,34 @@
{
description = "PolyMC flake";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
inputs.libnbtplusplus = {
url = "github:multimc/libnbtplusplus";
flake = false;
};
inputs.quazip = {
url = "github:stachenov/quazip";
flake = false;
description = "A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once (Fork of MultiMC)";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
libnbtplusplus = { url = "github:multimc/libnbtplusplus"; flake = false; };
quazip = { url = "github:stachenov/quazip"; flake = false; };
};
outputs = args@{ self, nixpkgs, flake-utils, libnbtplusplus, quazip, ... }:
outputs = { self, nixpkgs, libnbtplusplus, quazip, ... }:
let
systems = [
"aarch64-linux"
# "aarch64-darwin" # qtbase is currently broken
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
];
in {
overlay = final: prev: {
inherit (self.packages.${final.system}) polymc;
# Generate a user-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
# System types to support (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 system types.
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (system: { polymc = pkgs.${system}.libsForQt5.callPackage ./packages/nix/polymc { inherit version self quazip libnbtplusplus; }; });
defaultPackage = forAllSystems (system: self.packages.${system}.polymc);
apps = forAllSystems (system: { polymc = { type = "app"; program = "${self.defaultPackage.${system}}/bin/polymc"; }; });
defaultApp = forAllSystems (system: self.apps.${system}.polymc);
overlay = final: prev: { polymc = self.defaultPackage.${final.system}; };
};
} // flake-utils.lib.eachSystem systems (system:
let pkgs = import nixpkgs { inherit system; };
in {
packages = {
polymc = pkgs.libsForQt5.callPackage ./packages/nix/polymc {
inherit self;
submoduleQuazip = quazip;
submoduleNbt = libnbtplusplus;
};
};
apps = {
polymc = flake-utils.lib.mkApp {
name = "polymc";
drv = self.packages.${system}.polymc;
};
};
defaultPackage = self.packages.${system}.polymc;
defaultApp = self.apps.${system}.polymc;
});
}

View File

@ -16,8 +16,9 @@
# flake
, self
, submoduleNbt
, submoduleQuazip
, version
, libnbtplusplus
, quazip
}:
let
@ -38,7 +39,7 @@ in
mkDerivation rec {
pname = "polymc";
version = "nightly";
inherit version;
src = lib.cleanSource self;
@ -57,8 +58,8 @@ mkDerivation rec {
# Copy submodules inputs
rm -rf source/libraries/{libnbtplusplus,quazip}
mkdir source/libraries/{libnbtplusplus,quazip}
cp -a ${submoduleNbt}/* source/libraries/libnbtplusplus
cp -a ${submoduleQuazip}/* source/libraries/quazip
cp -a ${libnbtplusplus}/* source/libraries/libnbtplusplus
cp -a ${quazip}/* source/libraries/quazip
chmod a+r+w source/libraries/{libnbtplusplus,quazip}/*
'';