Skip to content

Commit

Permalink
feat: add versions to the list of packages
Browse files Browse the repository at this point in the history
  • Loading branch information
imincik committed Jan 31, 2024
1 parent 0367867 commit 5e8ad00
Show file tree
Hide file tree
Showing 9 changed files with 123,179 additions and 61,560 deletions.
42 changes: 24 additions & 18 deletions geonix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,84 +21,90 @@ in
packages_file="src/GeoPackages.elm"
echo "module GeoPackages exposing (packages)" > $packages_file
echo "packages = " >> $packages_file
echo "packages = [" >> $packages_file
nix search --json github:imincik/geospatial-nix \
--exclude "all-packages" \
--exclude "geonix-base-image" \
--exclude "geonixcli" \
--exclude "unwrapped" \
--exclude "postgresql." \
--exclude "python.*" \
| jq --compact-output 'keys' \
| sed 's|\[|\[\n|' \
| jq -r 'to_entries[] | " ,( \"\(.key)\", \"\(.value | .version)\" )"' \
| sed 's|packages\.x86_64-linux\.|geopkgs\.|g' \
>> $packages_file
echo "]" >> $packages_file
sed -i '3s/ ,//' $packages_file
${lib.getExe pkgs.elmPackages.elm-format} --yes $packages_file
packages_file="src/Packages.elm"
echo "module Packages exposing (packages)" > $packages_file
echo "packages = " >> $packages_file
echo "packages = [" >> $packages_file
nix search --json nixpkgs/$nixpkgs_version \
--exclude "postgresql.*Packages" \
--exclude "python.*Packages" \
| jq --compact-output 'keys' \
| sed 's|\[|\[\n|' \
| jq -r 'to_entries[] | " ,( \"\(.key)\", \"\(.value | .version)\" )"' \
| sed 's|legacyPackages\.x86_64-linux\.|pkgs\.|g' \
>> $packages_file
echo "]" >> $packages_file
sed -i '3s/ ,//' $packages_file
${lib.getExe pkgs.elmPackages.elm-format} --yes $packages_file
packages_file="src/GeoPythonPackages.elm"
echo "module GeoPythonPackages exposing (packages)" > $packages_file
echo "packages = " >> $packages_file
echo "packages = [" >> $packages_file
nix search --json github:imincik/geospatial-nix \
"python3-" \
--exclude "all-packages" \
| jq --compact-output 'keys' \
| sed 's|\[|\[\n|' \
| jq -r 'to_entries[] | " ,( \"\(.key)\", \"\(.value | .version)\" )"' \
| sed 's|packages\.x86_64-linux\.|geopkgs\.|g' \
>> $packages_file
echo "]" >> $packages_file
sed -i '3s/ ,//' $packages_file
${lib.getExe pkgs.elmPackages.elm-format} --yes $packages_file
packages_file="src/PythonPackages.elm"
echo "module PythonPackages exposing (packages)" > $packages_file
echo "packages = " >> $packages_file
echo "packages = [" >> $packages_file
nix search --json nixpkgs/$nixpkgs_version \
python''${python_version}Packages \
| jq --compact-output 'keys' \
| sed 's|\[|\[\n|' \
| jq -r 'to_entries[] | " ,( \"\(.key)\", \"\(.value | .version)\" )"' \
| sed 's|legacyPackages\.x86_64-linux\.|pkgs\.|g' \
| sed 's|python3..Packages|python3Packages|g' \
>> $packages_file
echo "]" >> $packages_file
sed -i '3s/ ,//' $packages_file
${lib.getExe pkgs.elmPackages.elm-format} --yes $packages_file
packages_file="src/GeoPostgresqlPackages.elm"
echo "module GeoPostgresqlPackages exposing (packages)" > $packages_file
echo "packages = " >> $packages_file
echo "packages = [" >> $packages_file
nix search --json github:imincik/geospatial-nix \
"postgresql_''${postgresql_version}" \
--exclude "all-packages" \
| jq --compact-output 'keys' \
| sed 's|\[|\[\n|' \
| jq -r 'to_entries[] | " ,( \"\(.key)\", \"\(.value | .version)\" )"' \
| sed 's|packages\.x86_64-linux\.|geopkgs\.|g' \
| sed 's|postgresql_..|postgresql|g' \
>> $packages_file
echo "]" >> $packages_file
sed -i '3s/ ,//' $packages_file
${lib.getExe pkgs.elmPackages.elm-format} --yes $packages_file
packages_file="src/PostgresqlPackages.elm"
echo "module PostgresqlPackages exposing (packages)" > $packages_file
echo "packages = " >> $packages_file
echo "packages = [" >> $packages_file
nix search --json nixpkgs/$nixpkgs_version \
postgresql''${postgresql_version}Packages \
| jq --compact-output 'keys' \
| sed 's|\[|\[\n|' \
| jq -r 'to_entries[] | " ,( \"\(.key)\", \"\(.value | .version)\" )"' \
| sed 's|legacyPackages\.x86_64-linux\.|pkgs\.|g' \
| sed 's|postgresql..Packages|postgresqlPackages|g' \
>> $packages_file
echo "]" >> $packages_file
sed -i '3s/ ,//' $packages_file
${lib.getExe pkgs.elmPackages.elm-format} --yes $packages_file
'';

Expand Down
26 changes: 13 additions & 13 deletions src/GeoPackages.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ module GeoPackages exposing (packages)


packages =
[ "geopkgs.gdal"
, "geopkgs.gdal-minimal"
, "geopkgs.geos"
, "geopkgs.grass"
, "geopkgs.libgeotiff"
, "geopkgs.librttopo"
, "geopkgs.libspatialindex"
, "geopkgs.libspatialite"
, "geopkgs.pdal"
, "geopkgs.proj"
, "geopkgs.qgis"
, "geopkgs.qgis-ltr"
, "geopkgs.tiledb"
[ ( "geopkgs.gdal", "3.8.3" )
, ( "geopkgs.gdal-minimal", "3.8.3" )
, ( "geopkgs.geos", "3.12.1" )
, ( "geopkgs.grass", "8.3.1" )
, ( "geopkgs.libgeotiff", "1.7.1" )
, ( "geopkgs.librttopo", "1.1.0" )
, ( "geopkgs.libspatialindex", "1.9.3" )
, ( "geopkgs.libspatialite", "5.1.0" )
, ( "geopkgs.pdal", "2.6.2" )
, ( "geopkgs.proj", "9.3.1" )
, ( "geopkgs.qgis", "3.34.3" )
, ( "geopkgs.qgis-ltr", "3.28.15" )
, ( "geopkgs.tiledb", "2.18.2" )
]
2 changes: 1 addition & 1 deletion src/GeoPostgresqlPackages.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ module GeoPostgresqlPackages exposing (packages)


packages =
[ "geopkgs.postgresql-postgis"
[ ( "geopkgs.postgresql-postgis", "3.4.1" )
]
18 changes: 9 additions & 9 deletions src/GeoPythonPackages.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module GeoPythonPackages exposing (packages)


packages =
[ "geopkgs.python3-fiona"
, "geopkgs.python3-gdal"
, "geopkgs.python3-geopandas"
, "geopkgs.python3-owslib"
, "geopkgs.python3-psycopg"
, "geopkgs.python3-pyproj"
, "geopkgs.python3-pyqt5"
, "geopkgs.python3-rasterio"
, "geopkgs.python3-shapely"
[ ( "geopkgs.python3-fiona", "1.9.5" )
, ( "geopkgs.python3-gdal", "3.8.3" )
, ( "geopkgs.python3-geopandas", "0.14.2" )
, ( "geopkgs.python3-owslib", "0.29.3" )
, ( "geopkgs.python3-psycopg", "3.1.12" )
, ( "geopkgs.python3-pyproj", "3.6.1" )
, ( "geopkgs.python3-pyqt5", "5.15.9" )
, ( "geopkgs.python3-rasterio", "1.3.9" )
, ( "geopkgs.python3-shapely", "2.0.2" )
]
69 changes: 48 additions & 21 deletions src/HomePage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ docker run --rm -it shell:latest


-- MODEL


type alias Package =
( String, String )



-- packages


Expand Down Expand Up @@ -198,18 +205,18 @@ type alias Model =
{ name : String

-- packages
, availablePackages : List String
, selectedPackages : List String
, availablePackages : List Package
, selectedPackages : List Package

-- python
, pythonEnabled : String
, availablePyPackages : List String
, selectedPyPackages : List String
, availablePyPackages : List Package
, selectedPyPackages : List Package

-- postgresql
, postgresEnabled : String
, availablePgPackages : List String
, selectedPgPackages : List String
, availablePgPackages : List Package
, selectedPgPackages : List Package

-- filters
, filterLimit : Int
Expand Down Expand Up @@ -386,19 +393,29 @@ view model =
]


toHtmlListAdd : List String -> List String -> String -> Int -> (String -> Msg) -> Html Msg
packagesListToNamesList : List Package -> List String
packagesListToNamesList packages =
List.map (\item -> Tuple.first item) packages


packagesCountText : Int -> Int -> Html Msg
packagesCountText packagesCount selectedCount =
text ("Total packages: " ++ String.fromInt packagesCount ++ " , selected: " ++ String.fromInt selectedCount)


toHtmlListAdd : List Package -> List Package -> String -> Int -> (Package -> Msg) -> Html Msg
toHtmlListAdd availableItems selectedItems filter filterLimit onClickAction =
let
filteredItems =
-- filter items
List.filter (\item -> String.contains filter item) availableItems
List.filter (\item -> String.contains filter (Tuple.first item)) availableItems
-- show only first x items
|> List.take filterLimit
in
ul [ class "list-group" ] (List.map (toLiAdd selectedItems onClickAction) filteredItems)


toLiAdd : List String -> (String -> Msg) -> String -> Html Msg
toLiAdd : List Package -> (Package -> Msg) -> Package -> Html Msg
toLiAdd selectedItems onClickAction item =
let
buttonLabel =
Expand All @@ -412,12 +429,12 @@ toLiAdd selectedItems onClickAction item =
"btn btn-success btn-sm"
in
li [ class "list-group-item d-flex justify-content-between align-items-center" ]
[ text item, button [ class buttonClass, style "margin" "10px", onClick (onClickAction item), id "packagesList" ] [ text buttonLabel ] ]


packagesCountText : Int -> Int -> Html Msg
packagesCountText packagesCount selectedCount =
text ("Total packages: " ++ String.fromInt packagesCount ++ " , selected: " ++ String.fromInt selectedCount)
[ p [ class "fs-5" ]
[ text (Tuple.first item)
, span [ class "text-secondary fs-6" ] [ text (" v" ++ Tuple.second item) ]
]
, button [ class buttonClass, style "margin" "10px", onClick (onClickAction item), id "packagesList" ] [ text buttonLabel ]
]


showMorePackagesButton : Int -> Html Msg
Expand All @@ -433,11 +450,11 @@ showMorePackagesButton filterLimit =

type Msg
= UpdateName String
| AddPackage String
| AddPackage Package
| EnablePython
| AddPyPackage String
| AddPyPackage Package
| EnablePostgres
| AddPgPackage String
| AddPgPackage Package
| UpdateShellHook String
| FilterPackages String
| FilterPyPackages String
Expand All @@ -452,12 +469,22 @@ type Msg

buildConfig : Model -> String
buildConfig model =
let
selectedPackages =
packagesListToNamesList model.selectedPackages

selectedPyPackages =
packagesListToNamesList model.selectedPyPackages

selectedPgPackages =
packagesListToNamesList model.selectedPgPackages
in
String.replace "<NAME>" model.name configTemplate
|> String.replace "<PACKAGES>" (String.join " " model.selectedPackages)
|> String.replace "<PACKAGES>" (String.join " " selectedPackages)
|> String.replace "<PYTHON-ENABLED>" model.pythonEnabled
|> String.replace "<PY-PACKAGES>" (String.join " " model.selectedPyPackages)
|> String.replace "<PY-PACKAGES>" (String.join " " selectedPyPackages)
|> String.replace "<POSTGRES-ENABLED>" model.postgresEnabled
|> String.replace "<PG-PACKAGES>" (String.join " " model.selectedPgPackages)
|> String.replace "<PG-PACKAGES>" (String.join " " selectedPgPackages)
|> String.replace "<SHELL-HOOK>" model.config.enterShell


Expand Down
Loading

0 comments on commit 5e8ad00

Please sign in to comment.