Skip to content

Commit

Permalink
refactor: move string templates to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
imincik committed Jan 31, 2024
1 parent 5e8ad00 commit 7c4a6cf
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 137 deletions.
113 changes: 2 additions & 111 deletions src/HomePage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import GeoPythonPackages
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import NixConfig exposing (configTemplate)
import Packages
import PostgresqlPackages
import PythonPackages
import Texts exposing (aboutText, configTemplateComment, containerTemplate, containerTemplateComment, initTemplate, initTemplateComment, installNixTemplate, installNixTemplateComment, servicesTemplate, servicesTemplateComment, shellTemplate, shellTemplateComment)


allPackages =
Expand All @@ -24,117 +26,6 @@ allPgPackages =
GeoPostgresqlPackages.packages ++ PostgresqlPackages.packages


aboutText =
"""
In a world of horrendously complex software developed by myriads of authors,
be smart, use Nix and create isolated and reproducible geospatial environment,
lovely built to work on any modern Linux machine.
"""


installNixTemplateComment =
"""
- Install Nix (if not already installed)
"""


installNixTemplate =
"""
curl --proto '=https' --tlsv1.2 -sSf \\
-L https://install.determinate.systems/nix \\
| sh -s -- install
"""


initTemplateComment =
"""
- Run following commands to initalize new project
"""


initTemplate =
"""
mkdir my-project && cd my-project
git init
nix run github:imincik/geospatial-nix#geonixcli init
git add *
"""


configTemplateComment =
"""
- Copy and paste configuration to geonix.nix file
"""


configTemplate =
"""
{ inputs, config, pkgs, lib, ... }:
let
geopkgs = inputs.geonix.packages.${pkgs.system};
in {
name = "<NAME>";
packages = [ <PACKAGES> ];
languages.python = {
enable = <PYTHON-ENABLED>;
package = pkgs.python3.withPackages (p: [ <PY-PACKAGES> ]);
};
services.postgres = {
enable = if config.container.isBuilding then false else <POSTGRES-ENABLED>;
extensions = e: [ <PG-PACKAGES> ];
};
enterShell = ''
<SHELL-HOOK>
'';
}
"""


shellTemplateComment =
"""
- Run following command to enter shell environment
"""


shellTemplate =
"""
nix run github:imincik/geospatial-nix#geonixcli -- shell
"""


servicesTemplateComment =
"""
- Run following command to launch services
"""


servicesTemplate =
"""
nix run github:imincik/geospatial-nix#geonixcli -- up
"""


containerTemplateComment =
"""
- Run following commands to build and run environment in container
"""


containerTemplate =
"""
nix run github:imincik/geospatial-nix#geonixcli -- container shell
docker run --rm -it shell:latest
"""



-- MODEL

Expand Down
30 changes: 30 additions & 0 deletions src/NixConfig.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module NixConfig exposing (configTemplate)


configTemplate =
"""
{ inputs, config, pkgs, lib, ... }:
let
geopkgs = inputs.geonix.packages.${pkgs.system};
in {
name = "<NAME>";
packages = [ <PACKAGES> ];
languages.python = {
enable = <PYTHON-ENABLED>;
package = pkgs.python3.withPackages (p: [ <PY-PACKAGES> ]);
};
services.postgres = {
enable = if config.container.isBuilding then false else <POSTGRES-ENABLED>;
extensions = e: [ <PG-PACKAGES> ];
};
enterShell = ''
<SHELL-HOOK>
'';
}
"""
83 changes: 83 additions & 0 deletions src/Texts.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
module Texts exposing (aboutText, configTemplateComment, containerTemplate, containerTemplateComment, initTemplate, initTemplateComment, installNixTemplate, installNixTemplateComment, servicesTemplate, servicesTemplateComment, shellTemplate, shellTemplateComment)


aboutText =
"""
In a world of horrendously complex software developed by myriads of authors,
be smart, use Nix and create isolated and reproducible geospatial environment,
lovely built to work on any modern Linux machine.
"""


installNixTemplateComment =
"""
- Install Nix (if not already installed)
"""


installNixTemplate =
"""
curl --proto '=https' --tlsv1.2 -sSf \\
-L https://install.determinate.systems/nix \\
| sh -s -- install
"""


initTemplateComment =
"""
- Run following commands to initalize new project
"""


initTemplate =
"""
mkdir my-project && cd my-project
git init
nix run github:imincik/geospatial-nix#geonixcli init
git add *
"""


configTemplateComment =
"""
- Copy and paste configuration to geonix.nix file
"""


shellTemplateComment =
"""
- Run following command to enter shell environment
"""


shellTemplate =
"""
nix run github:imincik/geospatial-nix#geonixcli -- shell
"""


servicesTemplateComment =
"""
- Run following command to launch services
"""


servicesTemplate =
"""
nix run github:imincik/geospatial-nix#geonixcli -- up
"""


containerTemplateComment =
"""
- Run following commands to build and run environment in container
"""


containerTemplate =
"""
nix run github:imincik/geospatial-nix#geonixcli -- container shell
docker run --rm -it shell:latest
"""
Loading

0 comments on commit 7c4a6cf

Please sign in to comment.