chore(nix): drop flake-parts

The primary goals here include making the flake easier to contribute to
by having it follow the standard boilerplate, while also limiting the
size of our flake.lock to lower the chance of duplicate inputs for users

Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
seth 2024-08-20 02:58:55 -04:00
parent e85b364748
commit 0ae421c265
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86
7 changed files with 69 additions and 87 deletions

21
flake.lock generated
View File

@ -16,26 +16,6 @@
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1722555600,
"narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "8471fe90ad337a8074e957b69ca4d0089218391d",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"libnbtplusplus": {
"flake": false,
"locked": {
@ -71,7 +51,6 @@
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs"
}

View File

@ -8,10 +8,7 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
libnbtplusplus = {
url = "github:PrismLauncher/libnbtplusplus";
flake = false;
@ -39,18 +36,64 @@
};
outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
./nix/dev.nix
./nix/distribution.nix
];
{
self,
nixpkgs,
libnbtplusplus,
...
}:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
# While we only officially support aarch and x86_64 on Linux and MacOS,
# we expose a reasonable amount of other systems for users who want to
# build for most exotic platforms
systems = lib.systems.flakeExposed;
forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
default = pkgs.mkShell {
inputsFrom = [ self.packages.${system}.prismlauncher-unwrapped ];
buildInputs = with pkgs; [
ccache
ninja
];
};
}
);
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
overlays.default =
final: prev:
let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in
{
prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix { inherit libnbtplusplus version; };
prismlauncher = final.callPackage ./nix/wrapper.nix { };
};
packages = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
prismPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs);
in
{
inherit (prismPackages) prismlauncher-unwrapped prismlauncher;
default = prismPackages.prismlauncher;
}
);
};
}

View File

@ -44,11 +44,14 @@ Example:
# Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake
# Note that overriding any input of prismlauncher may break reproducibility
# inputs.nixpkgs.follows = "nixpkgs";
# This is not required for Flakes
inputs.flake-compat.follows = "";
};
};
outputs =
{ nixpkgs, prismlauncher }:
{ nixpkgs, prismlauncher, ... }:
{
nixosConfigurations.foo = nixpkgs.lib.nixosSystem {
modules = [
@ -85,11 +88,14 @@ Example:
# Optional: Override the nixpkgs input of prismlauncher to use the same revision as the rest of your flake
# Note that overriding any input of prismlauncher may break reproducibility
# inputs.nixpkgs.follows = "nixpkgs";
# This is not required for Flakes
inputs.flake-compat.follows = "";
};
};
outputs =
{ nixpkgs, prismlauncher }:
{ nixpkgs, prismlauncher, ... }:
{
nixosConfigurations.foo = nixpkgs.lib.nixosSystem {
modules = [

View File

@ -1,15 +0,0 @@
{
perSystem =
{ pkgs, self', ... }:
{
devShells.default = pkgs.mkShell {
inputsFrom = [ self'.packages.prismlauncher-unwrapped ];
buildInputs = with pkgs; [
ccache
ninja
];
};
formatter = pkgs.nixfmt-rfc-style;
};
}

View File

@ -1,31 +0,0 @@
{ inputs, self, ... }:
{
perSystem =
{ lib, pkgs, ... }:
{
packages =
let
ourPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs);
in
{
inherit (ourPackages) prismlauncher-unwrapped prismlauncher;
default = ourPackages.prismlauncher;
};
};
flake = {
overlays.default =
final: prev:
let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in
{
prismlauncher-unwrapped = prev.callPackage ./pkg {
inherit (inputs) libnbtplusplus;
inherit version;
};
prismlauncher = final.callPackage ./pkg/wrapper.nix { };
};
};
}

View File

@ -28,9 +28,9 @@ stdenv.mkDerivation {
inherit version;
src = lib.fileset.toSource {
root = ../../.;
root = ../.;
fileset = lib.fileset.unions (
map (fileName: ../../${fileName}) [
map (fileName: ../${fileName}) [
"buildconfig"
"cmake"
"launcher"