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" "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": { "libnbtplusplus": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -49,16 +34,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1643169865, "lastModified": 1646955661,
"narHash": "sha256-+KIpNRazbc8Gac9jdWCKQkFv9bjceaLaLhlwqUEYu8c=", "narHash": "sha256-AYLta1PubJnrkv15+7G+6ErW5m9NcI9wSdJ+n7pKAe0=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "945ec499041db73043f745fad3b2a3a01e826081", "rev": "e9545762b032559c27d8ec9141ed63ceca1aa1ac",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-unstable", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -82,7 +67,6 @@
"root": { "root": {
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"libnbtplusplus": "libnbtplusplus", "libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"quazip": "quazip" "quazip": "quazip"

View File

@ -1,50 +1,34 @@
{ {
description = "PolyMC flake"; 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/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs = {
inputs.flake-compat = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
url = "github:edolstra/flake-compat"; flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
flake = false; libnbtplusplus = { url = "github:multimc/libnbtplusplus"; flake = false; };
}; quazip = { url = "github:stachenov/quazip"; flake = false; };
inputs.libnbtplusplus = {
url = "github:multimc/libnbtplusplus";
flake = false;
};
inputs.quazip = {
url = "github:stachenov/quazip";
flake = false;
}; };
outputs = args@{ self, nixpkgs, flake-utils, libnbtplusplus, quazip, ... }: outputs = { self, nixpkgs, libnbtplusplus, quazip, ... }:
let let
systems = [ # Generate a user-friendly version number.
"aarch64-linux" version = builtins.substring 0 8 self.lastModifiedDate;
# "aarch64-darwin" # qtbase is currently broken
"i686-linux" # System types to support (qtbase is currently broken for "aarch64-darwin")
"x86_64-darwin" supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
"x86_64-linux"
]; # Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
in { forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
overlay = final: prev: {
inherit (self.packages.${final.system}) polymc; # 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 # flake
, self , self
, submoduleNbt , version
, submoduleQuazip , libnbtplusplus
, quazip
}: }:
let let
@ -38,7 +39,7 @@ in
mkDerivation rec { mkDerivation rec {
pname = "polymc"; pname = "polymc";
version = "nightly"; inherit version;
src = lib.cleanSource self; src = lib.cleanSource self;
@ -57,8 +58,8 @@ mkDerivation rec {
# Copy submodules inputs # Copy submodules inputs
rm -rf source/libraries/{libnbtplusplus,quazip} rm -rf source/libraries/{libnbtplusplus,quazip}
mkdir source/libraries/{libnbtplusplus,quazip} mkdir source/libraries/{libnbtplusplus,quazip}
cp -a ${submoduleNbt}/* source/libraries/libnbtplusplus cp -a ${libnbtplusplus}/* source/libraries/libnbtplusplus
cp -a ${submoduleQuazip}/* source/libraries/quazip cp -a ${quazip}/* source/libraries/quazip
chmod a+r+w source/libraries/{libnbtplusplus,quazip}/* chmod a+r+w source/libraries/{libnbtplusplus,quazip}/*
''; '';