refactor readme updated
This commit is contained in:
parent
c4b1d1c2ba
commit
8562fc6553
5 changed files with 57 additions and 24 deletions
45
README.md
45
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# Essence
|
||||
# Prix du gaz
|
||||
|
||||
Carte de chaleur des prix d'essence au Québec affichant les prix en temps réel des stations à travers la province.
|
||||
Carte des prix d'essence au Québec affichant les prix en temps réel des stations à travers la province.
|
||||
|
||||
## Fonctionnalités
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ direnv allow
|
|||
go run .
|
||||
|
||||
# Ou avec des paramètres personnalisés
|
||||
PORT=8080 ESSENCE_DB=./essence.db go run .
|
||||
PORT=8080 PRIXDUGAZ_DB=./prixdugaz.db go run .
|
||||
```
|
||||
|
||||
Le serveur démarre à `http://localhost:8080` et redirige `/` vers `/map`.
|
||||
|
|
@ -49,19 +49,19 @@ Le serveur démarre à `http://localhost:8080` et redirige `/` vers `/map`.
|
|||
| Variable | Défaut | Description |
|
||||
|----------|--------|-------------|
|
||||
| `PORT` | `8080` | Port d'écoute HTTP |
|
||||
| `ESSENCE_DB` | `./essence.db` | Chemin de la base de données SQLite |
|
||||
| `PRIXDUGAZ_DB` | `./prixdugaz.db` | Chemin de la base de données SQLite |
|
||||
|
||||
## Compilation
|
||||
|
||||
```sh
|
||||
go build -o essence .
|
||||
go build -o prixdugaz .
|
||||
```
|
||||
|
||||
Ou via Nix :
|
||||
|
||||
```sh
|
||||
nix build
|
||||
./result/bin/essence
|
||||
./result/bin/prixdugaz
|
||||
```
|
||||
|
||||
## Formatage et analyse statique
|
||||
|
|
@ -72,6 +72,39 @@ goimports -w .
|
|||
go vet ./...
|
||||
```
|
||||
|
||||
## Déploiement sur NixOS
|
||||
|
||||
Le projet fournit un module NixOS via le flake. Ajoutez-le à votre configuration :
|
||||
|
||||
**1. Ajoutez le flake comme entrée (`flake.nix`) :**
|
||||
|
||||
```nix
|
||||
inputs.prixdugaz.url = "github:Polensky/prixdugaz";
|
||||
```
|
||||
|
||||
**2. Importez le module NixOS et activez le service :**
|
||||
|
||||
```nix
|
||||
imports = [ inputs.prixdugaz.nixosModules.default ];
|
||||
|
||||
services.prixdugaz = {
|
||||
enable = true;
|
||||
port = 8080; # optionnel, 8080 par défaut
|
||||
openFirewall = true; # optionnel, ouvre le port dans le pare-feu
|
||||
};
|
||||
```
|
||||
|
||||
**Options disponibles :**
|
||||
|
||||
| Option | Défaut | Description |
|
||||
|--------|--------|-------------|
|
||||
| `enable` | `false` | Active le service |
|
||||
| `port` | `8080` | Port d'écoute HTTP |
|
||||
| `dataDir` | `/var/lib/prixdugaz` | Répertoire de la base de données SQLite |
|
||||
| `openFirewall` | `false` | Ouvre le port dans le pare-feu |
|
||||
| `package` | flake par défaut | Paquet Prix du gaz à utiliser |
|
||||
|
||||
|
||||
## Licence
|
||||
|
||||
MIT
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
description = "Essence Quebec - Gas price heatmap";
|
||||
description = "Prix du gaz Quebec - Gas price heatmap";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
};
|
||||
|
||||
packages.default = pkgs.buildGoModule {
|
||||
pname = "essence";
|
||||
pname = "prixdugaz";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
vendorHash = "sha256-iiobqg0INKuzTyC/VMGcX5CfroqqbKnwlJLVAOCZbEE=";
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -1,4 +1,4 @@
|
|||
module github.com/polen/essence
|
||||
module github.com/polen/prixdugaz
|
||||
|
||||
go 1.25.0
|
||||
|
||||
|
|
|
|||
6
main.go
6
main.go
|
|
@ -107,9 +107,9 @@ func main() {
|
|||
port = defaultPort
|
||||
}
|
||||
|
||||
dbPath := os.Getenv("ESSENCE_DB")
|
||||
dbPath := os.Getenv("PRIXDUGAZ_DB")
|
||||
if dbPath == "" {
|
||||
dbPath = "./essence.db"
|
||||
dbPath = "./prixdugaz.db"
|
||||
}
|
||||
|
||||
var err error
|
||||
|
|
@ -983,7 +983,7 @@ func fetchAndParse() (*StationsResponse, error) {
|
|||
return nil, fmt.Errorf("creating request: %w", err)
|
||||
}
|
||||
req.Header.Set("Accept-Encoding", "gzip")
|
||||
req.Header.Set("User-Agent", "essence-quebec-map/1.0")
|
||||
req.Header.Set("User-Agent", "prixdugaz-quebec-map/1.0")
|
||||
|
||||
client := &http.Client{Timeout: 30 * time.Second}
|
||||
resp, err := client.Do(req)
|
||||
|
|
|
|||
|
|
@ -2,48 +2,48 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.essence;
|
||||
cfg = config.services.prixdugaz;
|
||||
in
|
||||
{
|
||||
options.services.essence = {
|
||||
enable = lib.mkEnableOption "Essence Quebec gas price map";
|
||||
options.services.prixdugaz = {
|
||||
enable = lib.mkEnableOption "Prix du gaz Quebec gas price map";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 8080;
|
||||
description = "Port the Essence web server listens on.";
|
||||
description = "Port the Prix du gaz web server listens on.";
|
||||
};
|
||||
|
||||
dataDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/var/lib/essence";
|
||||
default = "/var/lib/prixdugaz";
|
||||
description = "Directory where the SQLite database is stored.";
|
||||
};
|
||||
|
||||
openFirewall = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = "Whether to open the firewall for the Essence web server port.";
|
||||
description = "Whether to open the firewall for the Prix du gaz web server port.";
|
||||
};
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = self.packages.${pkgs.system}.default;
|
||||
defaultText = lib.literalExpression "self.packages.\${pkgs.system}.default";
|
||||
description = "The Essence package to use.";
|
||||
description = "The Prix du gaz package to use.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services.essence = {
|
||||
description = "Essence Quebec - Gas price map";
|
||||
systemd.services.prixdugaz = {
|
||||
description = "Prix du gaz Quebec - Gas price map";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
|
||||
environment = {
|
||||
PORT = toString cfg.port;
|
||||
ESSENCE_DB = "${cfg.dataDir}/essence.db";
|
||||
PRIXDUGAZ_DB = "${cfg.dataDir}/prixdugaz.db";
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
|
|
@ -52,7 +52,7 @@ in
|
|||
RestartSec = 5;
|
||||
|
||||
DynamicUser = true;
|
||||
StateDirectory = "essence";
|
||||
StateDirectory = "prixdugaz";
|
||||
StateDirectoryMode = "0750";
|
||||
|
||||
# Hardening
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue