diff options
Diffstat (limited to 'nixos/modules/services/misc')
-rw-r--r-- | nixos/modules/services/misc/confd.nix | 2 | ||||
-rw-r--r-- | nixos/modules/services/misc/etcd.nix | 8 | ||||
-rw-r--r-- | nixos/modules/services/misc/gitit.nix | 157 | ||||
-rw-r--r-- | nixos/modules/services/misc/nix-daemon.nix | 24 | ||||
-rw-r--r-- | nixos/modules/services/misc/nix-gc.nix | 2 | ||||
-rw-r--r-- | nixos/modules/services/misc/rogue.nix | 1 |
6 files changed, 114 insertions, 80 deletions
diff --git a/nixos/modules/services/misc/confd.nix b/nixos/modules/services/misc/confd.nix index 98738b6497bf..50532a8a16fb 100644 --- a/nixos/modules/services/misc/confd.nix +++ b/nixos/modules/services/misc/confd.nix @@ -63,7 +63,7 @@ in { package = mkOption { description = "Confd package to use."; - default = pkgs.goPackages.confd; + default = pkgs.confd; type = types.package; }; }; diff --git a/nixos/modules/services/misc/etcd.nix b/nixos/modules/services/misc/etcd.nix index 26d2753879d0..e1839b936f01 100644 --- a/nixos/modules/services/misc/etcd.nix +++ b/nixos/modules/services/misc/etcd.nix @@ -122,14 +122,6 @@ in { mkdir -m 0700 -p ${cfg.dataDir} if [ "$(id -u)" = 0 ]; then chown etcd ${cfg.dataDir}; fi ''; - postStart = '' - until ${pkgs.etcdctl}/bin/etcdctl set /nixos/state 'up'; do - sleep 1; - done - until ${pkgs.etcdctl}/bin/etcdctl get /nixos/state | grep up; do - sleep 1; - done - ''; }; environment.systemPackages = [ pkgs.etcdctl ]; diff --git a/nixos/modules/services/misc/gitit.nix b/nixos/modules/services/misc/gitit.nix index 56e735d7356b..10a706fbd71d 100644 --- a/nixos/modules/services/misc/gitit.nix +++ b/nixos/modules/services/misc/gitit.nix @@ -8,6 +8,8 @@ let homeDir = "/var/lib/gitit"; + toYesNo = b: if b then "yes" else "no"; + gititShared = with cfg.haskellPackages; gitit + "/share/" + pkgs.stdenv.system + "-" + ghc.name + "/" + gitit.pname + "-" + gitit.version; gititWithPkgs = hsPkgs: extras: hsPkgs.ghcWithPackages (self: with self; [ gitit ] ++ (extras self)); @@ -17,9 +19,6 @@ let in writeScript "gitit" '' #!${stdenv.shell} cd $HOME - export PATH="${makeSearchPath "bin" ( - [ git curl ] ++ (if cfg.pdfExport == "yes" then [texLiveFull] else []) - )}:$PATH"; export NIX_GHC="${env}/bin/ghc" export NIX_GHCPKG="${env}/bin/ghc-pkg" export NIX_GHC_DOCDIR="${env}/share/doc/ghc/html" @@ -27,11 +26,7 @@ let ${env}/bin/gitit -f ${configFile} ''; - gititOptions = let - - yesNo = types.enum [ "yes" "no" ]; - - in { + gititOptions = { enable = mkOption { type = types.bool; @@ -40,7 +35,6 @@ let }; haskellPackages = mkOption { - default = pkgs.haskellPackages; defaultText = "pkgs.haskellPackages"; example = literalExample "pkgs.haskell.packages.ghc784"; description = "haskellPackages used to build gitit and plugins."; @@ -143,7 +137,6 @@ let staticDir = mkOption { type = types.path; - default = gititShared + "/data/static"; description = '' Specifies the path of the static directory (containing javascript, css, and images). If it does not exist, gitit will create it and @@ -204,8 +197,8 @@ let }; showLhsBirdTracks = mkOption { - type = yesNo; - default = "no"; + type = types.bool; + default = false; description = '' Specifies whether to show Haskell code blocks in "bird style", with "> " at the beginning of each line. @@ -214,7 +207,6 @@ let templatesDir = mkOption { type = types.path; - default = gititShared + "/data/templates"; description = '' Specifies the path of the directory containing page templates. If it does not exist, gitit will create it with default templates. Users @@ -286,8 +278,8 @@ let }; tableOfContents = mkOption { - type = yesNo; - default = "yes"; + type = types.bool; + default = true; description = '' Specifies whether to print a tables of contents (with links to sections) on each wiki page. @@ -295,23 +287,18 @@ let }; plugins = mkOption { - type = types.path; - default = gititShared + "/plugins/Dot.hs"; + type = with types; listOf str; description = '' - Specifies a list of plugins to load. Plugins may be specified either - by their path or by their module name. If the plugin name starts + Specifies a list of plugins to load. Plugins may be specified either + by their path or by their module name. If the plugin name starts with Gitit.Plugin., gitit will assume that the plugin is an installed module and will not try to find a source file. - Examples: - plugins: plugins/DotPlugin.hs, CapitalizeEmphasisPlugin.hs - plugins: plugins/DotPlugin - plugins: Gitit.Plugin.InterwikiLinks ''; }; useCache = mkOption { - type = yesNo; - default = "no"; + type = types.bool; + default = false; description = '' Specifies whether to cache rendered pages. Note that if use-feed is selected, feeds will be cached regardless of the value of use-cache. @@ -342,14 +329,14 @@ let }; debugMode = mkOption { - type = yesNo; - default = "no"; + type = types.bool; + default = false; description = "Causes debug information to be logged while gitit is running."; }; compressResponses = mkOption { - type = yesNo; - default = "yes"; + type = types.bool; + default = true; description = "Specifies whether HTTP responses should be compressed."; }; @@ -361,16 +348,18 @@ let line of the file should contain two fields, separated by whitespace. The first field is the mime type, the second is a file extension. For example: - video/x-ms-wmx wmx +<programlisting> +video/x-ms-wmx wmx +</programlisting> If the file is not found, some simple defaults will be used. ''; }; useReCaptcha = mkOption { - type = yesNo; - default = "no"; + type = types.bool; + default = false; description = '' - If "yes", causes gitit to use the reCAPTCHA service + If true, causes gitit to use the reCAPTCHA service (http://recaptcha.net) to prevent bots from creating accounts. ''; }; @@ -475,8 +464,8 @@ let }; useFeed = mkOption { - type = yesNo; - default = "no"; + type = types.bool; + default = false; description = '' Specifies whether an ATOM feed should be enabled (for the site and for individual pages). @@ -488,19 +477,19 @@ let default = null; description = '' The base URL of the wiki, to be used in constructing feed IDs and RPX - token_urls. Set this if use-feed is 'yes' or authentication-method + token_urls. Set this if useFeed is false or authentication-method is 'rpx'. ''; }; absoluteUrls = mkOption { - type = yesNo; - default = "no"; + type = types.bool; + default = false; description = '' Make wikilinks absolute with respect to the base-url. So, for example, in a wiki served at the base URL '/wiki', on a page Sub/Page, the wikilink '[Cactus]()' will produce a link to - '/wiki/Cactus' if absolute-urls is 'yes', and a relative link to + '/wiki/Cactus' if absoluteUrls is true, and a relative link to 'Cactus' (referring to '/wiki/Sub/Cactus') if absolute-urls is 'no'. ''; }; @@ -518,10 +507,10 @@ let }; pdfExport = mkOption { - type = yesNo; - default = "no"; + type = types.bool; + default = false; description = '' - If yes, PDF will appear in export options. PDF will be created using + If true, PDF will appear in export options. PDF will be created using pdflatex, which must be installed and in the path. Note that PDF exports create significant additional server load. ''; @@ -541,10 +530,10 @@ let }; xssSanitize = mkOption { - type = yesNo; - default = "yes"; + type = types.bool; + default = true; description = '' - If yes, all HTML (including that produced by pandoc) is filtered + If true, all HTML (including that produced by pandoc) is filtered through xss-sanitize. Set to no only if you trust all of your users. ''; }; @@ -564,7 +553,7 @@ let default-page-type: ${cfg.defaultPageType} math: ${cfg.math} mathjax-script: ${cfg.mathJaxScript} - show-lhs-bird-tracks: ${cfg.showLhsBirdTracks} + show-lhs-bird-tracks: ${toYesNo cfg.showLhsBirdTracks} templates-dir: ${cfg.templatesDir} log-file: ${cfg.logFile} log-level: ${cfg.logLevel} @@ -572,16 +561,16 @@ let no-delete: ${cfg.noDelete} no-edit: ${cfg.noEdit} default-summary: ${cfg.defaultSummary} - table-of-contents: ${cfg.tableOfContents} - plugins: ${cfg.plugins} - use-cache: ${cfg.useCache} + table-of-contents: ${toYesNo cfg.tableOfContents} + plugins: ${concatStringsSep "," cfg.plugins} + use-cache: ${toYesNo cfg.useCache} cache-dir: ${cfg.cacheDir} max-upload-size: ${cfg.maxUploadSize} max-page-size: ${cfg.maxPageSize} - debug-mode: ${cfg.debugMode} - compress-responses: ${cfg.compressResponses} + debug-mode: ${toYesNo cfg.debugMode} + compress-responses: ${toYesNo cfg.compressResponses} mime-types-file: ${cfg.mimeTypesFile} - use-recaptcha: ${cfg.useReCaptcha} + use-recaptcha: ${toYesNo cfg.useReCaptcha} recaptcha-private-key: ${toString cfg.reCaptchaPrivateKey} recaptcha-public-key: ${toString cfg.reCaptchaPublicKey} access-question: ${cfg.accessQuestion} @@ -590,14 +579,14 @@ let rpx-key: ${toString cfg.rpxKey} mail-command: ${cfg.mailCommand} reset-password-message: ${cfg.resetPasswordMessage} - use-feed: ${cfg.useFeed} + use-feed: ${toYesNo cfg.useFeed} base-url: ${toString cfg.baseUrl} - absolute-urls: ${cfg.absoluteUrls} + absolute-urls: ${toYesNo cfg.absoluteUrls} feed-days: ${toString cfg.feedDays} feed-refresh-time: ${toString cfg.feedRefreshTime} - pdf-export: ${cfg.pdfExport} + pdf-export: ${toYesNo cfg.pdfExport} pandoc-user-data: ${toString cfg.pandocUserData} - xss-sanitize: ${cfg.xssSanitize} + xss-sanitize: ${toYesNo cfg.xssSanitize} ''; in @@ -608,6 +597,13 @@ in config = mkIf cfg.enable { + services.gitit = { + haskellPackages = mkDefault pkgs.haskellPackages; + staticDir = gititShared + "/data/static"; + templatesDir = gititShared + "/data/templates"; + plugins = [ ]; + }; + users.extraUsers.gitit = { group = config.users.extraGroups.gitit.name; description = "Gitit user"; @@ -625,8 +621,16 @@ in description = "Git and Pandoc Powered Wiki"; after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; - - preStart = with cfg; '' + path = with pkgs; [ curl ] + ++ optional cfg.pdfExport texLiveFull + ++ optional (cfg.repositoryType == "darcs") darcs + ++ optional (cfg.repositoryType == "mercurial") mercurial + ++ optional (cfg.repositoryType == "git") git; + + preStart = let + gm = "gitit@${config.networking.hostName}"; + in + with cfg; '' chown ${uid}:${gid} -R ${homeDir} for dir in ${repositoryPath} ${staticDir} ${templatesDir} ${cacheDir} do @@ -638,14 +642,35 @@ in fi done cd ${repositoryPath} - if [ ! -d .git ] - then - ${pkgs.git}/bin/git init - ${pkgs.git}/bin/git config user.email "gitit@${config.networking.hostName}" - ${pkgs.git}/bin/git config user.name "gitit" - chown ${uid}:${gid} -R {repositoryPath} - fi - cd - + ${ + if repositoryType == "darcs" then + '' + if [ ! -d _darcs ] + then + ${pkgs.darcs}/bin/darcs initialize + echo "${gm}" > _darcs/prefs/email + '' + else if repositoryType == "mercurial" then + '' + if [ ! -d .hg ] + then + ${pkgs.mercurial}/bin/hg init + cat >> .hg/hgrc <<NAMED +[ui] +username = gitit ${gm} +NAMED + '' + else + '' + if [ ! -d .git ] + then + ${pkgs.git}/bin/git init + ${pkgs.git}/bin/git config user.email "${gm}" + ${pkgs.git}/bin/git config user.name "gitit" + ''} + chown ${uid}:${gid} -R ${repositoryPath} + fi + cd - ''; serviceConfig = { diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index b5a8a7df9fca..4aed91c34978 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -78,8 +78,8 @@ in description = '' This option defines the maximum number of jobs that Nix will try to build in parallel. The default is 1. You should generally - set it to the number of CPUs in your system (e.g., 2 on an Athlon - 64 X2). + set it to the total number of logical cores in your system (e.g., 16 + for two CPUs with 4 cores each and hyper-threading). ''; }; @@ -254,7 +254,7 @@ in requireSignedBinaryCaches = mkOption { type = types.bool; - default = false; + default = true; description = '' If enabled, Nix will only download binaries from binary caches if they are cryptographically signed with any of the @@ -309,6 +309,20 @@ in ''; }; + nixPath = mkOption { + type = types.listOf types.str; + default = + [ "/nix/var/nix/profiles/per-user/root/channels/nixos" + "nixos-config=/etc/nixos/configuration.nix" + "/nix/var/nix/profiles/per-user/root/channels" + ]; + description = '' + The default Nix expression search path, used by the Nix + evaluator to look up paths enclosed in angle brackets + (e.g. <literal><nixpkgs></literal>). + ''; + }; + }; }; @@ -378,7 +392,9 @@ in }; # Set up the environment variables for running Nix. - environment.sessionVariables = cfg.envVars; + environment.sessionVariables = cfg.envVars // + { NIX_PATH = concatStringsSep ":" cfg.nixPath; + }; environment.extraInit = '' diff --git a/nixos/modules/services/misc/nix-gc.nix b/nixos/modules/services/misc/nix-gc.nix index 6a7a7f4cee72..981299352575 100644 --- a/nixos/modules/services/misc/nix-gc.nix +++ b/nixos/modules/services/misc/nix-gc.nix @@ -52,7 +52,7 @@ in systemd.services.nix-gc = { description = "Nix Garbage Collector"; - script = "exec ${config.nix.package}/bin/nix-collect-garbage ${cfg.options}"; + script = "exec ${config.nix.package}/bin/nix-store --gc ${cfg.options}"; startAt = optionalString cfg.automatic cfg.dates; }; diff --git a/nixos/modules/services/misc/rogue.nix b/nixos/modules/services/misc/rogue.nix index ed8da8a518ff..aae02e384c97 100644 --- a/nixos/modules/services/misc/rogue.nix +++ b/nixos/modules/services/misc/rogue.nix @@ -52,6 +52,7 @@ in TTYPath = "/dev/${cfg.tty}"; TTYReset = true; TTYVTDisallocate = true; + WorkingDirectory = "/tmp"; Restart = "always"; }; }; |