{ description = "spacial-data-experiments"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; quebec-osm-data = { url = "https://static.home.all-dressed-programming.com/download.geofabrik.de/north-america/canada/quebec-241223.osm.pbf"; flake = false; }; quebec-cities-poly = { url = "github:didiercrunch/cities"; flake = false; }; }; outputs = { self, nixpkgs, flake-utils, quebec-osm-data, quebec-cities-poly }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; poly2geojson = pkgs.rustPlatform.buildRustPackage rec { pname = "poly2geojson"; version = "0.1.3"; src = pkgs.fetchFromGitHub { owner = "frafra"; repo = pname; rev = "2fbf2383765fe043d43d53b91ddbfe50c0129bb1"; hash = "sha256-BMRl6fRqQlibuGxg5hBHz7r1cvionNYEZe9YcZuL0oU="; }; cargoHash = "sha256-pCegHF6SsCIsCQ/b+N34xTMjw2PjPB0pi30Y9sWIcV4="; }; osmosis = pkgs.stdenv.mkDerivation { name = "osmosis"; src = pkgs.fetchzip { url = "https://github.com/openstreetmap/osmosis/releases/download/0.49.2/osmosis-0.49.2.zip"; hash = "sha256-hmD/pnEEJsl2NkODon4XZcZ3ZQ7+fx/JvWTR4xrRoug="; }; buildInputs = [ ]; buildPhase = ""; installPhase = '' cp -r . $out ''; }; data-dir = pkgs.stdenv.mkDerivation { name = "data-dir"; src = ./scripts; buildInputs = [ poly2geojson pkgs.jdk23 osmosis ]; buildPhase = '' mkdir -p cities/canada/quebec cp ${quebec-cities-poly}/canada/quebec/* cities/canada/quebec chmod u+w cities/canada/quebec ${pkgs.babashka}/bin/bb to-geojson.clj --osm-file ${quebec-osm-data} --paths cities/canada/quebec/*.poly ''; installPhase = '' cp -r cities $out ''; }; python-virtual-env = pkgs.python312.withPackages (ps: [ ps.matplotlib ps.jupyter ps.duckdb ps.pandas ps.unidecode ps.geopy ]); in { packages = { default = data-dir; poly2geojson = poly2geojson; osmosis = osmosis; }; devShell = pkgs.mkShell { name = "spacial-data-experiments"; buildInputs = with pkgs; [ duckdb http-server sqlfluff poly2geojson gdal osmosis python-virtual-env ]; }; }); }