Eliminate all references to stdenv.lib, add tests that build for all backends
This commit is contained in:
parent
5571ba3f49
commit
5f65ae4e96
|
@ -22,7 +22,7 @@ in
|
|||
|
||||
nginxReverseProxyHostBased = import ./nginx/nginx-reverse-proxy-hostbased.nix {
|
||||
inherit createManagedProcess stateDir runtimeDir cacheDir forceDisableUserChange;
|
||||
inherit (pkgs) stdenv writeTextFile nginx;
|
||||
inherit (pkgs) stdenv lib writeTextFile nginx;
|
||||
};
|
||||
|
||||
supervisord = import ./supervisord {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{createManagedProcess, stdenv, nginx, stateDir, runtimeDir, cacheDir, forceDisableUserChange}:
|
||||
{createManagedProcess, lib, nginx, stateDir, runtimeDir, cacheDir, forceDisableUserChange}:
|
||||
{configFile, dependencies ? [], instanceSuffix ? "", instanceName ? "nginx${instanceSuffix}"}:
|
||||
|
||||
let
|
||||
|
@ -15,7 +15,7 @@ createManagedProcess {
|
|||
initialize = ''
|
||||
mkdir -p ${nginxLogDir}
|
||||
mkdir -p ${nginxCacheDir}
|
||||
${stdenv.lib.optionalString (!forceDisableUserChange) ''
|
||||
${lib.optionalString (!forceDisableUserChange) ''
|
||||
chown ${user}:${group} ${nginxLogDir}
|
||||
chown ${user}:${group} ${nginxCacheDir}
|
||||
''}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{createManagedProcess, stdenv, writeTextFile, nginx, runtimeDir, stateDir, cacheDir, forceDisableUserChange}:
|
||||
{createManagedProcess, stdenv, lib, writeTextFile, nginx, runtimeDir, stateDir, cacheDir, forceDisableUserChange}:
|
||||
{port ? 80, webapps ? [], instanceSuffix ? "", instanceName ? "nginx${instanceSuffix}"}:
|
||||
interDependencies:
|
||||
|
||||
|
@ -11,7 +11,7 @@ let
|
|||
nginxCacheDir = "${cacheDir}/${instanceName}";
|
||||
in
|
||||
import ./default.nix {
|
||||
inherit createManagedProcess stdenv nginx stateDir forceDisableUserChange runtimeDir cacheDir;
|
||||
inherit createManagedProcess lib nginx stateDir forceDisableUserChange runtimeDir cacheDir;
|
||||
} {
|
||||
inherit instanceName;
|
||||
|
||||
|
@ -24,7 +24,7 @@ import ./default.nix {
|
|||
pid ${runtimeDir}/${instanceName}.pid;
|
||||
error_log ${nginxLogDir}/error.log;
|
||||
|
||||
${stdenv.lib.optionalString (!forceDisableUserChange) ''
|
||||
${lib.optionalString (!forceDisableUserChange) ''
|
||||
user ${user} ${group};
|
||||
''}
|
||||
|
||||
|
@ -42,13 +42,13 @@ import ./default.nix {
|
|||
uwsgi_temp_path ${nginxCacheDir}/uwsgi;
|
||||
scgi_temp_path ${nginxCacheDir}/scgi;
|
||||
|
||||
${stdenv.lib.concatMapStrings (dependency: ''
|
||||
${lib.concatMapStrings (dependency: ''
|
||||
upstream webapp${toString dependency.port} {
|
||||
server localhost:${toString dependency.port};
|
||||
}
|
||||
'') webapps}
|
||||
|
||||
${stdenv.lib.concatMapStrings (paramName:
|
||||
${lib.concatMapStrings (paramName:
|
||||
let
|
||||
dependency = builtins.getAttr paramName interDependencies;
|
||||
in
|
||||
|
@ -69,7 +69,7 @@ import ./default.nix {
|
|||
root ${./errorpage};
|
||||
}
|
||||
|
||||
${stdenv.lib.concatMapStrings (dependency: ''
|
||||
${lib.concatMapStrings (dependency: ''
|
||||
server {
|
||||
listen ${toString port};
|
||||
server_name ${dependency.dnsName};
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
let
|
||||
createSystemVInitScript = import ../../../nixproc/backends/sysvinit/create-sysvinit-script.nix {
|
||||
inherit (pkgs) stdenv writeTextFile daemon;
|
||||
inherit (pkgs) stdenv writeTextFile lib daemon;
|
||||
inherit runtimeDir logDir tmpDir forceDisableUserChange;
|
||||
|
||||
createCredentials = import ../../../nixproc/create-credentials {
|
||||
inherit (pkgs) stdenv;
|
||||
inherit (pkgs) stdenv lib;
|
||||
inherit ids forceDisableUserChange;
|
||||
};
|
||||
|
||||
|
@ -32,6 +32,6 @@ in
|
|||
|
||||
nginxReverseProxy = import ./nginx/nginx-reverse-proxy.nix {
|
||||
inherit createSystemVInitScript stateDir logDir cacheDir runtimeDir forceDisableUserChange;
|
||||
inherit (pkgs) stdenv writeTextFile nginx;
|
||||
inherit (pkgs) stdenv lib writeTextFile nginx;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{createSystemVInitScript, stdenv, nginx, stateDir, runtimeDir, cacheDir, forceDisableUserChange}:
|
||||
{createSystemVInitScript, lib, nginx, stateDir, runtimeDir, cacheDir, forceDisableUserChange}:
|
||||
{configFile, dependencies ? [], instanceSuffix ? "", instanceName ? "nginx${instanceSuffix}"}:
|
||||
|
||||
let
|
||||
|
@ -14,7 +14,7 @@ createSystemVInitScript {
|
|||
mkdir -p ${nginxLogDir}
|
||||
mkdir -p ${nginxCacheDir}
|
||||
|
||||
${stdenv.lib.optionalString (!forceDisableUserChange) ''
|
||||
${lib.optionalString (!forceDisableUserChange) ''
|
||||
chown ${user}:${group} ${nginxLogDir}
|
||||
''}
|
||||
'';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{createSystemVInitScript, stdenv, writeTextFile, nginx, runtimeDir, stateDir, cacheDir, logDir, forceDisableUserChange}:
|
||||
{createSystemVInitScript, stdenv, lib, writeTextFile, nginx, runtimeDir, stateDir, cacheDir, logDir, forceDisableUserChange}:
|
||||
{port ? 80, webapps ? [], instanceSuffix ? "", instanceName ? "nginx${instanceSuffix}"}:
|
||||
interDependencies:
|
||||
|
||||
|
@ -11,7 +11,7 @@ let
|
|||
nginxCacheDir = "${cacheDir}/${instanceName}";
|
||||
in
|
||||
import ./default.nix {
|
||||
inherit createSystemVInitScript stdenv nginx runtimeDir cacheDir forceDisableUserChange;
|
||||
inherit createSystemVInitScript lib nginx runtimeDir cacheDir forceDisableUserChange;
|
||||
stateDir = nginxStateDir;
|
||||
} {
|
||||
inherit instanceName;
|
||||
|
@ -25,7 +25,7 @@ import ./default.nix {
|
|||
pid ${runtimeDir}/${instanceName}.pid;
|
||||
error_log ${nginxLogDir}/error.log;
|
||||
|
||||
${stdenv.lib.optionalString (!forceDisableUserChange) ''
|
||||
${lib.optionalString (!forceDisableUserChange) ''
|
||||
user ${user} ${group};
|
||||
''}
|
||||
|
||||
|
@ -43,13 +43,13 @@ import ./default.nix {
|
|||
uwsgi_temp_path ${nginxCacheDir}/uwsgi;
|
||||
scgi_temp_path ${nginxCacheDir}/scgi;
|
||||
|
||||
${stdenv.lib.concatMapStrings (dependency: ''
|
||||
${lib.concatMapStrings (dependency: ''
|
||||
upstream webapp${toString dependency.port} {
|
||||
server localhost:${toString dependency.port};
|
||||
}
|
||||
'') webapps}
|
||||
|
||||
${stdenv.lib.concatMapStrings (paramName:
|
||||
${lib.concatMapStrings (paramName:
|
||||
let
|
||||
dependency = builtins.getAttr paramName interDependencies;
|
||||
in
|
||||
|
@ -71,7 +71,7 @@ import ./default.nix {
|
|||
root ${./errorpage};
|
||||
}
|
||||
|
||||
${stdenv.lib.concatMapStrings (dependency: ''
|
||||
${lib.concatMapStrings (dependency: ''
|
||||
server {
|
||||
client_body_temp_path ${nginxCacheDir}/client_body;
|
||||
listen ${toString port};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{ writeTextFile
|
||||
, stdenv
|
||||
, lib
|
||||
, createCredentials
|
||||
|
||||
# Path to the rc.subr script
|
||||
|
@ -87,7 +88,7 @@ assert command == null -> commands ? start && commands ? stop;
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
extraCommands = builtins.attrNames (removeAttrs commands builtinCommands);
|
||||
|
@ -103,8 +104,8 @@ let
|
|||
|
||||
_command = if commandIsDaemon then command else "daemon";
|
||||
_commandArgs = if commandIsDaemon then commandArgs else
|
||||
stdenv.lib.optionals (pidFile != null) [ "-p" pidFile ]
|
||||
++ stdenv.lib.optionals (outputLogFile != null) [ "-o" outputLogFile ]
|
||||
lib.optionals (pidFile != null) [ "-p" pidFile ]
|
||||
++ lib.optionals (outputLogFile != null) [ "-o" outputLogFile ]
|
||||
++ [ command ]
|
||||
++ commandArgs;
|
||||
|
||||
|
@ -112,11 +113,11 @@ let
|
|||
|
||||
envFile = if environment == {} then null else writeTextFile {
|
||||
name = "${name}-envfile";
|
||||
text = stdenv.lib.concatMapStrings (name:
|
||||
text = lib.concatMapStrings (name:
|
||||
let
|
||||
value = builtins.getAttr name environment;
|
||||
in
|
||||
''${name}=${stdenv.lib.escapeShellArg value}
|
||||
''${name}=${lib.escapeShellArg value}
|
||||
''
|
||||
) (builtins.attrNames environment);
|
||||
};
|
||||
|
@ -135,107 +136,107 @@ let
|
|||
text = ''
|
||||
#!/bin/sh
|
||||
''
|
||||
+ stdenv.lib.optionalString (provides != []) ''
|
||||
+ lib.optionalString (provides != []) ''
|
||||
# PROVIDE: ${toString provides}
|
||||
''
|
||||
+ stdenv.lib.optionalString (_requires != []) ''
|
||||
+ lib.optionalString (_requires != []) ''
|
||||
# REQUIRE: ${toString _requires}
|
||||
''
|
||||
+ stdenv.lib.optionalString (keywords != []) ''
|
||||
+ lib.optionalString (keywords != []) ''
|
||||
# KEYWORD: ${toString keywords}
|
||||
'' +
|
||||
''
|
||||
. ${rcSubr}
|
||||
|
||||
name="${name}"
|
||||
'' + stdenv.lib.optionalString (rcvar != null) ''
|
||||
'' + lib.optionalString (rcvar != null) ''
|
||||
rcvar=''${name}_${rcvar}
|
||||
''
|
||||
+ ''
|
||||
|
||||
load_rc_config $name
|
||||
${stdenv.lib.concatMapStrings (rcvarName: ''
|
||||
${lib.concatMapStrings (rcvarName: ''
|
||||
: ''${name}_${rcvarName}:=${toString builtins.getAttr rcvarName rcvarsDefaults}
|
||||
'') (builtins.attrNames rcvarsDefaults)}
|
||||
|
||||
''
|
||||
+ stdenv.lib.optionalString (_command != null) ''
|
||||
+ lib.optionalString (_command != null) ''
|
||||
command=${_command}
|
||||
''
|
||||
+ stdenv.lib.optionalString (_commandArgs != []) ''
|
||||
command_args="${stdenv.lib.escapeShellArgs _commandArgs}"
|
||||
+ lib.optionalString (_commandArgs != []) ''
|
||||
command_args="${lib.escapeShellArgs _commandArgs}"
|
||||
''
|
||||
+ stdenv.lib.optionalString (requiredDirs != []) ''
|
||||
+ lib.optionalString (requiredDirs != []) ''
|
||||
required_dirs="${toString requiredDirs}"
|
||||
''
|
||||
+ stdenv.lib.optionalString (requiredFiles != []) ''
|
||||
+ lib.optionalString (requiredFiles != []) ''
|
||||
required_files="${toString requiredFiles}"
|
||||
''
|
||||
+ stdenv.lib.optionalString (requiredVars != []) ''
|
||||
+ lib.optionalString (requiredVars != []) ''
|
||||
required_vars="${toString requiredVars}"
|
||||
''
|
||||
+ stdenv.lib.optionalString (requiredModules != []) ''
|
||||
+ lib.optionalString (requiredModules != []) ''
|
||||
required_modules="${toString requiredModules}"
|
||||
''
|
||||
+ stdenv.lib.optionalString (_pidFile != null) ''
|
||||
+ lib.optionalString (_pidFile != null) ''
|
||||
pidfile="${_pidFile}"
|
||||
''
|
||||
+ stdenv.lib.optionalString (reloadSignal != defaultReloadSignal) ''
|
||||
+ lib.optionalString (reloadSignal != defaultReloadSignal) ''
|
||||
sig_reload="${reloadSignal}"
|
||||
''
|
||||
+ stdenv.lib.optionalString (stopSignal != defaultStopSignal) ''
|
||||
+ lib.optionalString (stopSignal != defaultStopSignal) ''
|
||||
sig_stop="${stopSignal}"
|
||||
''
|
||||
+ stdenv.lib.optionalString (nice != null) ''
|
||||
+ lib.optionalString (nice != null) ''
|
||||
${name}_nice=${toString nice}
|
||||
''
|
||||
+ stdenv.lib.optionalString (directory != null) ''
|
||||
+ lib.optionalString (directory != null) ''
|
||||
${name}_chdir=${directory}
|
||||
''
|
||||
+ stdenv.lib.optionalString (_user != null) ''
|
||||
+ lib.optionalString (_user != null) ''
|
||||
${name}_user=${_user}
|
||||
''
|
||||
+ stdenv.lib.optionalString (envFile != null) ''
|
||||
+ lib.optionalString (envFile != null) ''
|
||||
${name}_env_file=${envFile}
|
||||
''
|
||||
+ stdenv.lib.optionalString (extraCommands != []) ''
|
||||
+ lib.optionalString (extraCommands != []) ''
|
||||
extra_commands="${toString extraCommands}"
|
||||
''
|
||||
+ stdenv.lib.concatMapStrings (commandName:
|
||||
+ lib.concatMapStrings (commandName:
|
||||
let
|
||||
command = builtins.getAttr commandName commands;
|
||||
in
|
||||
stdenv.lib.optionalString (command ? pre) ''${commandName}_precmd=''${name}_pre${commandName}
|
||||
lib.optionalString (command ? pre) ''${commandName}_precmd=''${name}_pre${commandName}
|
||||
''
|
||||
+ stdenv.lib.optionalString (command ? implementation) ''${commandName}_cmd=''${name}_${commandName}
|
||||
+ lib.optionalString (command ? implementation) ''${commandName}_cmd=''${name}_${commandName}
|
||||
''
|
||||
+ stdenv.lib.optionalString (command ? post) ''${commandName}_postcmd=''${name}_post${commandName}
|
||||
+ lib.optionalString (command ? post) ''${commandName}_postcmd=''${name}_post${commandName}
|
||||
''
|
||||
) (builtins.attrNames commands)
|
||||
+ stdenv.lib.optionalString (path != []) ''
|
||||
+ lib.optionalString (path != []) ''
|
||||
|
||||
PATH=${util.composePathEnvVariable { inherit path; }}
|
||||
export PATH
|
||||
''
|
||||
+ "\n"
|
||||
+ stdenv.lib.concatMapStrings (commandName:
|
||||
+ lib.concatMapStrings (commandName:
|
||||
let
|
||||
command = builtins.getAttr commandName commands;
|
||||
in
|
||||
''
|
||||
${stdenv.lib.optionalString (command ? pre) ''
|
||||
${lib.optionalString (command ? pre) ''
|
||||
${name}_pre${commandName}()
|
||||
{
|
||||
${command.pre}
|
||||
}
|
||||
''}
|
||||
${stdenv.lib.optionalString (command ? implementation) ''
|
||||
${lib.optionalString (command ? implementation) ''
|
||||
${name}_${commandName}()
|
||||
{
|
||||
${command.implementation}
|
||||
}
|
||||
''}
|
||||
${stdenv.lib.optionalString (command ? post) ''
|
||||
${lib.optionalString (command ? post) ''
|
||||
${name}_post${commandName}()
|
||||
{
|
||||
${command.post}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ createBSDRCScript, stdenv }:
|
||||
{ createBSDRCScript, lib }:
|
||||
|
||||
{ name
|
||||
, description
|
||||
|
@ -31,14 +31,14 @@ let
|
|||
command = if daemon != null then daemon else foregroundProcess;
|
||||
commandIsDaemon = daemon != null;
|
||||
commandArgs = if daemon != null then daemonArgs else foregroundProcessArgs;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
} // stdenv.lib.optionalAttrs (initialize != "") {
|
||||
} // lib.optionalAttrs (initialize != "") {
|
||||
commands.start.pre = initialize;
|
||||
};
|
||||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
in
|
||||
createBSDRCScript targetSpecificArgs
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
{stdenv, forceDisableUserChange}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "rc.subr";
|
||||
src = /etc/rc.subr;
|
||||
if forceDisableUserChange then
|
||||
# Disable the limits command when we want to deploy processes as an unprivileged user
|
||||
buildCommand = if forceDisableUserChange then ''
|
||||
sed -e 's|limits -C $_login_class $_limits||' $src > $out
|
||||
'' else ''
|
||||
cp $src $out
|
||||
'';
|
||||
}
|
||||
stdenv.mkDerivation {
|
||||
name = "rc.subr";
|
||||
src = /etc/rc.subr;
|
||||
|
||||
buildCommand = ''
|
||||
sed -e 's|limits -C $_login_class $_limits||' $src > $out
|
||||
'';
|
||||
}
|
||||
else
|
||||
# Otherwise, simply return the path to the rc subroutines
|
||||
"/etc/rc.subr"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, writeTextFile
|
||||
|
||||
# Prefix that is in front of all Windows services generated by this function
|
||||
|
@ -43,7 +44,7 @@ name
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
_environment = util.appendPathToEnvironment {
|
||||
|
@ -59,51 +60,51 @@ let
|
|||
--disp
|
||||
${displayName}
|
||||
''
|
||||
+ stdenv.lib.optionalString (type != "auto") ''
|
||||
+ lib.optionalString (type != "auto") ''
|
||||
--type
|
||||
${type}
|
||||
''
|
||||
+ stdenv.lib.optionalString (args != []) ''
|
||||
+ lib.optionalString (args != []) ''
|
||||
--args
|
||||
${builtins.concatStringsSep " " (map (arg: stdenv.lib.escapeShellArg arg) args)}
|
||||
${builtins.concatStringsSep " " (map (arg: lib.escapeShellArg arg) args)}
|
||||
''
|
||||
+
|
||||
stdenv.lib.concatMapStrings (variableName:
|
||||
lib.concatMapStrings (variableName:
|
||||
let
|
||||
value = builtins.getAttr variableName _environment;
|
||||
in
|
||||
''
|
||||
--env
|
||||
'${variableName}=${stdenv.lib.escape [ "'" ] (toString value)}'
|
||||
'${variableName}=${lib.escape [ "'" ] (toString value)}'
|
||||
'') (builtins.attrNames _environment)
|
||||
+ stdenv.lib.optionalString (user != null) ''
|
||||
+ lib.optionalString (user != null) ''
|
||||
--user
|
||||
${user}
|
||||
''
|
||||
+ stdenv.lib.optionalString (password != null) ''
|
||||
+ lib.optionalString (password != null) ''
|
||||
--passwd
|
||||
${password}
|
||||
''
|
||||
+ stdenv.lib.optionalString (stdin != null) ''
|
||||
+ lib.optionalString (stdin != null) ''
|
||||
--stdin
|
||||
${stdin}
|
||||
''
|
||||
+ stdenv.lib.optionalString (stdout != null) ''
|
||||
+ lib.optionalString (stdout != null) ''
|
||||
--stdout
|
||||
${stdout}
|
||||
''
|
||||
+ stdenv.lib.optionalString (stderr != null) ''
|
||||
+ lib.optionalString (stderr != null) ''
|
||||
--stderr
|
||||
${stderr}
|
||||
''
|
||||
+ stdenv.lib.optionalString (terminateSignal != "TERM") ''
|
||||
+ lib.optionalString (terminateSignal != "TERM") ''
|
||||
--termsig
|
||||
${terminateSignal}
|
||||
''
|
||||
+ stdenv.lib.optionalString terminateOnShutdown ''
|
||||
+ lib.optionalString terminateOnShutdown ''
|
||||
--shutdown
|
||||
''
|
||||
+ stdenv.lib.concatMapStrings (dependency: ''
|
||||
+ lib.concatMapStrings (dependency: ''
|
||||
--dep
|
||||
${dependency.name}
|
||||
'') dependencies;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{ createCygrunsrvParams
|
||||
, stdenv
|
||||
, lib
|
||||
, writeTextFile
|
||||
, runtimeDir ? "/var/run"
|
||||
}:
|
||||
|
@ -33,7 +34,7 @@
|
|||
|
||||
let
|
||||
generateForegroundProxy = import ../util/generate-foreground-proxy.nix {
|
||||
inherit stdenv writeTextFile;
|
||||
inherit stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
generatedTargetSpecificArgs = {
|
||||
|
@ -59,6 +60,6 @@ let
|
|||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
in
|
||||
createCygrunsrvParams targetSpecificArgs
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{stdenv, createCredentials, forceDisableUserChange}:
|
||||
{stdenv, lib, createCredentials, forceDisableUserChange}:
|
||||
|
||||
{ name
|
||||
, process
|
||||
|
@ -17,7 +17,7 @@ stdenv.mkDerivation {
|
|||
mkdir -p $out/etc/dysnomia/process
|
||||
cat > $out/etc/dysnomia/process/${name} <<EOF
|
||||
process=${process}
|
||||
${stdenv.lib.optionalString (pidFile != null) "pidFile=${pidFile}"}
|
||||
${lib.optionalString (pidFile != null) "pidFile=${pidFile}"}
|
||||
EOF
|
||||
|
||||
ln -s ${credentialsSpec}/dysnomia-support $out/dysnomia-support
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ createProcessScript, writeTextFile, stdenv, daemon, basePackages
|
||||
{ createProcessScript, writeTextFile, stdenv, lib, daemon, basePackages
|
||||
, runtimeDir, logDir, tmpDir, forceDisableUserChange
|
||||
}:
|
||||
|
||||
|
@ -29,7 +29,7 @@ in
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
_environment = util.appendPathToEnvironment {
|
||||
|
@ -84,26 +84,26 @@ let
|
|||
environment = _environment;
|
||||
allowSystemPath = true;
|
||||
}
|
||||
+ stdenv.lib.optionalString (umask != null) ''
|
||||
+ lib.optionalString (umask != null) ''
|
||||
umask ${umask}
|
||||
''
|
||||
+ stdenv.lib.optionalString (initialize != null) ''
|
||||
+ lib.optionalString (initialize != null) ''
|
||||
${initialize}
|
||||
''
|
||||
+ stdenv.lib.optionalString (directory != null) ''
|
||||
+ lib.optionalString (directory != null) ''
|
||||
cd ${directory}
|
||||
''
|
||||
+ stdenv.lib.optionalString (nice != null) ''
|
||||
+ lib.optionalString (nice != null) ''
|
||||
nice -n ${toString nice}
|
||||
''
|
||||
+ "exec ${invocationCommand}";
|
||||
};
|
||||
} // stdenv.lib.optionalAttrs (_pidFile != null) {
|
||||
} // lib.optionalAttrs (_pidFile != null) {
|
||||
pidFile = _pidFile;
|
||||
};
|
||||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
in
|
||||
createProcessScript targetSpecificArgs
|
||||
|
|
|
@ -7,7 +7,7 @@ let
|
|||
}).disnix;
|
||||
|
||||
generateCompoundProxy = import ../../util/generate-compound-proxy.nix {
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
inherit (pkgs) stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
disnixDataDir = "${pkgs.disnix}/share/disnix";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
let
|
||||
generateCompoundProxy = import ../../util/generate-compound-proxy.nix {
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
inherit (pkgs) stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
disnixDataDir = "${pkgs.disnix}/share/disnix";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{stdenv}:
|
||||
{stdenv, lib}:
|
||||
|
||||
{ name
|
||||
, dockerImage
|
||||
|
@ -20,8 +20,8 @@ let
|
|||
else throw "Unknown type for the dockerCreateParameters";
|
||||
|
||||
_dockerCreateParameters = dockerCreateParametersList
|
||||
++ stdenv.lib.optional useHostNixStore { name = "volume"; value = "/nix/store:/nix/store"; }
|
||||
++ stdenv.lib.optional useHostNetwork { name = "network"; value = "host"; }
|
||||
++ lib.optional useHostNixStore { name = "volume"; value = "/nix/store:/nix/store"; }
|
||||
++ lib.optional useHostNetwork { name = "network"; value = "host"; }
|
||||
++ map (mapStateDirVolume: { name = "volume"; value = "${mapStateDirVolume}:${mapStateDirVolume}"; }) mapStateDirVolumes;
|
||||
|
||||
priority = if dependencies == [] then 1
|
||||
|
@ -42,7 +42,7 @@ stdenv.mkDerivation {
|
|||
EOF
|
||||
|
||||
cat > $out/${name}-docker-createparams <<EOF
|
||||
${stdenv.lib.concatMapStringsSep "\n" (nameValuePair:
|
||||
${lib.concatMapStringsSep "\n" (nameValuePair:
|
||||
"${if builtins.stringLength nameValuePair.name > 1 then "--" else "-"}${nameValuePair.name}"
|
||||
+ (if nameValuePair ? value then "\n${toString nameValuePair.value}" else "")
|
||||
) _dockerCreateParameters}
|
||||
|
@ -50,17 +50,17 @@ stdenv.mkDerivation {
|
|||
|
||||
touch $out/${sequenceNumberToString priority}-${name}-docker-priority
|
||||
|
||||
${stdenv.lib.optionalString useHostNixStore ''
|
||||
${lib.optionalString useHostNixStore ''
|
||||
# Add configuration files with Nix store paths used from the host system so that they will not be garbage collected
|
||||
${stdenv.lib.optionalString (cmd != "") ''
|
||||
${lib.optionalString (cmd != "") ''
|
||||
cat > $out/${name}-docker-cmd <<EOF
|
||||
${toString cmd}
|
||||
EOF
|
||||
''}
|
||||
|
||||
${stdenv.lib.optionalString (storePaths != []) ''
|
||||
${lib.optionalString (storePaths != []) ''
|
||||
cat > $out/${name}-storepaths <<EOF
|
||||
${stdenv.lib.concatMapStrings (storePath: "${storePath}\n") storePaths}
|
||||
${lib.concatMapStrings (storePath: "${storePath}\n") storePaths}
|
||||
EOF
|
||||
''}
|
||||
''}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ createDockerContainer, dockerTools, stdenv, writeTextFile, findutils, glibc, dysnomia, basePackages, runtimeDir, stateDir, forceDisableUserChange, createCredentials }:
|
||||
{ createDockerContainer, dockerTools, stdenv, lib, writeTextFile, findutils, glibc, dysnomia, basePackages, runtimeDir, stateDir, forceDisableUserChange, createCredentials }:
|
||||
|
||||
{ name
|
||||
, description
|
||||
|
@ -26,13 +26,13 @@
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
commonTools = (import ../../../tools {}).common;
|
||||
|
||||
generateForegroundProxy = import ../util/generate-foreground-proxy.nix {
|
||||
inherit stdenv writeTextFile;
|
||||
inherit stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
cmd = if foregroundProcess != null
|
||||
|
@ -45,9 +45,9 @@ let
|
|||
wrapDaemon = false;
|
||||
executable = foregroundProcess;
|
||||
inherit name initialize runtimeDir stdenv;
|
||||
} // stdenv.lib.optionalAttrs (instanceName != null) {
|
||||
} // lib.optionalAttrs (instanceName != null) {
|
||||
inherit instanceName;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
});
|
||||
in
|
||||
|
@ -58,9 +58,9 @@ let
|
|||
wrapDaemon = true;
|
||||
executable = daemon;
|
||||
inherit name runtimeDir initialize stdenv;
|
||||
} // stdenv.lib.optionalAttrs (instanceName != null) {
|
||||
} // lib.optionalAttrs (instanceName != null) {
|
||||
inherit instanceName;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
});
|
||||
in
|
||||
|
@ -86,16 +86,16 @@ let
|
|||
tag = "latest";
|
||||
|
||||
runAsRoot = import ../docker/setup.nix {
|
||||
inherit dockerTools commonTools stdenv dysnomia findutils glibc stateDir runtimeDir forceDisableUserChange credentialsSpec;
|
||||
inherit dockerTools commonTools lib dysnomia findutils glibc stateDir runtimeDir forceDisableUserChange credentialsSpec;
|
||||
};
|
||||
|
||||
config = {
|
||||
Cmd = cmdWithoutContext;
|
||||
} // stdenv.lib.optionalAttrs (_environment != {}) {
|
||||
} // lib.optionalAttrs (_environment != {}) {
|
||||
Env = map (varName: "${varName}=${toString (builtins.getAttr varName _environment)}") (builtins.attrNames _environment);
|
||||
} // stdenv.lib.optionalAttrs (directory != null) {
|
||||
} // lib.optionalAttrs (directory != null) {
|
||||
WorkingDir = directory;
|
||||
} // stdenv.lib.optionalAttrs (_user != null) {
|
||||
} // lib.optionalAttrs (_user != null) {
|
||||
User = _user;
|
||||
};
|
||||
};
|
||||
|
@ -104,7 +104,7 @@ let
|
|||
if overrides ? image
|
||||
then
|
||||
if builtins.isFunction overrides.image then overrides.image generatedDockerImageArgs
|
||||
else stdenv.lib.recursiveUpdate generatedDockerImageArgs overrides.image
|
||||
else lib.recursiveUpdate generatedDockerImageArgs overrides.image
|
||||
else generatedDockerImageArgs;
|
||||
|
||||
dockerImage = dockerTools.buildImage dockerImageArgs;
|
||||
|
@ -121,7 +121,7 @@ let
|
|||
if overrides ? container
|
||||
then
|
||||
if builtins.isFunction overrides.container then overrides.container generatedDockerContainerArgs
|
||||
else stdenv.lib.recursiveUpdate generatedDockerContainerArgs overrides.container
|
||||
else lib.recursiveUpdate generatedDockerContainerArgs overrides.container
|
||||
else generatedDockerContainerArgs;
|
||||
in
|
||||
createDockerContainer dockerContainerArgs
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{dockerTools, commonTools, stdenv, dysnomia, findutils, glibc, stateDir, runtimeDir, forceDisableUserChange, credentialsSpec}:
|
||||
{dockerTools, commonTools, lib, dysnomia, findutils, glibc, stateDir, runtimeDir, forceDisableUserChange, credentialsSpec}:
|
||||
|
||||
''
|
||||
${dockerTools.shadowSetup}
|
||||
|
@ -10,13 +10,13 @@
|
|||
# Initialize common state directories
|
||||
${commonTools}/bin/nixproc-init-state --state-dir ${stateDir} --runtime-dir ${runtimeDir}
|
||||
|
||||
${stdenv.lib.optionalString (!forceDisableUserChange && credentialsSpec != null) ''
|
||||
${lib.optionalString (!forceDisableUserChange && credentialsSpec != null) ''
|
||||
export PATH=$PATH:${findutils}/bin:${glibc.bin}/bin
|
||||
${dysnomia}/bin/dysnomia-addgroups ${credentialsSpec}
|
||||
${dysnomia}/bin/dysnomia-addusers ${credentialsSpec}
|
||||
''}
|
||||
|
||||
${stdenv.lib.optionalString forceDisableUserChange ''
|
||||
${lib.optionalString forceDisableUserChange ''
|
||||
groupadd -r nogroup
|
||||
useradd -r nobody -g nogroup -d /dev/null
|
||||
''}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{ writeTextFile
|
||||
, stdenv
|
||||
, lib
|
||||
, createCredentials
|
||||
|
||||
# Specifies whether user changing functionality should be disabled or not
|
||||
|
@ -24,11 +25,11 @@ name
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
environment = util.appendPathToEnvironment {
|
||||
environment = stdenv.lib.mapAttrs (name: value: toString value) args.EnvironmentVariables or {}; # Convert all environment variables to strings
|
||||
environment = lib.mapAttrs (name: value: toString value) args.EnvironmentVariables or {}; # Convert all environment variables to strings
|
||||
inherit path;
|
||||
};
|
||||
|
||||
|
@ -36,13 +37,13 @@ let
|
|||
|
||||
properties = {
|
||||
Label = label;
|
||||
} // removeAttrs args ([ "name" "path" "credentials" "postInstall" ] ++ stdenv.lib.optional forceDisableUserChange "UserName") // stdenv.lib.optionalAttrs (environment != {}) {
|
||||
} // removeAttrs args ([ "name" "path" "credentials" "postInstall" ] ++ lib.optional forceDisableUserChange "UserName") // lib.optionalAttrs (environment != {}) {
|
||||
EnvironmentVariables = environment;
|
||||
};
|
||||
|
||||
attrsToPList = attrs:
|
||||
"<dict>\n"
|
||||
+ stdenv.lib.concatMapStrings (name:
|
||||
+ lib.concatMapStrings (name:
|
||||
let
|
||||
value = builtins.getAttr name attrs;
|
||||
in
|
||||
|
@ -55,7 +56,7 @@ let
|
|||
|
||||
listToPList = list:
|
||||
"<array>\n"
|
||||
+ stdenv.lib.concatMapStrings (value: exprToPList value + "\n") list
|
||||
+ lib.concatMapStrings (value: exprToPList value + "\n") list
|
||||
+ "</array>\n";
|
||||
|
||||
exprToPList = expr:
|
||||
|
@ -68,7 +69,7 @@ let
|
|||
else if exprType == "float" then "<real>${toString expr}</real>"
|
||||
else if exprType == "string" then "<string>${expr}</string>"
|
||||
else if exprType == "set" then
|
||||
if stdenv.lib.isDerivation expr
|
||||
if lib.isDerivation expr
|
||||
then "<string>${expr}</string>"
|
||||
else attrsToPList expr
|
||||
else if exprType == "list" then listToPList expr
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{ createLaunchdDaemon
|
||||
, stdenv
|
||||
, lib
|
||||
, writeTextFile
|
||||
, runtimeDir ? "/var/run"
|
||||
, forceDisableUserChange
|
||||
|
@ -28,7 +29,7 @@
|
|||
|
||||
let
|
||||
generateForegroundProxy = import ../util/generate-foreground-proxy.nix {
|
||||
inherit stdenv writeTextFile;
|
||||
inherit stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
chainLoadUser = if initialize == "" || forceDisableUserChange then null
|
||||
|
@ -41,9 +42,9 @@ let
|
|||
user = chainLoadUser;
|
||||
executable = foregroundProcess;
|
||||
inherit name initialize runtimeDir stdenv;
|
||||
} // stdenv.lib.optionalAttrs (instanceName != null) {
|
||||
} // lib.optionalAttrs (instanceName != null) {
|
||||
inherit instanceName;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
})
|
||||
else generateForegroundProxy ({
|
||||
|
@ -51,34 +52,34 @@ let
|
|||
user = chainLoadUser;
|
||||
executable = daemon;
|
||||
inherit name initialize runtimeDir stdenv;
|
||||
} // stdenv.lib.optionalAttrs (instanceName != null) {
|
||||
} // lib.optionalAttrs (instanceName != null) {
|
||||
inherit instanceName;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
});
|
||||
ProgramArguments = [ Program ] ++ (if foregroundProcess != null then foregroundProcessArgs else daemonArgs);
|
||||
|
||||
generatedTargetSpecificArgs = {
|
||||
inherit name credentials postInstall Program;
|
||||
} // stdenv.lib.optionalAttrs (ProgramArguments != [ Program ]) {
|
||||
} // lib.optionalAttrs (ProgramArguments != [ Program ]) {
|
||||
inherit ProgramArguments;
|
||||
} // stdenv.lib.optionalAttrs (environment != {}) {
|
||||
} // lib.optionalAttrs (environment != {}) {
|
||||
EnvironmentVariables = environment;
|
||||
} // stdenv.lib.optionalAttrs (path != []) {
|
||||
} // lib.optionalAttrs (path != []) {
|
||||
inherit path;
|
||||
} // stdenv.lib.optionalAttrs (directory != null) {
|
||||
} // lib.optionalAttrs (directory != null) {
|
||||
WorkingDirectory = directory;
|
||||
} // stdenv.lib.optionalAttrs (umask != null) {
|
||||
} // lib.optionalAttrs (umask != null) {
|
||||
Umask = umask;
|
||||
} // stdenv.lib.optionalAttrs (nice != null) {
|
||||
} // lib.optionalAttrs (nice != null) {
|
||||
Nice = nice;
|
||||
} // stdenv.lib.optionalAttrs (user != null && chainLoadUser == null) {
|
||||
} // lib.optionalAttrs (user != null && chainLoadUser == null) {
|
||||
UserName = user;
|
||||
};
|
||||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
|
||||
daemonConfig = createLaunchdDaemon targetSpecificArgs;
|
||||
in
|
||||
|
|
|
@ -23,7 +23,7 @@ let
|
|||
processes = if exprFile == null then {} else processesFun processesArgs;
|
||||
|
||||
createServiceBundle = import ./create-service-bundle.nix {
|
||||
inherit (pkgs) stdenv;
|
||||
inherit (pkgs) stdenv lib;
|
||||
};
|
||||
|
||||
processesList = map (processName:
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{stdenv, execline, logDir, logDirUser, logDirGroup, forceDisableUserChange}:
|
||||
{stdenv, lib, execline, logDir, logDirUser, logDirGroup, forceDisableUserChange}:
|
||||
{name}:
|
||||
|
||||
let
|
||||
serviceName = "${name}-log";
|
||||
|
||||
util = import ./util.nix {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
serviceLogDir = "${logDir}/s6-log/${name}";
|
||||
|
@ -24,7 +24,7 @@ stdenv.mkDerivation {
|
|||
#!${execline}/bin/execlineb -P
|
||||
|
||||
foreground { mkdir -p ${serviceLogDir} }
|
||||
${stdenv.lib.optionalString (!forceDisableUserChange) ''
|
||||
${lib.optionalString (!forceDisableUserChange) ''
|
||||
foreground { chown -R ${logDirUser}:${logDirGroup} ${serviceLogDir} }
|
||||
s6-setuidgid ${logDirUser}
|
||||
''}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{stdenv, createCredentials, createLogServiceForLongRunService}:
|
||||
{stdenv, lib, createCredentials, createLogServiceForLongRunService}:
|
||||
|
||||
{ name
|
||||
# When a service is flagged as essential it will not stop with the command: s6-rc -d change foo, but only: s6-rc -D change foo
|
||||
|
@ -45,7 +45,7 @@ let
|
|||
credentialsSpec = createCredentials credentials;
|
||||
|
||||
util = import ./util.nix {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
logService = createLogServiceForLongRunService {
|
||||
|
@ -79,7 +79,7 @@ stdenv.mkDerivation {
|
|||
+ util.generateServiceName { service = _producerFor; filename = "producer-for"; }
|
||||
+ util.generateServiceNameList { services = consumerFor; filename = "consumer-for"; }
|
||||
+ util.generateStringProperty { value = pipelineName; filename = "pipeline-name"; }
|
||||
+ stdenv.lib.optionalString autoGenerateLogService ''
|
||||
+ lib.optionalString autoGenerateLogService ''
|
||||
cd ..
|
||||
ln -sfn ${logService}/etc/s6/sv/${name}-log
|
||||
''
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{stdenv, createCredentials}:
|
||||
{stdenv, lib, createCredentials}:
|
||||
|
||||
{ name
|
||||
# When a service is flagged as essential it will not stop with the command: s6-rc -d change foo, but only: s6-rc -D change foo
|
||||
|
@ -19,7 +19,7 @@ let
|
|||
credentialsSpec = createCredentials credentials;
|
||||
|
||||
util = import ./util.nix {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{stdenv}:
|
||||
{stdenv, lib}:
|
||||
|
||||
{ name
|
||||
# When a service is flagged as essential it will not stop with the command: s6-rc -d change foo, but only: s6-rc -D change foo
|
||||
|
@ -11,7 +11,7 @@
|
|||
|
||||
let
|
||||
util = import ./util.nix {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
{stdenv, execline, createCredentials, logDir, logDirUser ? "s6-log", logDirGroup ? "s6-log", forceDisableUserChange}:
|
||||
{stdenv, lib, execline, createCredentials, logDir, logDirUser ? "s6-log", logDirGroup ? "s6-log", forceDisableUserChange}:
|
||||
|
||||
rec {
|
||||
createLogServiceForLongRunService = import ./create-log-service-for-longrun-service.nix {
|
||||
inherit stdenv execline logDir logDirUser logDirGroup forceDisableUserChange;
|
||||
inherit stdenv lib execline logDir logDirUser logDirGroup forceDisableUserChange;
|
||||
};
|
||||
createLongRunService = import ./create-longrun-service.nix {
|
||||
inherit stdenv createCredentials createLogServiceForLongRunService;
|
||||
inherit stdenv lib createCredentials createLogServiceForLongRunService;
|
||||
};
|
||||
createOneShotService = import ./create-oneshot-service.nix {
|
||||
inherit stdenv createCredentials;
|
||||
inherit stdenv lib createCredentials;
|
||||
};
|
||||
createServiceBundle = import ./create-service-bundle.nix {
|
||||
inherit stdenv;
|
||||
inherit stdenv lib;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ s6, s6-rc, basePackages, stdenv, writeTextFile, execline, tmpDir, runtimeDir, forceDisableUserChange }:
|
||||
{ s6, s6-rc, basePackages, stdenv, lib, writeTextFile, execline, tmpDir, runtimeDir, forceDisableUserChange }:
|
||||
|
||||
{ name
|
||||
, description
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
s6-rcBasePackages = basePackages ++ [ execline s6 ];
|
||||
|
@ -49,7 +49,7 @@ let
|
|||
if _environment == {} then null
|
||||
else writeTextFile {
|
||||
name = "envfile";
|
||||
text = stdenv.lib.concatMapStrings (envName:
|
||||
text = lib.concatMapStrings (envName:
|
||||
let
|
||||
envValue = builtins.getAttr envName _environment;
|
||||
in
|
||||
|
@ -74,22 +74,22 @@ let
|
|||
#!${execline}/bin/execlineb -P
|
||||
|
||||
''
|
||||
+ stdenv.lib.optionalString (envFile != null) ''
|
||||
+ lib.optionalString (envFile != null) ''
|
||||
envfile ${envFile}
|
||||
''
|
||||
+ stdenv.lib.optionalString (initializeScript != null) ''
|
||||
+ lib.optionalString (initializeScript != null) ''
|
||||
foreground { ${initializeScript} }
|
||||
''
|
||||
+ stdenv.lib.optionalString (umask != null) ''
|
||||
+ lib.optionalString (umask != null) ''
|
||||
execline-umask ${umask}
|
||||
''
|
||||
+ stdenv.lib.optionalString (directory != null) ''
|
||||
+ lib.optionalString (directory != null) ''
|
||||
execline-cd ${directory}
|
||||
''
|
||||
+ stdenv.lib.optionalString (_user != null) ''
|
||||
+ lib.optionalString (_user != null) ''
|
||||
s6-setuidgid ${_user}
|
||||
''
|
||||
+ stdenv.lib.optionalString (nice != null) ''
|
||||
+ lib.optionalString (nice != null) ''
|
||||
nice -n ${toString nice}
|
||||
''
|
||||
# Always forward standard error so that it can be captured by the s6-log service
|
||||
|
@ -98,7 +98,7 @@ let
|
|||
'';
|
||||
|
||||
escapeArgs = args:
|
||||
stdenv.lib.concatMapStringsSep " " (arg: "\"${stdenv.lib.replaceStrings ["\""] ["\\\""] (toString arg)}\"") args;
|
||||
lib.concatMapStringsSep " " (arg: "\"${lib.replaceStrings ["\""] ["\\\""] (toString arg)}\"") args;
|
||||
in
|
||||
if foregroundProcess != null then
|
||||
let
|
||||
|
@ -115,7 +115,7 @@ if foregroundProcess != null then
|
|||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
in
|
||||
s6-rc.createLongRunService targetSpecificArgs
|
||||
else if daemon != null then
|
||||
|
@ -143,7 +143,7 @@ else if daemon != null then
|
|||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
in
|
||||
s6-rc.createOneShotService targetSpecificArgs
|
||||
else throw "No foreground process or daemon known!"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{writeTextFile, stdenv, createCredentials, supervisor, basePackages, forceDisableUserChange ? false, runtimeDir}:
|
||||
{writeTextFile, stdenv, lib, createCredentials, supervisor, basePackages, forceDisableUserChange ? false, runtimeDir}:
|
||||
|
||||
{
|
||||
# A name that identifies the process instance
|
||||
|
@ -25,15 +25,15 @@ name
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
properties = removeAttrs params ([ "name" "command" "useProxy" "pidFile" "path" "environment" "dependencies" "credentials" "postInstall" ] ++ stdenv.lib.optional forceDisableUserChange "user");
|
||||
properties = removeAttrs params ([ "name" "command" "useProxy" "pidFile" "path" "environment" "dependencies" "credentials" "postInstall" ] ++ lib.optional forceDisableUserChange "user");
|
||||
|
||||
priority = if dependencies == [] then 1
|
||||
else builtins.head (builtins.sort (a: b: a > b) (map (dependency: dependency.priority) dependencies)) + 1;
|
||||
|
||||
_command = (stdenv.lib.optionalString useProxy "${supervisor}/bin/pidproxy ${runtimeDir}/${pidFile} ") + command;
|
||||
_command = (lib.optionalString useProxy "${supervisor}/bin/pidproxy ${runtimeDir}/${pidFile} ") + command;
|
||||
|
||||
_environment = util.appendPathToEnvironment {
|
||||
inherit environment;
|
||||
|
@ -47,14 +47,14 @@ let
|
|||
command=${_command}
|
||||
priority=${toString priority}
|
||||
''
|
||||
+ (if _environment == {} then "" else "environment=" + stdenv.lib.concatMapStringsSep "," (name:
|
||||
+ (if _environment == {} then "" else "environment=" + lib.concatMapStringsSep "," (name:
|
||||
let
|
||||
value = builtins.getAttr name _environment;
|
||||
in
|
||||
"${name}=\"${stdenv.lib.escape [ "\"" ] (toString value)}\""
|
||||
"${name}=\"${lib.escape [ "\"" ] (toString value)}\""
|
||||
) (builtins.attrNames _environment)) +
|
||||
"\n"
|
||||
+ stdenv.lib.concatMapStrings (name:
|
||||
+ lib.concatMapStrings (name:
|
||||
let
|
||||
value = builtins.getAttr name properties;
|
||||
in
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ createSupervisordProgram, stdenv, writeTextFile, runtimeDir, forceDisableUserChange }:
|
||||
{ createSupervisordProgram, stdenv, lib, writeTextFile, runtimeDir, forceDisableUserChange }:
|
||||
|
||||
{ name
|
||||
, description
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
let
|
||||
generateForegroundProxy = import ../util/generate-foreground-proxy.nix {
|
||||
inherit stdenv writeTextFile;
|
||||
inherit stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
chainLoadUser = if initialize == "" || forceDisableUserChange then null
|
||||
|
@ -37,36 +37,36 @@ let
|
|||
wrapDaemon = false;
|
||||
executable = foregroundProcess;
|
||||
inherit name initialize runtimeDir stdenv;
|
||||
} // stdenv.lib.optionalAttrs (instanceName != null) {
|
||||
} // lib.optionalAttrs (instanceName != null) {
|
||||
inherit instanceName;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
})) + " ${stdenv.lib.escapeShellArgs foregroundProcessArgs}"
|
||||
})) + " ${lib.escapeShellArgs foregroundProcessArgs}"
|
||||
else (generateForegroundProxy ({
|
||||
wrapDaemon = true;
|
||||
user = chainLoadUser;
|
||||
executable = daemon;
|
||||
inherit name initialize runtimeDir stdenv;
|
||||
} // stdenv.lib.optionalAttrs (instanceName != null) {
|
||||
} // lib.optionalAttrs (instanceName != null) {
|
||||
inherit instanceName;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
})) + " ${stdenv.lib.escapeShellArgs daemonArgs}";
|
||||
})) + " ${lib.escapeShellArgs daemonArgs}";
|
||||
|
||||
generatedTargetSpecificArgs = {
|
||||
inherit name command path environment dependencies credentials postInstall;
|
||||
} // stdenv.lib.optionalAttrs (umask != null) {
|
||||
} // lib.optionalAttrs (umask != null) {
|
||||
inherit umask;
|
||||
} // stdenv.lib.optionalAttrs (nice != null) {
|
||||
} // lib.optionalAttrs (nice != null) {
|
||||
inherit nice;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
} // stdenv.lib.optionalAttrs (user != null && chainLoadUser == null) {
|
||||
} // lib.optionalAttrs (user != null && chainLoadUser == null) {
|
||||
inherit user;
|
||||
};
|
||||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
in
|
||||
createSupervisordProgram targetSpecificArgs
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{ writeTextFile
|
||||
, stdenv
|
||||
, lib
|
||||
, createCredentials
|
||||
, basePackages
|
||||
|
||||
|
@ -32,7 +33,7 @@ name
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
sections = removeAttrs args [ "name" "environment" "dependencies" "path" "credentials" "postInstall" ];
|
||||
|
@ -43,7 +44,7 @@ let
|
|||
};
|
||||
|
||||
generateEnvironmentVariables = environment:
|
||||
stdenv.lib.concatMapStrings (name:
|
||||
lib.concatMapStrings (name:
|
||||
let
|
||||
value = builtins.getAttr name _environment;
|
||||
in
|
||||
|
@ -63,7 +64,7 @@ let
|
|||
''
|
||||
|
||||
[${title}]
|
||||
${stdenv.lib.concatMapStrings (name:
|
||||
${lib.concatMapStrings (name:
|
||||
let
|
||||
value = builtins.getAttr name properties;
|
||||
in
|
||||
|
@ -75,7 +76,7 @@ let
|
|||
+ (if title == "Unit" then mapDependencies dependencies else "");
|
||||
|
||||
generateSections = sections:
|
||||
stdenv.lib.concatMapStrings (title:
|
||||
lib.concatMapStrings (title:
|
||||
let
|
||||
properties = builtins.getAttr title sections;
|
||||
in
|
||||
|
@ -88,11 +89,11 @@ let
|
|||
name = "${name}.service";
|
||||
text = ''
|
||||
${generateSections sections}
|
||||
${stdenv.lib.optionalString (!(sections ? Service) && _environment != {}) ''
|
||||
${lib.optionalString (!(sections ? Service) && _environment != {}) ''
|
||||
[Service]
|
||||
|
||||
${generateEnvironmentVariables _environment}''}
|
||||
${stdenv.lib.optionalString (!(sections ? Unit) && dependencies != []) ''
|
||||
${lib.optionalString (!(sections ? Unit) && dependencies != []) ''
|
||||
|
||||
[Unit]
|
||||
${mapDependencies dependencies}
|
||||
|
@ -109,10 +110,10 @@ stdenv.mkDerivation {
|
|||
mkdir -p $out/etc/systemd/system
|
||||
ln -s ${service} $out/etc/systemd/system/${prefix}${name}.service
|
||||
|
||||
${stdenv.lib.optionalString (dependencies != []) ''
|
||||
${lib.optionalString (dependencies != []) ''
|
||||
mkdir -p $out/etc/systemd/system/${prefix}${name}.service.wants
|
||||
|
||||
${stdenv.lib.concatMapStrings (dependency: ''
|
||||
${lib.concatMapStrings (dependency: ''
|
||||
ln -s ${dependency}/etc/systemd/system/${dependency.name}.service $out/etc/systemd/system/${prefix}${name}.service.wants
|
||||
'') dependencies}
|
||||
''}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ createSystemdService, stdenv, writeTextFile }:
|
||||
{ createSystemdService, stdenv, lib, writeTextFile }:
|
||||
|
||||
{ name
|
||||
, description
|
||||
|
@ -33,27 +33,29 @@ let
|
|||
Description = description;
|
||||
};
|
||||
Service = {
|
||||
ExecStart = if foregroundProcess != null then "${foregroundProcess} ${stdenv.lib.escapeShellArgs foregroundProcessArgs}" else "${daemon} ${stdenv.lib.escapeShellArgs daemonArgs}";
|
||||
ExecStart = if foregroundProcess != null
|
||||
then "${foregroundProcess} ${lib.escapeShellArgs foregroundProcessArgs}"
|
||||
else "${daemon} ${lib.escapeShellArgs daemonArgs}";
|
||||
Type = if foregroundProcess != null then "simple" else "forking";
|
||||
} // stdenv.lib.optionalAttrs (initialize != "") {
|
||||
ExecStartPre = stdenv.lib.optionalString (user != null) "+" + generatePreStartScript {
|
||||
} // lib.optionalAttrs (initialize != "") {
|
||||
ExecStartPre = lib.optionalString (user != null) "+" + generatePreStartScript {
|
||||
inherit name initialize;
|
||||
};
|
||||
} // stdenv.lib.optionalAttrs (directory != null) {
|
||||
} // lib.optionalAttrs (directory != null) {
|
||||
WorkingDirectory = directory;
|
||||
} // stdenv.lib.optionalAttrs (umask != null) {
|
||||
} // lib.optionalAttrs (umask != null) {
|
||||
UMask = umask;
|
||||
} // stdenv.lib.optionalAttrs (nice != null) {
|
||||
} // lib.optionalAttrs (nice != null) {
|
||||
Nice = nice;
|
||||
} // stdenv.lib.optionalAttrs (foregroundProcess == null && pidFile != null) {
|
||||
} // lib.optionalAttrs (foregroundProcess == null && pidFile != null) {
|
||||
PIDFile = pidFile;
|
||||
} // stdenv.lib.optionalAttrs (user != null) {
|
||||
} // lib.optionalAttrs (user != null) {
|
||||
User = user;
|
||||
};
|
||||
};
|
||||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
in
|
||||
createSystemdService targetSpecificArgs
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, writeTextFile
|
||||
, daemon
|
||||
, initFunctions
|
||||
|
@ -31,7 +32,7 @@
|
|||
$0 start
|
||||
''
|
||||
# Specifies which runlevels are supported
|
||||
, supportedRunlevels ? stdenv.lib.range 0 6
|
||||
, supportedRunlevels ? lib.range 0 6
|
||||
# The minimum start/stop sequence number
|
||||
, minSequence ? 0
|
||||
# The maximum start/stop sequence number
|
||||
|
@ -97,7 +98,7 @@ name
|
|||
|
||||
let
|
||||
util = import ../util {
|
||||
inherit (stdenv) lib;
|
||||
inherit lib;
|
||||
};
|
||||
|
||||
isCommonActivity = {activityName}:
|
||||
|
@ -105,13 +106,13 @@ let
|
|||
|
||||
# Enumerates the activities in a logical order -- the common activities first, then the remaining activities in alphabetical order
|
||||
enumerateActivities = activities:
|
||||
stdenv.lib.optional (activities ? start) "start"
|
||||
++ stdenv.lib.optional (activities ? stop) "stop"
|
||||
++ stdenv.lib.optional (activities ? reload) "reload"
|
||||
++ stdenv.lib.optional (activities ? restart) "restart"
|
||||
++ stdenv.lib.optional (activities ? status) "status"
|
||||
lib.optional (activities ? start) "start"
|
||||
++ lib.optional (activities ? stop) "stop"
|
||||
++ lib.optional (activities ? reload) "reload"
|
||||
++ lib.optional (activities ? restart) "restart"
|
||||
++ lib.optional (activities ? status) "status"
|
||||
++ builtins.filter (activityName: !isCommonActivity { inherit activityName; }) (builtins.attrNames activities)
|
||||
++ stdenv.lib.optional (activities ? "*") "*";
|
||||
++ lib.optional (activities ? "*") "*";
|
||||
|
||||
_user = util.determineUser {
|
||||
inherit user forceDisableUserChange;
|
||||
|
@ -125,13 +126,13 @@ let
|
|||
inherit pidFile instanceName pidFilesDir;
|
||||
};
|
||||
|
||||
_instructions = (stdenv.lib.optionalAttrs (process != null) {
|
||||
_instructions = (lib.optionalAttrs (process != null) {
|
||||
start = {
|
||||
activity = "Starting";
|
||||
instruction =
|
||||
let
|
||||
invocationCommand =
|
||||
if processIsDaemon then "${startDaemon} ${stdenv.lib.optionalString (_pidFile != null) "-f -p ${_pidFile}"} ${stdenv.lib.optionalString (nice != null) "-n ${nice}"} "
|
||||
if processIsDaemon then "${startDaemon} ${lib.optionalString (_pidFile != null) "-f -p ${_pidFile}"} ${lib.optionalString (nice != null) "-n ${nice}"} "
|
||||
+ util.invokeDaemon {
|
||||
inherit process args;
|
||||
su = "$(type -p su)"; # the loadproc command requires a full path to an executable
|
||||
|
@ -151,7 +152,7 @@ let
|
|||
''
|
||||
${initialize}
|
||||
''
|
||||
+ stdenv.lib.optionalString (directory != null) ''
|
||||
+ lib.optionalString (directory != null) ''
|
||||
cd ${directory}
|
||||
''
|
||||
+ ''
|
||||
|
@ -160,17 +161,17 @@ let
|
|||
};
|
||||
stop = {
|
||||
activity = "Stopping";
|
||||
instruction = "${stopDaemon} ${stdenv.lib.optionalString (_pidFile != null) "-p ${_pidFile}"} ${process}";
|
||||
instruction = "${stopDaemon} ${lib.optionalString (_pidFile != null) "-p ${_pidFile}"} ${process}";
|
||||
};
|
||||
reload = {
|
||||
activity = "Reloading";
|
||||
instruction = "${reloadDaemon} ${stdenv.lib.optionalString (_pidFile != null) "-p ${_pidFile}"} ${process} ${reloadSignal}";
|
||||
instruction = "${reloadDaemon} ${lib.optionalString (_pidFile != null) "-p ${_pidFile}"} ${process} ${reloadSignal}";
|
||||
};
|
||||
}) // instructions;
|
||||
|
||||
_activities =
|
||||
let
|
||||
convertedInstructions = stdenv.lib.mapAttrs (name: instruction:
|
||||
convertedInstructions = lib.mapAttrs (name: instruction:
|
||||
''
|
||||
log_info_msg "${instruction.activity} ${description}..."
|
||||
${instruction.instruction}
|
||||
|
@ -178,8 +179,8 @@ let
|
|||
''
|
||||
) _instructions;
|
||||
|
||||
defaultActivities = stdenv.lib.optionalAttrs (process != null) {
|
||||
status = "${statusCommand} ${stdenv.lib.optionalString (_pidFile != null) "-p ${_pidFile}"} ${process}";
|
||||
defaultActivities = lib.optionalAttrs (process != null) {
|
||||
status = "${statusCommand} ${lib.optionalString (_pidFile != null) "-p ${_pidFile}"} ${process}";
|
||||
restart = restartActivity;
|
||||
} // {
|
||||
"*" = ''
|
||||
|
@ -190,10 +191,10 @@ let
|
|||
in
|
||||
removeAttrs (convertedInstructions // defaultActivities // activities) removeActivities;
|
||||
|
||||
_defaultStart = if runlevels != [] then stdenv.lib.intersectLists runlevels supportedRunlevels
|
||||
_defaultStart = if runlevels != [] then lib.intersectLists runlevels supportedRunlevels
|
||||
else defaultStart;
|
||||
|
||||
_defaultStop = if runlevels != [] then stdenv.lib.subtractLists _defaultStart supportedRunlevels
|
||||
_defaultStop = if runlevels != [] then lib.subtractLists _defaultStart supportedRunlevels
|
||||
else defaultStop;
|
||||
|
||||
_environment = util.appendPathToEnvironment {
|
||||
|
@ -209,9 +210,9 @@ let
|
|||
## BEGIN INIT INFO
|
||||
# Provides: ${name}
|
||||
''
|
||||
+ stdenv.lib.optionalString (_defaultStart != []) "# Default-Start: ${toString _defaultStart}\n"
|
||||
+ stdenv.lib.optionalString (_defaultStop != []) "# Default-Stop: ${toString _defaultStop}\n"
|
||||
+ stdenv.lib.optionalString (dependencies != []) ''
|
||||
+ lib.optionalString (_defaultStart != []) "# Default-Start: ${toString _defaultStart}\n"
|
||||
+ lib.optionalString (_defaultStop != []) "# Default-Stop: ${toString _defaultStop}\n"
|
||||
+ lib.optionalString (dependencies != []) ''
|
||||
# Should-Start: ${toString (map (dependency: dependency.name) dependencies)}
|
||||
# Should-Stop: ${toString (map (dependency: dependency.name) dependencies)}
|
||||
''
|
||||
|
@ -222,7 +223,7 @@ let
|
|||
${initialInstructions}
|
||||
${globalInstructions}
|
||||
''
|
||||
+ stdenv.lib.optionalString (umask != null) ''
|
||||
+ lib.optionalString (umask != null) ''
|
||||
umask ${umask}
|
||||
''
|
||||
+ util.printShellEnvironmentVariables {
|
||||
|
@ -232,7 +233,7 @@ let
|
|||
+ ''
|
||||
|
||||
case "$1" in
|
||||
${stdenv.lib.concatMapStrings (activityName:
|
||||
${lib.concatMapStrings (activityName:
|
||||
let
|
||||
instructions = builtins.getAttr activityName _activities;
|
||||
in
|
||||
|
@ -271,12 +272,12 @@ stdenv.mkDerivation {
|
|||
mkdir -p init.d
|
||||
ln -s ${initdScript} init.d/${name}
|
||||
|
||||
${stdenv.lib.concatMapStrings (runlevel: ''
|
||||
${lib.concatMapStrings (runlevel: ''
|
||||
mkdir -p rc${toString runlevel}.d
|
||||
ln -s ../init.d/${name} rc${toString runlevel}.d/S${sequenceNumberToString startSequenceNumber}${name}
|
||||
'') _defaultStart}
|
||||
|
||||
${stdenv.lib.concatMapStrings (runlevel: ''
|
||||
${lib.concatMapStrings (runlevel: ''
|
||||
mkdir -p rc${toString runlevel}.d
|
||||
ln -s ../init.d/${name} rc${toString runlevel}.d/K${sequenceNumberToString stopSequenceNumber}${name}
|
||||
'') _defaultStop}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ createSystemVInitScript, stdenv }:
|
||||
{ createSystemVInitScript, lib }:
|
||||
|
||||
{ name
|
||||
, description
|
||||
|
@ -29,12 +29,12 @@ let
|
|||
process = if daemon != null then daemon else foregroundProcess;
|
||||
processIsDaemon = daemon != null;
|
||||
args = if daemon != null then daemonArgs else foregroundProcessArgs;
|
||||
} // stdenv.lib.optionalAttrs (pidFile != null) {
|
||||
} // lib.optionalAttrs (pidFile != null) {
|
||||
inherit pidFile;
|
||||
};
|
||||
|
||||
targetSpecificArgs =
|
||||
if builtins.isFunction overrides then overrides generatedTargetSpecificArgs
|
||||
else stdenv.lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
else lib.recursiveUpdate generatedTargetSpecificArgs overrides;
|
||||
in
|
||||
createSystemVInitScript targetSpecificArgs
|
||||
|
|
|
@ -7,7 +7,7 @@ let
|
|||
}).sysvinit;
|
||||
|
||||
generateCompoundProxy = import ../../util/generate-compound-proxy.nix {
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
inherit (pkgs) stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
runlevel = "3";
|
||||
|
|
|
@ -7,7 +7,7 @@ let
|
|||
}).sysvinit;
|
||||
|
||||
generateCompoundProxy = import ../../util/generate-compound-proxy.nix {
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
inherit (pkgs) stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
runlevel = "3";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{stdenv, writeTextFile}:
|
||||
{stdenv, lib, writeTextFile}:
|
||||
{startCommand, stopCommand, path ? []}:
|
||||
|
||||
writeTextFile {
|
||||
|
@ -14,7 +14,7 @@ writeTextFile {
|
|||
exit 0
|
||||
}
|
||||
|
||||
export PATH=${stdenv.lib.escapeShellArg (builtins.concatStringsSep ":" (map (pathComponent: "${pathComponent}/bin") path))}:$PATH
|
||||
export PATH=${lib.escapeShellArg (builtins.concatStringsSep ":" (map (pathComponent: "${pathComponent}/bin") path))}:$PATH
|
||||
|
||||
${startCommand}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{stdenv, writeTextFile}:
|
||||
{stdenv, lib, writeTextFile}:
|
||||
|
||||
{ name
|
||||
, wrapDaemon
|
||||
|
@ -43,7 +43,7 @@ writeTextFile {
|
|||
trap _interrupt SIGINT
|
||||
|
||||
# Start process in the background as a daemon
|
||||
${stdenv.lib.optionalString (user != null) "${chainload-user}/bin/nixproc-chainload-user ${user}"} ${executable} "$@"
|
||||
${lib.optionalString (user != null) "${chainload-user}/bin/nixproc-chainload-user ${user}"} ${executable} "$@"
|
||||
|
||||
# Wait for the PID file to become available. Useful to work with daemons that don't behave well enough.
|
||||
count=1 # Start with 1, because 0 returns a non-zero exit status when incrementing it
|
||||
|
@ -80,7 +80,7 @@ writeTextFile {
|
|||
blocker_pid=$!
|
||||
wait $blocker_pid
|
||||
'' else ''
|
||||
exec ${stdenv.lib.optionalString (user != null) "${chainload-user}/bin/nixproc-chainload-user ${user} "}"${executable}" "$@"
|
||||
exec ${lib.optionalString (user != null) "${chainload-user}/bin/nixproc-chainload-user ${user} "}"${executable}" "$@"
|
||||
''}
|
||||
'';
|
||||
executable = true;
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
{stdenv, ids ? {}, forceDisableUserChange}:
|
||||
{stdenv, lib, ids ? {}, forceDisableUserChange}:
|
||||
{groups ? {}, users ? {}}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "credentials";
|
||||
buildCommand = ''
|
||||
${stdenv.lib.optionalString (!forceDisableUserChange && groups != {}) ''
|
||||
${lib.optionalString (!forceDisableUserChange && groups != {}) ''
|
||||
mkdir -p $out/dysnomia-support/groups
|
||||
|
||||
${stdenv.lib.concatMapStrings (groupname:
|
||||
${lib.concatMapStrings (groupname:
|
||||
let
|
||||
group = builtins.getAttr groupname groups;
|
||||
in
|
||||
''
|
||||
${stdenv.lib.optionalString (ids ? gids && builtins.hasAttr groupname ids.gids) ''echo "gid=${toString ids.gids."${groupname}"}" > $out/dysnomia-support/groups/${groupname}''}
|
||||
${lib.optionalString (ids ? gids && builtins.hasAttr groupname ids.gids) ''echo "gid=${toString ids.gids."${groupname}"}" > $out/dysnomia-support/groups/${groupname}''}
|
||||
|
||||
cat >> $out/dysnomia-support/groups/${groupname} <<EOF
|
||||
${stdenv.lib.concatMapStrings (propertyName:
|
||||
${lib.concatMapStrings (propertyName:
|
||||
let
|
||||
value = builtins.getAttr propertyName group;
|
||||
in
|
||||
"${propertyName}=${stdenv.lib.escapeShellArg value}\n"
|
||||
"${propertyName}=${lib.escapeShellArg value}\n"
|
||||
) (builtins.attrNames group)}
|
||||
EOF
|
||||
''
|
||||
|
@ -28,12 +28,12 @@ stdenv.mkDerivation {
|
|||
|
||||
mkdir -p $out/dysnomia-support/users
|
||||
|
||||
${stdenv.lib.concatMapStrings (username:
|
||||
${lib.concatMapStrings (username:
|
||||
let
|
||||
user = builtins.getAttr username users;
|
||||
in
|
||||
# If we force disable user changes, we should still create the desired home directory, if applicable
|
||||
if forceDisableUserChange then stdenv.lib.optionalString (user ? createHomeDir && user.createHomeDir) ''
|
||||
if forceDisableUserChange then lib.optionalString (user ? createHomeDir && user.createHomeDir) ''
|
||||
cat > $out/dysnomia-support/users/${username} <<EOF
|
||||
homeDir=${user.homeDir}
|
||||
createHomeDir=1
|
||||
|
@ -42,14 +42,14 @@ stdenv.mkDerivation {
|
|||
''
|
||||
# Regular user creation configuration
|
||||
else ''
|
||||
${stdenv.lib.optionalString (ids ? uids && builtins.hasAttr username ids.uids) ''echo "uid=${toString ids.uids."${username}"}" > $out/dysnomia-support/users/${username}''}
|
||||
${lib.optionalString (ids ? uids && builtins.hasAttr username ids.uids) ''echo "uid=${toString ids.uids."${username}"}" > $out/dysnomia-support/users/${username}''}
|
||||
|
||||
cat >> $out/dysnomia-support/users/${username} <<EOF
|
||||
${stdenv.lib.concatMapStrings (propertyName:
|
||||
${lib.concatMapStrings (propertyName:
|
||||
let
|
||||
value = builtins.getAttr propertyName user;
|
||||
in
|
||||
"${propertyName}=${stdenv.lib.escapeShellArg value}\n"
|
||||
"${propertyName}=${lib.escapeShellArg value}\n"
|
||||
) (builtins.attrNames user)}
|
||||
EOF
|
||||
''
|
||||
|
|
|
@ -19,7 +19,7 @@ let
|
|||
|
||||
properties = builtins.fromJSON (builtins.readFile configFile);
|
||||
|
||||
normalizedProperties = properties // pkgs.stdenv.lib.optionalAttrs (properties ? dependencies) {
|
||||
normalizedProperties = properties // pkgs.lib.optionalAttrs (properties ? dependencies) {
|
||||
dependencies = map (dependency: createManagedProcessFromConfig "${dependency}/${builtins.substring 33 (builtins.stringLength dependency) (baseNameOf dependency)}.json") properties.dependencies;
|
||||
};
|
||||
in
|
||||
|
|
|
@ -9,12 +9,12 @@ let
|
|||
];
|
||||
|
||||
createCredentials = import ../../create-credentials {
|
||||
inherit (pkgs) stdenv;
|
||||
inherit (pkgs) stdenv lib;
|
||||
inherit ids forceDisableUserChange;
|
||||
};
|
||||
|
||||
createSystemVInitScript = import ../../backends/sysvinit/create-sysvinit-script.nix {
|
||||
inherit (pkgs) stdenv writeTextFile daemon;
|
||||
inherit (pkgs) stdenv lib writeTextFile daemon;
|
||||
inherit createCredentials runtimeDir logDir tmpDir forceDisableUserChange;
|
||||
|
||||
initFunctions = import ../../backends/sysvinit/init-functions.nix {
|
||||
|
@ -26,32 +26,32 @@ let
|
|||
|
||||
generateSystemVInitScript = import ../../backends/sysvinit/generate-sysvinit-script.nix {
|
||||
inherit createSystemVInitScript;
|
||||
inherit (pkgs) stdenv;
|
||||
inherit (pkgs) lib;
|
||||
};
|
||||
|
||||
createSystemdService = import ../../backends/systemd/create-systemd-service.nix {
|
||||
inherit (pkgs) writeTextFile stdenv;
|
||||
inherit (pkgs) writeTextFile stdenv lib;
|
||||
inherit createCredentials basePackages forceDisableUserChange;
|
||||
};
|
||||
|
||||
generateSystemdService = import ../../backends/systemd/generate-systemd-service.nix {
|
||||
inherit createSystemdService;
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
inherit (pkgs) stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
createSupervisordProgram = import ../../backends/supervisord/create-supervisord-program.nix {
|
||||
inherit (pkgs) writeTextFile stdenv;
|
||||
inherit (pkgs) writeTextFile stdenv lib;
|
||||
inherit (pkgs.pythonPackages) supervisor;
|
||||
inherit createCredentials basePackages forceDisableUserChange runtimeDir;
|
||||
};
|
||||
|
||||
generateSupervisordProgram = import ../../backends/supervisord/generate-supervisord-program.nix {
|
||||
inherit createSupervisordProgram runtimeDir forceDisableUserChange;
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
inherit (pkgs) stdenv lib writeTextFile;
|
||||
};
|
||||
|
||||
createBSDRCScript = import ../../backends/bsdrc/create-bsdrc-script.nix {
|
||||
inherit (pkgs) writeTextFile stdenv;
|
||||
inherit (pkgs) writeTextFile stdenv lib;
|
||||
inherit createCredentials forceDisableUserChange runtimeDir tmpDir;
|
||||
|
||||
rcSubr = import ../../backends/bsdrc/rcsubr.nix {
|
||||
|
@ -62,54 +62,54 @@ let
|
|||
|
||||
generateBSDRCScript = import ../../backends/bsdrc/generate-bsdrc-script.nix {
|
||||
inherit createBSDRCScript;
|
||||
inherit (pkgs) stdenv;
|
||||
inherit (pkgs) lib;
|
||||
};
|
||||
|
||||
createLaunchdDaemon = import ../../backends/launchd/create-launchd-daemon.nix {
|
||||
inherit (pkgs) writeTextFile stdenv;
|
||||
inherit (pkgs) writeTextFile stdenv lib;
|
||||
inherit createCredentials forceDisableUserChange;
|
||||
};
|
||||
|
||||
generateLaunchdDaemon = import ../../backends/launchd/generate-launchd-daemon.nix {
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
inherit (pkgs) stdenv writeTextFile lib;
|
||||
inherit createLaunchdDaemon runtimeDir forceDisableUserChange;
|
||||
};
|
||||
|
||||
createCygrunsrvParams = import ../../backends/cygrunsrv/create-cygrunsrv-params.nix {
|
||||
inherit (pkgs) writeTextFile stdenv;
|
||||
inherit (pkgs) writeTextFile stdenv lib;
|
||||
};
|
||||
|
||||
generateCygrunsrvParams = import ../../backends/cygrunsrv/generate-cygrunsrv-params.nix {
|
||||
inherit (pkgs) stdenv writeTextFile;
|
||||
inherit (pkgs) stdenv writeTextFile lib;
|
||||
inherit createCygrunsrvParams runtimeDir;
|
||||
};
|
||||
|
||||
createProcessScript = import ../../backends/disnix/create-process-script.nix {
|
||||
inherit (pkgs) stdenv;
|
||||
inherit (pkgs) stdenv lib;
|
||||
inherit createCredentials forceDisableUserChange;
|
||||
};
|
||||
|
||||
generateProcessScript = import ../../backends/disnix/generate-process-script.nix {
|
||||
inherit (pkgs) stdenv writeTextFile daemon;
|
||||
inherit (pkgs) stdenv writeTextFile lib daemon;
|
||||
inherit createProcessScript runtimeDir logDir tmpDir forceDisableUserChange basePackages;
|
||||
};
|
||||
|
||||
createDockerContainer = import ../../backends/docker/create-docker-container.nix {
|
||||
inherit (pkgs) stdenv;
|
||||
inherit (pkgs) stdenv lib;
|
||||
};
|
||||
|
||||
generateDockerContainer = import ../../backends/docker/generate-docker-container.nix {
|
||||
inherit (pkgs) stdenv writeTextFile dockerTools findutils glibc dysnomia;
|
||||
inherit (pkgs) stdenv writeTextFile lib dockerTools findutils glibc dysnomia;
|
||||
inherit createDockerContainer basePackages runtimeDir stateDir forceDisableUserChange createCredentials;
|
||||
};
|
||||
|
||||
s6-rc = import ../../backends/s6-rc {
|
||||
inherit (pkgs) stdenv execline;
|
||||
inherit (pkgs) stdenv lib execline;
|
||||
inherit createCredentials logDir forceDisableUserChange;
|
||||
};
|
||||
|
||||
generateS6RCService = import ../../backends/s6-rc/generate-s6-rc-service.nix {
|
||||
inherit (pkgs) stdenv writeTextFile execline s6;
|
||||
inherit (pkgs) stdenv writeTextFile lib execline s6;
|
||||
inherit s6-rc basePackages tmpDir runtimeDir forceDisableUserChange;
|
||||
};
|
||||
in
|
||||
|
|
|
@ -12,6 +12,10 @@ rec {
|
|||
};
|
||||
|
||||
tests = {
|
||||
builds = import ./tests/builds.nix {
|
||||
inherit pkgs;
|
||||
};
|
||||
|
||||
multi-process-images = import ./tests/multi-process-images.nix {
|
||||
inherit nixpkgs;
|
||||
};
|
||||
|
@ -62,6 +66,7 @@ rec {
|
|||
release = pkgs.releaseTools.aggregate {
|
||||
name = "nix-processmgmt";
|
||||
constituents = builtins.attrValues tools
|
||||
++ builtins.attrValues tests.builds
|
||||
++ builtins.attrValues tests.webapps-agnostic
|
||||
++ [
|
||||
tests.webapps-sysvinit
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{pkgs ? import <nixpkgs> {}}:
|
||||
|
||||
let
|
||||
nix-processmgmt = ./..;
|
||||
|
||||
backends = [ "bsdrc" "cygrunsrv" "disnix" "docker" "launchd" "s6-rc" "supervisord" "systemd" "sysvinit" ];
|
||||
in
|
||||
pkgs.lib.genAttrs backends (backend: import "${nix-processmgmt}/nixproc/backends/${backend}/build-${backend}-env.nix" ({
|
||||
exprFile = ../examples/webapps-agnostic/processes.nix;
|
||||
} // pkgs.lib.optionalAttrs (backend == "disnix") {
|
||||
disnixDataDir = "${pkgs.disnix}/share/disnix";
|
||||
}))
|
Loading…
Reference in New Issue