From 79bfab0e07ddb5863fe5cf2ec9ba66ae1538309e Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Fri, 2 Jan 2009 16:07:10 +0000 Subject: [PATCH] convert "upstart-jobs/atd.nix" to a configuration file. Remove extra occurrences of "atd" from other files. svn path=/nixos/branches/fix-style/; revision=13680 --- etc/default.nix | 1 - system/options.nix | 20 +------ system/system.nix | 2 - upstart-jobs/atd.nix | 110 ++++++++++++++++++++++++++++++++------- upstart-jobs/default.nix | 7 --- 5 files changed, 91 insertions(+), 49 deletions(-) diff --git a/etc/default.nix b/etc/default.nix index 53ab49d62bd7..d05ae3f6c87d 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -224,7 +224,6 @@ let } ) [ - "atd" "login" "slim" "su" diff --git a/system/options.nix b/system/options.nix index a7fc27db90ff..a85564aa62e6 100644 --- a/system/options.nix +++ b/system/options.nix @@ -693,25 +693,6 @@ in }; - atd = { - - enable = mkOption { - default = true; - description = '' - Whether to enable the `at' daemon, a command scheduler. - ''; - }; - - allowEveryone = mkOption { - default = false; - description = '' - Whether to make /var/spool/at{jobs,spool} writeable - by everyone (and sticky). - ''; - }; - }; - - ttyBackgrounds = { enable = mkOption { @@ -2886,6 +2867,7 @@ root ALL=(ALL) SETENV: ALL # services (import ../upstart-jobs/avahi-daemon.nix) + (import ../upstart-jobs/atd.nix) (import ../upstart-jobs/dbus.nix) (import ../upstart-jobs/hal.nix) (import ../upstart-jobs/gpm.nix) diff --git a/system/system.nix b/system/system.nix index 7dda2b950027..4ca281a9fc8a 100644 --- a/system/system.nix +++ b/system/system.nix @@ -159,7 +159,6 @@ rec { pkgs.wirelesstools ] ++ pkgs.lib.optional config.security.sudo.enable pkgs.sudo - ++ pkgs.lib.optional config.services.atd.enable pkgs.at ++ pkgs.lib.optional config.services.bitlbee.enable pkgs.bitlbee ++ pkgs.lib.optional config.networking.defaultMailServer.directDelivery pkgs.ssmtp ++ config.environment.extraPackages @@ -201,7 +200,6 @@ rec { config.security.setuidPrograms ++ config.security.extraSetuidPrograms ++ pkgs.lib.optional config.security.sudo.enable "sudo" ++ - pkgs.lib.optionals config.services.atd.enable ["at" "atq" "atrm"] ++ pkgs.lib.optional (config.services.xserver.sessionType == "kde") "kcheckpass" ++ map ( x : x.program ) config.security.setuidOwners; diff --git a/upstart-jobs/atd.nix b/upstart-jobs/atd.nix index 8a775d0c5d76..b477a38eee4b 100644 --- a/upstart-jobs/atd.nix +++ b/upstart-jobs/atd.nix @@ -1,24 +1,50 @@ -{ at, config }: +{pkgs, config, ...}: -let uid = (import ../system/ids.nix).uids.atd; - gid = (import ../system/ids.nix).gids.atd; +###### interface +let + inherit (pkgs.lib) mkOption; + + options = { + services = { + atd = { + + enable = mkOption { + default = true; + description = '' + Whether to enable the `at' daemon, a command scheduler. + ''; + }; + + allowEveryone = mkOption { + default = false; + description = '' + Whether to make /var/spool/at{jobs,spool} writeable + by everyone (and sticky). + ''; + }; + }; + + }; + }; in -{ - name = "atd"; - - users = [ - { name = "atd"; - inherit uid; - description = "atd user"; - home = "/var/empty"; - } - ]; - groups = [ - { name = "atd"; - inherit gid; - } - ]; +###### implementation +let + cfg = config.services.atd; + inherit (pkgs.lib) mkIf; + inherit (pkgs) at; + + user = { + name = "atd"; + uid = (import ../system/ids.nix).uids.atd; + description = "atd user"; + home = "/var/empty"; + }; + + group = { + name = "atd"; + gid = (import ../system/ids.nix).gids.atd; + }; job = '' description "at daemon (atd)" @@ -44,7 +70,7 @@ start script fi done chmod 1770 "$spooldir" "$jobdir" - ${if config.allowEveryone then ''chmod a+rwxt "$spooldir" "$jobdir" '' else ""} + ${if cfg.allowEveryone then ''chmod a+rwxt "$spooldir" "$jobdir" '' else ""} if [ ! -f "$etcdir"/at.deny ] then touch "$etcdir"/at.deny && \ @@ -61,5 +87,49 @@ end script respawn ${at}/sbin/atd ''; - +in + +mkIf cfg.enable { + require = [ + options + + # config.services.extraJobs + (import ../upstart-jobs/default.nix) + + # config.environment.etc + (import ../etc/default.nix) + + # users.* + (import ../system/users-groups.nix) + + # (import ?) # config.environment.extraPackages + # (import ?) # config.security.extraSetuidPrograms + ]; + + security = { + extraSetuidPrograms = [ + "at" "atq" "atrm" + ]; + }; + + environment = { + extraPackages = [ at ]; + + etc = [{ + source = ../etc/pam.d/atd; + target = "pam.d/atd"; + }]; + }; + + users = { + extraUsers = [user]; + extraGroups = [group]; + }; + + services = { + extraJobs = [{ + name = "atd"; + inherit job; + }]; + }; } diff --git a/upstart-jobs/default.nix b/upstart-jobs/default.nix index 47d2a0ec422a..f2f0c90a6024 100644 --- a/upstart-jobs/default.nix +++ b/upstart-jobs/default.nix @@ -220,13 +220,6 @@ let ]) - # At daemon. - ++ optional config.services.atd.enable - (import ../upstart-jobs/atd.nix { - at = pkgs.at; - config = config.services.atd; - }) - # ifplugd daemon for monitoring Ethernet cables. ++ optional config.networking.interfaceMonitor.enable (import ../upstart-jobs/ifplugd.nix {