2024-03-18 12:29:16 +00:00
{
config ,
lib ,
pkgs ,
. . .
} :
let
inherit ( lib ) types ;
cfg = config . services . ocis ;
defaultUser = " o c i s " ;
defaultGroup = defaultUser ;
in
{
options = {
services . ocis = {
enable = lib . mkEnableOption " o w n C l o u d I n f i n i t e S c a l e " ;
package = lib . mkPackageOption pkgs " o c i s - b i n " { } ;
configDir = lib . mkOption {
type = types . nullOr types . path ;
default = null ;
example = " / v a r / l i b / o c i s / c o n f i g " ;
2024-04-13 12:54:15 +00:00
description = ''
2024-03-18 12:29:16 +00:00
Path to directory containing oCIS config file .
Example config can be generated by ` ocis init - - config-path fileName - - admin-password " a d m i n P a s s " ` .
Add ` - - insecure true ` if SSL certificates are generated and managed externally ( e . g . using oCIS behind reverse proxy ) .
Note : This directory must contain at least a ` ocis . yaml ` . Ensure
[ user ] ( #opt-services.ocis.user) has read/write access to it. In some
circumstances you may need to add additional oCIS configuration files ( e . g . ,
` proxy . yaml ` ) to this directory .
'' ;
} ;
environmentFile = lib . mkOption {
type = types . nullOr types . path ;
default = null ;
example = " / r u n / k e y s / o c i s . e n v " ;
2024-04-13 12:54:15 +00:00
description = ''
2024-03-18 12:29:16 +00:00
An environment file as defined in { manpage } ` systemd . exec ( 5 ) ` .
Configuration provided in this file will override those from [ configDir ] ( #opt-services.ocis.configDir)/ocis.yaml.
'' ;
} ;
user = lib . mkOption {
type = types . str ;
default = defaultUser ;
example = " y o u r U s e r " ;
2024-04-13 12:54:15 +00:00
description = ''
2024-03-18 12:29:16 +00:00
The user to run oCIS as .
By default , a user named ` $ { defaultUser } ` will be created whose home
directory is [ stateDir ] ( #opt-services.ocis.stateDir).
'' ;
} ;
group = lib . mkOption {
type = types . str ;
default = defaultGroup ;
example = " y o u r G r o u p " ;
2024-04-13 12:54:15 +00:00
description = ''
2024-03-18 12:29:16 +00:00
The group to run oCIS under .
By default , a group named ` $ { defaultGroup } ` will be created .
'' ;
} ;
address = lib . mkOption {
type = types . str ;
default = " 1 2 7 . 0 . 0 . 1 " ;
description = " W e b i n t e r f a c e a d d r e s s . " ;
} ;
port = lib . mkOption {
type = types . port ;
default = 9200 ;
description = " W e b i n t e r f a c e p o r t . " ;
} ;
url = lib . mkOption {
type = types . str ;
default = " h t t p s : / / l o c a l h o s t : 9 2 0 0 " ;
example = " h t t p s : / / s o m e - h o s t n a m e - o r - i p : 9 2 0 0 " ;
description = " W e b i n t e r f a c e a d d r e s s . " ;
} ;
stateDir = lib . mkOption {
default = " / v a r / l i b / o c i s " ;
type = types . str ;
description = " o w n C l o u d d a t a d i r e c t o r y . " ;
} ;
environment = lib . mkOption {
type = types . attrsOf types . str ;
default = { } ;
2024-04-13 12:54:15 +00:00
description = ''
2024-03-18 12:29:16 +00:00
Extra config options .
See [ the documentation ] ( https://doc.owncloud.com/ocis/next/deployment/services/services.html ) for available options .
See [ notes for environment variables ] ( https://doc.owncloud.com/ocis/next/deployment/services/env-var-note.html ) for more information .
Note that all the attributes here will be copied to /nix/store / and will be world readable . Options like * _PASSWORD or * _SECRET should be part of [ environmentFile ] ( #opt-services.ocis.environmentFile) instead, and are only provided here for illustrative purpose.
Configuration here will override those from [ environmentFile ] ( #opt-services.ocis.environmentFile) and will have highest precedence, at the cost of security. Do NOT put security sensitive stuff here.
'' ;
example = {
OCIS_INSECURE = " f a l s e " ;
OCIS_LOG_LEVEL = " e r r o r " ;
OCIS_JWT_SECRET = " s u p e r _ s e c r e t " ;
OCIS_TRANSFER_SECRET = " f o o " ;
OCIS_MACHINE_AUTH_API_KEY = " f o o " ;
OCIS_SYSTEM_USER_ID = " 1 2 3 " ;
OCIS_MOUNT_ID = " 1 2 3 " ;
OCIS_STORAGE_USERS_MOUNT_ID = " 1 2 3 " ;
GATEWAY_STORAGE_USERS_MOUNT_ID = " 1 2 3 " ;
CS3_ALLOW_INSECURE = " t r u e " ;
OCIS_INSECURE_BACKENDS = " t r u e " ;
TLS_INSECURE = " t r u e " ;
TLS_SKIP_VERIFY_CLIENT_CERT = " t r u e " ;
WEBDAV_ALLOW_INSECURE = " t r u e " ;
IDP_TLS = " f a l s e " ;
GRAPH_APPLICATION_ID = " 1 2 3 4 " ;
IDM_IDPSVC_PASSWORD = " p a s s w o r d " ;
IDM_REVASVC_PASSWORD = " p a s s w o r d " ;
IDM_SVC_PASSWORD = " p a s s w o r d " ;
IDP_ISS = " h t t p s : / / l o c a l h o s t : 9 2 0 0 " ;
OCIS_LDAP_BIND_PASSWORD = " p a s s w o r d " ;
OCIS_SERVICE_ACCOUNT_ID = " f o o " ;
OCIS_SERVICE_ACCOUNT_SECRET = " f o o " ;
OCIS_SYSTEM_USER_API_KEY = " f o o " ;
STORAGE_USERS_MOUNT_ID = " 1 2 3 " ;
} ;
} ;
} ;
} ;
config = lib . mkIf cfg . enable {
users . users . ${ defaultUser } = lib . mkIf ( cfg . user == defaultUser ) {
group = cfg . group ;
home = cfg . stateDir ;
isSystemUser = true ;
createHome = true ;
description = " o w n C l o u d I n f i n i t e S c a l e d a e m o n u s e r " ;
} ;
users . groups = lib . mkIf ( cfg . group == defaultGroup ) { ${ defaultGroup } = { } ; } ;
systemd = {
services . ocis = {
description = " o w n C l o u d I n f i n i t e S c a l e S t a c k " ;
wantedBy = [ " m u l t i - u s e r . t a r g e t " ] ;
environment = {
PROXY_HTTP_ADDR = " ${ cfg . address } : ${ toString cfg . port } " ;
OCIS_URL = cfg . url ;
OCIS_CONFIG_DIR = if ( cfg . configDir == null ) then " ${ cfg . stateDir } / c o n f i g " else cfg . configDir ;
OCIS_BASE_DATA_PATH = cfg . stateDir ;
} // cfg . environment ;
serviceConfig = {
Type = " s i m p l e " ;
ExecStart = " ${ lib . getExe cfg . package } s e r v e r " ;
WorkingDirectory = cfg . stateDir ;
User = cfg . user ;
Group = cfg . group ;
Restart = " a l w a y s " ;
EnvironmentFile = lib . optional ( cfg . environmentFile != null ) cfg . environmentFile ;
ReadWritePaths = [ cfg . stateDir ] ;
ReadOnlyPaths = [ cfg . configDir ] ;
MemoryDenyWriteExecute = true ;
NoNewPrivileges = true ;
PrivateTmp = true ;
PrivateDevices = true ;
ProtectSystem = " s t r i c t " ;
ProtectHome = true ;
ProtectControlGroups = true ;
ProtectKernelModules = true ;
ProtectKernelTunables = true ;
ProtectKernelLogs = true ;
RestrictAddressFamilies = [
" A F _ U N I X "
" A F _ I N E T "
" A F _ I N E T 6 "
" A F _ N E T L I N K "
] ;
RestrictNamespaces = true ;
RestrictRealtime = true ;
RestrictSUIDSGID = true ;
LockPersonality = true ;
SystemCallArchitectures = " n a t i v e " ;
} ;
} ;
} ;
} ;
meta . maintainers = with lib . maintainers ; [
bhankas
danth
ramblurr
] ;
}