Files
minecraft-kartverket/flake.nix

123 lines
3.3 KiB
Nix

{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }: let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in f system pkgs);
inherit (nixpkgs) lib;
in {
apps = forAllSystems (system: pkgs: {
default = {
type = "app";
program = lib.getExe self.packages.${system}.default;
meta.description = "The 'mckart' cli tool with all map data embedded";
};
});
devShells = forAllSystems (_: pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
uv
ruff
python3
# (python3.withPackages (ps: with ps; []))
biome
];
};
});
overlays.default = final: prev: self.packages.${final.system};
checks = forAllSystems (system: pkgs: {
inherit (self.packages.${system}) bluemap-export mapcrafter-export;
hocon-include = let
format = pkgs.formats.hocon { };
in format.generate "minecraft-kartverket-test-hocon-include" {
_includes = [
(format.lib.mkInclude "${self.packages.${system}.bluemap-export}/overworld.hocon")
(format.lib.mkInclude "${self.packages.${system}.bluemap-export}/nether.hocon")
(format.lib.mkInclude "${self.packages.${system}.bluemap-export}/the-end.hocon")
];
};
});
packages = forAllSystems (system: pkgs: {
default = self.packages.${system}.mckart;
mckart = let
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
in with pkgs.python3Packages; buildPythonPackage {
pname = pyproject.project.name;
version = pyproject.project.version;
src = lib.cleanSource ./.;
format = "pyproject";
build-system = [ hatchling ];
dependencies = [];
meta.mainProgram = "mckart";
};
bluemap-export = let
# from pkgs/pkgs-lib/formats/hocon/default.nix
hocon-validator =
pkgs.writers.writePython3Bin "hocon-validator"
{
libraries = [ pkgs.python3Packages.pyhocon ];
}
''
from sys import argv
from pyhocon import ConfigFactory
if not len(argv) == 2:
print("USAGE: hocon-validator <file>")
ConfigFactory.parse_file(argv[1])
'';
in pkgs.runCommand "bluemap-export" {
nativeBuildInputs = [
(self.packages.${system}.mckart)
hocon-validator
];
} ''
mckart export-bluemap --output-dir "$out"
for file in "$out"/*.hocon; do
hocon-validator "$file"
done
'';
mapcrafter-export = pkgs.runCommand "mapcrafter-export" {
buildInputs = [
(self.packages.${system}.mckart)
pkgs.biome
];
biomeConf = builtins.toJSON {
formatter = {
indentStyle = "space";
lineWidth = 100;
};
};
passAsFile = [ "biomeConf" ];
} ''
mckart export-mapcrafter --output-dir "$out"
cp "$biomeConfPath" ./biome.json
biome format --config-path=./biome.json "$out"/* --write
'';
});
};
}