added nix support
This commit is contained in:
parent
cc77fee048
commit
cb9ae44ec4
6 changed files with 112 additions and 3 deletions
94
flake.nix
Normal file
94
flake.nix
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
description = "A flake to install sTodo";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
}: {
|
||||
packages.x86_64-linux.sTodo = with nixpkgs.legacyPackages.x86_64-linux;
|
||||
stdenv.mkDerivation {
|
||||
pname = "sTodo";
|
||||
version = "1.0.0";
|
||||
|
||||
src = fetchTarball {
|
||||
url = "https://git.stuce.ch/stuce/sTodo/releases/download/Release1/release1.tar.gz";
|
||||
sha256 = "10jyldwmcs5zyz1k8lp3jscn7nhlvn56g0709l5jp91qimw7xiqz";
|
||||
};
|
||||
buildInputs = [zlib gmp libffi openssl];
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp $src/sTodo $out/bin
|
||||
'';
|
||||
mainProgram = "sTodo";
|
||||
};
|
||||
nixosModules.sTodo = {
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.services.sTodo;
|
||||
in {
|
||||
options.services.sTodo = {
|
||||
# options.programs.sTodo = {
|
||||
enable = lib.mkEnableOption "sTodo";
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = self.packages.x86_64-linux.sTodo;
|
||||
};
|
||||
appRoot = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "http://localhost:6901";
|
||||
description = "Link used to access the webapp";
|
||||
};
|
||||
|
||||
staticRoot = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/etc/sTodo/static";
|
||||
description = "Location of the static folder";
|
||||
};
|
||||
|
||||
databaseFolder = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/etc/sTodo/sTodo.sqlite3";
|
||||
description = "Location of the database folder";
|
||||
};
|
||||
|
||||
clientSessionKey = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/etc/sTodo/client_session_key.aes";
|
||||
description = "Location of the client session key";
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 6901;
|
||||
description = "Default port of the app";
|
||||
};
|
||||
};
|
||||
|
||||
# Systemd Service
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services.sTodo = {
|
||||
description = "Launch a sTodo app to have a online todolist";
|
||||
after = ["network.target"];
|
||||
wantedBy = ["multi-user.target"];
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/sTodo";
|
||||
Restart = "always";
|
||||
};
|
||||
environment = {
|
||||
YESOD_PORT = "${toString cfg.port}";
|
||||
YESOD_APPROOT = "${cfg.appRoot}";
|
||||
YESOD_SQLITE_DATABASE = "${cfg.databaseFolder}";
|
||||
YESOD_STATIC_DIR = "${cfg.staticRoot}";
|
||||
YESOD_SESSION_KEY = "${cfg.clientSessionKey}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue