diff options
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/logging/fluentd.nix | 8 | ||||
-rw-r--r-- | nixos/modules/services/monitoring/arbtt.nix | 2 | ||||
-rw-r--r-- | nixos/modules/services/system/dbus.nix | 20 | ||||
-rw-r--r-- | nixos/modules/services/web-apps/frab.nix | 224 | ||||
-rw-r--r-- | nixos/modules/services/x11/desktop-managers/enlightenment.nix | 7 | ||||
-rw-r--r-- | nixos/modules/services/x11/desktop-managers/kde4.nix | 5 | ||||
-rw-r--r-- | nixos/modules/services/x11/desktop-managers/kde5.nix | 5 | ||||
-rw-r--r-- | nixos/modules/services/x11/xserver.nix | 24 |
8 files changed, 252 insertions, 43 deletions
diff --git a/nixos/modules/services/logging/fluentd.nix b/nixos/modules/services/logging/fluentd.nix index 3aa27a15266..e56a9a4e9af 100644 --- a/nixos/modules/services/logging/fluentd.nix +++ b/nixos/modules/services/logging/fluentd.nix @@ -21,6 +21,12 @@ in { default = ""; description = "Fluentd config."; }; + + package = mkOption { + type = types.path; + default = pkgs.fluentd; + description = "The fluentd package to use."; + }; }; }; @@ -32,7 +38,7 @@ in { description = "Fluentd Daemon"; wantedBy = [ "multi-user.target" ]; serviceConfig = { - ExecStart = "${pkgs.fluentd}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config}"; + ExecStart = "${cfg.package}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config}"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; }; }; diff --git a/nixos/modules/services/monitoring/arbtt.nix b/nixos/modules/services/monitoring/arbtt.nix index 27d59e367d5..1135c2c441c 100644 --- a/nixos/modules/services/monitoring/arbtt.nix +++ b/nixos/modules/services/monitoring/arbtt.nix @@ -49,7 +49,7 @@ in { config = mkIf cfg.enable { systemd.user.services.arbtt = { description = "arbtt statistics capture service"; - wantedBy = [ "multi-user.target" ]; + wantedBy = [ "default.target" ]; serviceConfig = { Type = "simple"; diff --git a/nixos/modules/services/system/dbus.nix b/nixos/modules/services/system/dbus.nix index f787c02540d..fae5a55c5ce 100644 --- a/nixos/modules/services/system/dbus.nix +++ b/nixos/modules/services/system/dbus.nix @@ -31,9 +31,6 @@ let cp ${pkgs.dbus.out}/share/dbus-1/{system,session}.conf $out - # avoid circular includes - sed -ri 's@(<include ignore_missing="yes">/etc/dbus-1/(system|session)\.conf</include>)@<!-- \1 -->@g' $out/{system,session}.conf - # include by full path sed -ri "s@/etc/dbus-1/(system|session)-@$out/\1-@" $out/{system,session}.conf @@ -98,11 +95,6 @@ in environment.systemPackages = [ pkgs.dbus.daemon pkgs.dbus ]; - environment.etc = singleton - { source = configDir; - target = "dbus-1"; - }; - users.extraUsers.messagebus = { uid = config.ids.uids.messagebus; description = "D-Bus system message bus daemon user"; @@ -133,8 +125,8 @@ in reloadIfChanged = true; restartTriggers = [ configDir ]; serviceConfig.ExecStart = [ - "" - "${lib.getBin pkgs.dbus}/bin/dbus-daemon --config-file=${configDir}/system.conf ${daemonArgs}" + "" # Default dbus.service has two entries, we need to override both. + "${lib.getBin pkgs.dbus}/bin/dbus-daemon --config-file=/run/current-system/dbus/system.conf ${daemonArgs}" ]; }; @@ -144,13 +136,17 @@ in reloadIfChanged = true; restartTriggers = [ configDir ]; serviceConfig.ExecStart = [ - "" - "${lib.getBin pkgs.dbus}/bin/dbus-daemon --config-file=${configDir}/session.conf ${daemonArgs}" + "" # Default dbus.service has two entries, we need to override both. + "${lib.getBin pkgs.dbus}/bin/dbus-daemon --config-file=/run/current-system/dbus/session.conf ${daemonArgs}" ]; }; sockets.dbus.wantedBy = mkIf cfg.socketActivated [ "sockets.target" ]; }; environment.pathsToLink = [ "/etc/dbus-1" "/share/dbus-1" ]; + + system.extraSystemBuilderCmds = '' + ln -s ${configDir} $out/dbus + ''; }; } diff --git a/nixos/modules/services/web-apps/frab.nix b/nixos/modules/services/web-apps/frab.nix new file mode 100644 index 00000000000..d5329ef03c8 --- /dev/null +++ b/nixos/modules/services/web-apps/frab.nix @@ -0,0 +1,224 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.frab; + + package = pkgs.frab; + ruby = package.ruby; + + databaseConfig = builtins.toJSON { production = cfg.database; }; + + frabEnv = { + RAILS_ENV = "production"; + RACK_ENV = "production"; + SECRET_KEY_BASE = cfg.secretKeyBase; + FRAB_HOST = cfg.host; + FRAB_PROTOCOL = cfg.protocol; + FROM_EMAIL = cfg.fromEmail; + RAILS_SERVE_STATIC_FILES = "1"; + } // cfg.extraEnvironment; + + frab-rake = pkgs.stdenv.mkDerivation rec { + name = "frab-rake"; + buildInputs = [ package.env pkgs.makeWrapper ]; + phases = "installPhase fixupPhase"; + installPhase = '' + mkdir -p $out/bin + makeWrapper ${package.env}/bin/bundle $out/bin/frab-bundle \ + ${concatStrings (mapAttrsToList (name: value: "--set ${name} '${value}' ") frabEnv)} \ + --set PATH '${lib.makeBinPath (with pkgs; [ nodejs file imagemagick ])}:$PATH' \ + --set RAKEOPT '-f ${package}/share/frab/Rakefile' \ + --run 'cd ${package}/share/frab' + makeWrapper $out/bin/frab-bundle $out/bin/frab-rake \ + --add-flags "exec rake" + ''; + }; + +in + +{ + options = { + services.frab = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Enable the frab service. + ''; + }; + + host = mkOption { + type = types.str; + example = "frab.example.com"; + description = '' + Hostname under which this frab instance can be reached. + ''; + }; + + protocol = mkOption { + type = types.str; + default = "https"; + example = "http"; + description = '' + Either http or https, depending on how your Frab instance + will be exposed to the public. + ''; + }; + + fromEmail = mkOption { + type = types.str; + default = "frab@localhost"; + description = '' + Email address used by frab. + ''; + }; + + listenAddress = mkOption { + type = types.str; + default = "localhost"; + description = '' + Address or hostname frab should listen on. + ''; + }; + + listenPort = mkOption { + type = types.int; + default = 3000; + description = '' + Port frab should listen on. + ''; + }; + + statePath = mkOption { + type = types.str; + default = "/var/lib/frab"; + description = '' + Directory where frab keeps its state. + ''; + }; + + user = mkOption { + type = types.str; + default = "frab"; + description = '' + User to run frab. + ''; + }; + + group = mkOption { + type = types.str; + default = "frab"; + description = '' + Group to run frab. + ''; + }; + + secretKeyBase = mkOption { + type = types.str; + description = '' + Your secret key is used for verifying the integrity of signed cookies. + If you change this key, all old signed cookies will become invalid! + + Make sure the secret is at least 30 characters and all random, + no regular words or you'll be exposed to dictionary attacks. + ''; + }; + + database = mkOption { + type = types.attrs; + default = { + adapter = "sqlite3"; + database = "/var/lib/frab/db.sqlite3"; + pool = 5; + timeout = 5000; + }; + example = { + adapter = "postgresql"; + database = "frab"; + host = "localhost"; + username = "frabuser"; + password = "supersecret"; + encoding = "utf8"; + pool = 5; + }; + description = '' + Rails database configuration for Frab as Nix attribute set. + ''; + }; + + extraEnvironment = mkOption { + type = types.attrs; + default = {}; + example = { + FRAB_CURRENCY_UNIT = "€"; + FRAB_CURRENCY_FORMAT = "%n%u"; + EXCEPTION_EMAIL = "frab-owner@example.com"; + SMTP_ADDRESS = "localhost"; + SMTP_PORT = "587"; + SMTP_DOMAIN = "localdomain"; + SMTP_USER_NAME = "root"; + SMTP_PASSWORD = "toor"; + SMTP_AUTHENTICATION = "1"; + SMTP_NOTLS = "1"; + }; + description = '' + Additional environment variables to set for frab for further + configuration. See the frab documentation for more information. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ frab-rake ]; + + users.extraUsers = [ + { name = cfg.user; + group = cfg.group; + home = "${cfg.statePath}"; + } + ]; + + users.extraGroups = [ { name = cfg.group; } ]; + + systemd.services.frab = { + after = [ "network.target" "gitlab.service" ]; + wantedBy = [ "multi-user.target" ]; + environment = frabEnv; + + preStart = '' + mkdir -p ${cfg.statePath}/system/attachments + chown ${cfg.user}:${cfg.group} -R ${cfg.statePath} + + mkdir /run/frab -p + ln -sf ${pkgs.writeText "frab-database.yml" databaseConfig} /run/frab/database.yml + ln -sf ${cfg.statePath}/system /run/frab/system + + if ! test -e "${cfg.statePath}/db-setup-done"; then + ${frab-rake}/bin/frab-rake db:setup + touch ${cfg.statePath}/db-setup-done + else + ${frab-rake}/bin/frab-rake db:migrate + fi + ''; + + serviceConfig = { + PermissionsStartOnly = true; + PrivateTmp = true; + PrivateDevices = true; + Type = "simple"; + User = cfg.user; + Group = cfg.group; + TimeoutSec = "300s"; + Restart = "on-failure"; + RestartSec = "10s"; + WorkingDirectory = "${package}/share/frab"; + ExecStart = "${frab-rake}/bin/frab-bundle exec rails server " + + "--binding=${cfg.listenAddress} --port=${toString cfg.listenPort}"; + }; + }; + + }; +} diff --git a/nixos/modules/services/x11/desktop-managers/enlightenment.nix b/nixos/modules/services/x11/desktop-managers/enlightenment.nix index 77050bcb23f..9b4caafe3b3 100644 --- a/nixos/modules/services/x11/desktop-managers/enlightenment.nix +++ b/nixos/modules/services/x11/desktop-managers/enlightenment.nix @@ -63,11 +63,8 @@ in }]; security.wrappers.e_freqset.source = "${e.enlightenment.out}/bin/e_freqset"; - - environment.etc = singleton - { source = "${pkgs.xkeyboard_config}/etc/X11/xkb"; - target = "X11/xkb"; - }; + + services.xserver.exportConfiguration = true; fonts.fonts = [ pkgs.dejavu_fonts pkgs.ubuntu_font_family ]; diff --git a/nixos/modules/services/x11/desktop-managers/kde4.nix b/nixos/modules/services/x11/desktop-managers/kde4.nix index 25ae75592c9..f810ffdfbb3 100644 --- a/nixos/modules/services/x11/desktop-managers/kde4.nix +++ b/nixos/modules/services/x11/desktop-managers/kde4.nix @@ -177,10 +177,7 @@ in GST_PLUGIN_SYSTEM_PATH = [ "/lib/gstreamer-0.10" ]; }; - environment.etc = singleton - { source = "${pkgs.xkeyboard_config}/etc/X11/xkb"; - target = "X11/xkb"; - }; + services.xserver.exportConfiguration = true; # Enable helpful DBus services. services.udisks2.enable = true; diff --git a/nixos/modules/services/x11/desktop-managers/kde5.nix b/nixos/modules/services/x11/desktop-managers/kde5.nix index 00fdfedbc7b..5874e080fd8 100644 --- a/nixos/modules/services/x11/desktop-managers/kde5.nix +++ b/nixos/modules/services/x11/desktop-managers/kde5.nix @@ -188,10 +188,7 @@ in environment.pathsToLink = [ "/share" ]; - environment.etc = singleton { - source = "${pkgs.xkeyboard_config}/etc/X11/xkb"; - target = "X11/xkb"; - }; + services.xserver.exportConfiguration = true; environment.variables = { diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix index f5ed5233818..8617a5fab03 100644 --- a/nixos/modules/services/x11/xserver.nix +++ b/nixos/modules/services/x11/xserver.nix @@ -465,23 +465,15 @@ in } ]; - environment.etc = - (optionals cfg.exportConfiguration - [ { source = "${configFile}"; - target = "X11/xorg.conf"; - } - # -xkbdir command line option does not seems to be passed to xkbcomp. - { source = "${cfg.xkbDir}"; - target = "X11/xkb"; - } - ]) + environment.etc = mkMerge [ + (mkIf cfg.exportConfiguration { + "X11/xorg.conf".source = configFile; + "X11/xkb".source = cfg.xkbDir; + }) # Needed since 1.18; see https://bugs.freedesktop.org/show_bug.cgi?id=89023#c5 - ++ (let cfgPath = "/X11/xorg.conf.d/10-evdev.conf"; in - [{ - source = xorg.xf86inputevdev.out + "/share" + cfgPath; - target = cfgPath; - }] - ); + (let cfgPath = "X11/xorg.conf.d/10-evdev.conf"; in + { "${cfgPath}".source = xorg.xf86inputevdev.out + "/share" + cfgPath; }) + ]; environment.systemPackages = [ xorg.xorgserver.out |