rewrite to python: redo nix packaging

This commit is contained in:
2025-03-22 00:42:59 +01:00
parent a1395c7b40
commit e3c69bc5e5
3 changed files with 109 additions and 4 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1762482733,
"narHash": "sha256-g/da4FzvckvbiZT075Sb1/YDNDr+tGQgh4N8i5ceYMg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e1ebeec86b771e9d387dd02d82ffdc77ac753abc",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View File

@@ -1,7 +1,84 @@
{
inputs = { };
outputs = inputs@{ self, ...}: {
map-markers = import ./map-markers;
map-lib = import ./map-markers/lib.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: let
mkApp = package: {
type = "app";
program = lib.getExe package;
};
in {
default = mkApp self.packages.${system}.default;
});
devShells = forAllSystems (_: pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
uv
(python3.withPackages (ps: with ps; []))
biome
];
};
});
overlays.default = final: prev: self.packages.${final.system};
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 = pkgs.runCommand "bluemap-export" {
buildInputs = [ (self.packages.${system}.mckart) ];
} ''
mckart export-bluemap --output-dir "$out"
'';
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
'';
});
};
}