From 9359ebf9753fc0c8133a3b358a2734a6c6cf1fac Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Mon, 1 Nov 2010 17:33:54 +0000 Subject: [PATCH 01/20] Implemented an option to enable to DisnixWebService on Apache Tomcat svn path=/nixos/trunk/; revision=24560 --- modules/services/misc/disnix.nix | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/modules/services/misc/disnix.nix b/modules/services/misc/disnix.nix index 09b9cf8fe08a..3688f8c3fc71 100644 --- a/modules/services/misc/disnix.nix +++ b/modules/services/misc/disnix.nix @@ -6,7 +6,14 @@ with pkgs.lib; let cfg = config.services.disnix; - + + disnix_activation_scripts = pkgs.disnix_activation_scripts.override (origArgs: { + enableApacheWebApplication = config.services.httpd.enable; + enableAxis2WebService = config.services.tomcat.axis2.enable; + enableEjabberdDump = config.services.ejabberd.enable; + enableMySQLDatabase = config.services.mysql.enable; + enableTomcatWebApplication = config.services.tomcat.enable; + }); in { @@ -20,7 +27,12 @@ in enable = mkOption { default = false; description = "Whether to enable Disnix"; - }; + }; + + useWebServiceInterface = mkOption { + default = false; + description = "Whether to enable the DisnixWebService interface running on Apache Tomcat"; + }; }; @@ -36,6 +48,13 @@ in services.dbus.enable = true; services.dbus.packages = [ pkgs.disnix ]; + services.tomcat.enable = cfg.useWebServiceInterface; + services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} "; + services.tomcat.sharedLibs = [] + ++ optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar" + ++ optional cfg.useWebServiceInterface "${pkgs.dbus_java}/share/java/dbus.jar"; + services.tomcat.webapps = [] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService; + users.extraGroups = singleton { name = "disnix"; gid = config.ids.gids.disnix; @@ -47,11 +66,8 @@ in startOn = "started dbus"; script = - '' - export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin - export HOME=/root - - ${pkgs.disnix}/bin/disnix-service --activation-modules-dir=${pkgs.disnix_activation_scripts}/libexec/disnix/activation-scripts + '' + ${pkgs.disnix}/bin/disnix-service --activation-modules-dir=${disnix_activation_scripts}/libexec/disnix/activation-scripts ''; }; From e39b10a4d92cb4c0c0957ba071879135d44b4eb0 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Mon, 1 Nov 2010 19:01:26 +0000 Subject: [PATCH 02/20] - The Disnix service needs Nix in its PATH for now - Implemented an extraGroups property for tomcat to grant a tomcat application access to the Disnix service svn path=/nixos/trunk/; revision=24561 --- modules/services/misc/disnix.nix | 4 ++++ modules/services/web-servers/tomcat.nix | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/modules/services/misc/disnix.nix b/modules/services/misc/disnix.nix index 3688f8c3fc71..abf664c90314 100644 --- a/modules/services/misc/disnix.nix +++ b/modules/services/misc/disnix.nix @@ -49,6 +49,7 @@ in services.dbus.packages = [ pkgs.disnix ]; services.tomcat.enable = cfg.useWebServiceInterface; + services.tomcat.extraGroups = [ "disnix" ]; services.tomcat.javaOpts = "${optionalString cfg.useWebServiceInterface "-Djava.library.path=${pkgs.libmatthew_java}/lib/jni"} "; services.tomcat.sharedLibs = [] ++ optional cfg.useWebServiceInterface "${pkgs.DisnixWebService}/share/java/DisnixConnection.jar" @@ -67,6 +68,9 @@ in script = '' + export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin + export HOME=/root + ${pkgs.disnix}/bin/disnix-service --activation-modules-dir=${disnix_activation_scripts}/libexec/disnix/activation-scripts ''; }; diff --git a/modules/services/web-servers/tomcat.nix b/modules/services/web-servers/tomcat.nix index e63abfb15d27..83b95655011b 100644 --- a/modules/services/web-servers/tomcat.nix +++ b/modules/services/web-servers/tomcat.nix @@ -26,6 +26,12 @@ in description = "Location where Tomcat stores configuration files, webapplications and logfiles"; }; + extraGroups = mkOption { + default = []; + example = [ "users" ]; + description = "Defines extra groups to which the tomcat user belongs."; + }; + user = mkOption { default = "tomcat"; description = "User account under which Apache Tomcat runs."; @@ -104,6 +110,7 @@ in uid = config.ids.uids.tomcat; description = "Tomcat user"; home = "/homeless-shelter"; + extraGroups = cfg.extraGroups; }; jobs.tomcat = From 4858ab9da83f94459632fc635277822a181903a6 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Tue, 2 Nov 2010 04:20:37 +0000 Subject: [PATCH 03/20] The DisnixWebService is now also part of the systemPackages so that a user can invoke the client tool from the command-line svn path=/nixos/trunk/; revision=24564 --- modules/services/misc/disnix.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/misc/disnix.nix b/modules/services/misc/disnix.nix index abf664c90314..63b8394c280c 100644 --- a/modules/services/misc/disnix.nix +++ b/modules/services/misc/disnix.nix @@ -43,7 +43,7 @@ in config = mkIf cfg.enable { - environment.systemPackages = [ pkgs.disnix ]; + environment.systemPackages = [ pkgs.disnix ] ++ optional cfg.useWebServiceInterface pkgs.DisnixWebService; services.dbus.enable = true; services.dbus.packages = [ pkgs.disnix ]; From cf84a442725add49f837b7a6a35eac0e63b2d459 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 3 Nov 2010 22:37:39 +0000 Subject: [PATCH 04/20] * Use buildEnv with a postBuild hook rather than buildEnvScript. svn path=/nixos/trunk/; revision=24593 --- modules/services/databases/postgresql.nix | 24 +++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/modules/services/databases/postgresql.nix b/modules/services/databases/postgresql.nix index 6d58b757421c..56e98e4a3f99 100644 --- a/modules/services/databases/postgresql.nix +++ b/modules/services/databases/postgresql.nix @@ -9,22 +9,16 @@ let # see description of extraPlugins postgresqlAndPlugins = pg: if cfg.extraPlugins == [] then pg - else pkgs.runCommand "postgresql-and-plugins" { - inherit (pkgs) perl; - inherit pg; - # used by env builder: + else pkgs.buildEnv { + name = "postgresql-and-plugins"; paths = [ pg ] ++ cfg.extraPlugins; - pathsToLink = "/"; - ignoreCollisions = 0; - manifest = null; - } - '' - perlScript=${pkgs.buildEnvScript} - mkdir -p $out/bin - $perl/bin/perl $perlScript - rm $out/bin/{pg_config,postgres,pg_ctl} - cp --target-directory=$out/bin $pg/bin/{postgres,pg_config,pg_ctl} - ''; + postBuild = + '' + mkdir -p $out/bin + rm $out/bin/{pg_config,postgres,pg_ctl} + cp --target-directory=$out/bin ${pg}/bin/{postgres,pg_config,pg_ctl} + ''; + }; postgresql = postgresqlAndPlugins pkgs.postgresql; From f34d7250b3e42d0e8b1379a3382f54c0295e29ab Mon Sep 17 00:00:00 2001 From: Rob Vermaas Date: Thu, 4 Nov 2010 08:13:57 +0000 Subject: [PATCH 05/20] mysql-backup.nix: add option to use single transaction for dumps svn path=/nixos/trunk/; revision=24594 --- modules/services/backup/mysql-backup.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/services/backup/mysql-backup.nix b/modules/services/backup/mysql-backup.nix index b6d42b8782a1..7c091fcfe263 100644 --- a/modules/services/backup/mysql-backup.nix +++ b/modules/services/backup/mysql-backup.nix @@ -6,10 +6,10 @@ let inherit (pkgs) mysql gzip; - location = config.services.mysqlBackup.location ; - + cfg = config.services.mysqlBackup ; + location = cfg.location ; mysqlBackupCron = db : '' - ${config.services.mysqlBackup.period} ${config.services.mysqlBackup.user} ${mysql}/bin/mysqldump ${db} | ${gzip}/bin/gzip -c > ${location}/${db}.gz + ${cfg.period} ${cfg.user} ${mysql}/bin/mysqldump ${if cfg.singleTransaction then "--single-transaction" else ""} ${db} | ${gzip}/bin/gzip -c > ${location}/${db}.gz ''; in @@ -55,6 +55,13 @@ in Location to put the gzipped MySQL database dumps. ''; }; + + singleTransaction = mkOption { + default = false; + description = '' + Whether to create database dump in a single transaction + ''; + }; }; }; From f319ca67c5a0282f4b3f3b7f626f46867b9a1554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 6 Nov 2010 18:13:48 +0000 Subject: [PATCH 06/20] Trying to improve the message hit by new users, if they use the 2.6.36 kernelPackages and don't disable the ttyBackgrounds. Some users got confused by the previous message. svn path=/nixos/trunk/; revision=24612 --- modules/tasks/tty-backgrounds.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/tasks/tty-backgrounds.nix b/modules/tasks/tty-backgrounds.nix index 8d079edc9342..d376c6a4b894 100644 --- a/modules/tasks/tty-backgrounds.nix +++ b/modules/tasks/tty-backgrounds.nix @@ -86,7 +86,8 @@ in assertions = singleton { assertion = kernelPackages.splashutils != null; - message = "kernelPackages.splashutils may not be false"; + message = "The kernelPackages does not provide splashutils, as required by ttyBackgrounds. " + + "Either provide kernelPackages with splashutils, or disable ttyBackgrounds."; }; services.ttyBackgrounds.specificThemes = singleton From 30943d2dc03671299d10ee618fe7b68067e127a1 Mon Sep 17 00:00:00 2001 From: Nicolas Pierron Date: Tue, 9 Nov 2010 18:42:59 +0000 Subject: [PATCH 07/20] Fix nixos-option, accept long arguments. svn path=/nixos/trunk/; revision=24631 --- modules/installer/tools/nixos-option.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/installer/tools/nixos-option.sh b/modules/installer/tools/nixos-option.sh index fc4380d00c47..456e2b275d0f 100644 --- a/modules/installer/tools/nixos-option.sh +++ b/modules/installer/tools/nixos-option.sh @@ -66,13 +66,14 @@ for arg; do sarg="$arg" while test "$sarg" != "-"; do case $sarg in - --*) longarg=$arg;; + --*) longarg=$arg; sarg="--";; -d*) longarg="$longarg --description";; -v*) longarg="$longarg --value";; -l*) longarg="$longarg --lookup";; -i*) longarg="$longarg --install";; -*) usage;; esac + # remove the first letter option sarg="-${sarg#??}" done ;; From c77c3ab22c578e4a7d3f1a94cb76588fa5a7e745 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Thu, 11 Nov 2010 13:24:37 +0000 Subject: [PATCH 08/20] Remove ttmkfdir reference svn path=/nixos/trunk/; revision=24662 --- modules/config/fonts.nix | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/config/fonts.nix b/modules/config/fonts.nix index 8b7ba6fab948..bb75a1e29abd 100644 --- a/modules/config/fonts.nix +++ b/modules/config/fonts.nix @@ -98,7 +98,7 @@ in ###### implementation let - inherit (pkgs) builderDefs ttmkfdir; + inherit (pkgs) builderDefs; inherit (pkgs.xorg) mkfontdir mkfontscale fontalias; fontDirs = config.fonts.fonts; @@ -107,7 +107,7 @@ let localDefs = with builderDefs; builderDefs.passthru.function rec { src = "";/* put a fetchurl here */ - buildInputs = [mkfontdir mkfontscale ttmkfdir]; + buildInputs = [mkfontdir mkfontscale]; configureFlags = []; inherit fontDirs; installPhase = fullDepEntry (" @@ -135,13 +135,6 @@ let rm fonts.alias mkfontdir mkfontscale - mv fonts.scale fonts.scale.old - mv fonts.dir fonts.dir.old - ttmkfdir - cat fonts.scale.old >> fonts.scale - cat fonts.dir.old >> fonts.dir - rm fonts.dir.old - rm fonts.scale.old cat \$( find ${fontalias}/ -name fonts.alias) >fonts.alias ") ["minInit" "addInputs"]; }; From ad48c7c534bddc6e8536500f6d49826c137d82be Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Sun, 21 Nov 2010 13:28:48 +0000 Subject: [PATCH 09/20] Initial implementation for the Disnix avahi publisher svn path=/nixos/trunk/; revision=24789 --- modules/services/misc/disnix.nix | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/services/misc/disnix.nix b/modules/services/misc/disnix.nix index 63b8394c280c..5714e8ddc796 100644 --- a/modules/services/misc/disnix.nix +++ b/modules/services/misc/disnix.nix @@ -33,6 +33,11 @@ in default = false; description = "Whether to enable the DisnixWebService interface running on Apache Tomcat"; }; + + publishAvahi = mkOption { + default = false; + description = "Whether to publish capabilities/properties as a Disnix service through Avahi"; + }; }; @@ -75,6 +80,26 @@ in ''; }; + } // + mkIf cfg.publishAvahi { + + services.avahi.enable = true; + + jobs.disnixAvahi = + { description = "Disnix Avahi publisher"; + + startOn = "started avahi-daemon"; + + exec = + '' + ${pkgs.avahi}/bin/avahi-publish-service disnix-$(${pkgs.nettools}/bin/hostname) _disnix._tcp 22 \ + "hostname=\"$(${pkgs.nettools}/bin/hostname)\"" \ + "mem=$(grep 'MemTotal:' /proc/meminfo | sed -e 's/kB//' -e 's/MemTotal://' -e 's/ //g')" \ + ${optionalString (config.services.httpd.enable) ''"documentRoot=\"${config.services.httpd.documentRoot}\""''} \ + ${optionalString (config.services.mysql.enable) ''"mysqlPort=3306"''} \ + ${optionalString (config.services.tomcat.enable) ''"tomcatPort=8080"''} \ + "supportedTypes=[$(for i in ${disnix_activation_scripts}/libexec/disnix/activation-scripts/*; do echo -n " \"$(basename $i)\""; done) ]" + ''; + }; }; - } From fcf53be5bd1ce31bd0862bdeb5144e388a07a4b7 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Sun, 21 Nov 2010 16:04:26 +0000 Subject: [PATCH 10/20] The DisnixWebService is also published through Avahi svn path=/nixos/trunk/; revision=24792 --- modules/services/misc/disnix.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/services/misc/disnix.nix b/modules/services/misc/disnix.nix index 5714e8ddc796..7eeed998d2df 100644 --- a/modules/services/misc/disnix.nix +++ b/modules/services/misc/disnix.nix @@ -95,6 +95,7 @@ in ${pkgs.avahi}/bin/avahi-publish-service disnix-$(${pkgs.nettools}/bin/hostname) _disnix._tcp 22 \ "hostname=\"$(${pkgs.nettools}/bin/hostname)\"" \ "mem=$(grep 'MemTotal:' /proc/meminfo | sed -e 's/kB//' -e 's/MemTotal://' -e 's/ //g')" \ + ${optionalString (cfg.useWebServiceInterface) ''"targetEPR=\"http://(${pkgs.nettools}/bin/hostname):8080/DisnixWebService/services/DisnixWebService\""''} \ ${optionalString (config.services.httpd.enable) ''"documentRoot=\"${config.services.httpd.documentRoot}\""''} \ ${optionalString (config.services.mysql.enable) ''"mysqlPort=3306"''} \ ${optionalString (config.services.tomcat.enable) ''"tomcatPort=8080"''} \ From c958902d4473e6abec41e383d43c28f7ec674a09 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 23 Nov 2010 16:07:00 +0000 Subject: [PATCH 11/20] * Added an option "nixpkgs.system" to specify the system type for which NixOS should be built. This is useful in NixOS network specifications, because it allows machines in the network to have different types, e.g., { machine1 = { config, pkgs, ... }: { nixpkgs.system = "i686-linux"; ... other config ... }; machine2 = { config, pkgs, ... }: { nixpkgs.system = "x86_64-linux"; ... other config ... }; } It can also be useful in distributed NixOS tests. svn path=/nixos/trunk/; revision=24823 --- lib/eval-config.nix | 8 +++++--- modules/misc/nixpkgs.nix | 11 +++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/eval-config.nix b/lib/eval-config.nix index 8a7b225e8500..d34a73fd1661 100644 --- a/lib/eval-config.nix +++ b/lib/eval-config.nix @@ -11,7 +11,7 @@ , modules }: -let extraArgs_ = extraArgs; pkgs_ = pkgs; in +let extraArgs_ = extraArgs; pkgs_ = pkgs; system_ = system; in rec { @@ -39,7 +39,8 @@ rec { # Import Nixpkgs, allowing the NixOS option nixpkgs.config to # specify the Nixpkgs configuration (e.g., to set package options # such as firefox.enableGeckoMediaPlayer, or to apply global - # overrides such as changing GCC throughout the system). This is + # overrides such as changing GCC throughout the system), and the + # option nixpkgs.system to override the platform type. This is # tricky, because we have to prevent an infinite recursion: "pkgs" # is passed as an argument to NixOS modules, but the value of "pkgs" # depends on config.nixpkgs.config, which we get from the modules. @@ -50,12 +51,13 @@ rec { then pkgs_ else import nixpkgs ( let + system = if nixpkgsOptions.system != "" then nixpkgsOptions.system else system_; nixpkgsOptions = (import ./eval-config.nix { inherit system nixpkgs services extraArgs modules; # For efficiency, leave out most NixOS modules; they don't # define nixpkgs.config, so it's pointless to evaluate them. baseModules = [ ../modules/misc/nixpkgs.nix ]; - pkgs = import nixpkgs { inherit system; config = {}; }; + pkgs = import nixpkgs { system = system_; config = {}; }; }).optionDefinitions.nixpkgs; in { diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix index 8173d716d841..d940b32dbd56 100644 --- a/modules/misc/nixpkgs.nix +++ b/modules/misc/nixpkgs.nix @@ -13,6 +13,17 @@ ''; }; + nixpkgs.system = pkgs.lib.mkOption { + default = ""; + description = '' + Specifies the Nix platform type for which NixOS should be built. + If unset, it defaults to the platform type of your host system + (${builtins.currentSystem}). + Specifying this option is useful when doing distributed + multi-platform deployment, or when building virtual machines. + ''; + }; + nixpkgs.platform = pkgs.lib.mkOption { default = pkgs.platforms.pc; description = '' From 1b41b6d16d7a8b8402c1679a1fd18a4aa2d999b1 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Wed, 24 Nov 2010 06:13:37 +0000 Subject: [PATCH 12/20] Fix Monit startOn parameter svn path=/nixos/trunk/; revision=24832 --- modules/services/monitoring/monit.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/services/monitoring/monit.nix b/modules/services/monitoring/monit.nix index 35f483411b23..40ad8456d7c4 100644 --- a/modules/services/monitoring/monit.nix +++ b/modules/services/monitoring/monit.nix @@ -20,7 +20,7 @@ in description = "monit.conf content"; }; startOn = mkOption { - default = "network-interfaces/started"; + default = "started network-interfaces"; description = "What Monit supposes to be already present"; }; }; From f58efe3336dec26eafc417ce91fbd779ec52ff6c Mon Sep 17 00:00:00 2001 From: "Yury G. Kudryashov" Date: Wed, 24 Nov 2010 10:45:34 +0000 Subject: [PATCH 13/20] Add kdm user. Kdm doesn't work here without kdm user svn path=/nixos/trunk/; revision=24835 --- modules/misc/ids.nix | 1 + modules/services/x11/display-managers/kdm.nix | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/modules/misc/ids.nix b/modules/misc/ids.nix index 2db841194e30..f8219c23068b 100644 --- a/modules/misc/ids.nix +++ b/modules/misc/ids.nix @@ -57,6 +57,7 @@ in cups = 36; foldingAtHome = 37; sabnzbd = 38; + kdm = 39; # When adding a uid, make sure it doesn't match an existing gid. nixbld = 30000; # start of range of uids diff --git a/modules/services/x11/display-managers/kdm.nix b/modules/services/x11/display-managers/kdm.nix index 1fa5b4f210ff..2c5a720f815e 100644 --- a/modules/services/x11/display-managers/kdm.nix +++ b/modules/services/x11/display-managers/kdm.nix @@ -106,6 +106,13 @@ in security.pam.services = [ { name = "kde"; } ]; + users.extraUsers = singleton + { name = "kdm"; + uid = config.ids.uids.kdm; + description = "kdm user"; + home = "/tmp/kdm"; + }; + }; } From 50d8698fd8fc89301db1cce56d73132da76772d7 Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Wed, 24 Nov 2010 22:58:42 +0000 Subject: [PATCH 14/20] network-interfaces: cleanup svn path=/nixos/trunk/; revision=24845 --- modules/tasks/network-interfaces.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 562a945d832a..d24f7c923cee 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -8,6 +8,8 @@ let cfg = config.networking; + ifconfig = "${nettools}/sbin/ifconfig"; + in { @@ -157,7 +159,7 @@ in for i in $(cd /sys/class/net && ls -d *); do echo "Bringing up network device $i..." - ${nettools}/sbin/ifconfig $i up || true + ${ifconfig} $i up || true done # Configure the manually specified interfaces. @@ -169,7 +171,7 @@ in if test -n "${i.subnetMask}"; then extraFlags="$extraFlags netmask ${i.subnetMask}" fi - ${nettools}/sbin/ifconfig "${i.name}" "${i.ipAddress}" $extraFlags || true + ${ifconfig} "${i.name}" "${i.ipAddress}" $extraFlags || true '' else "") cfg.interfaces} @@ -202,7 +204,7 @@ in '' #for i in $(cd /sys/class/net && ls -d *); do # echo "Taking down network device $i..." - # ${nettools}/sbin/ifconfig $i down || true + # ${ifconfig} $i down || true #done ''; }; From 72422d41262b4f48f5bf20fd58f1714292750a13 Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Wed, 24 Nov 2010 22:58:48 +0000 Subject: [PATCH 15/20] network-interfaces: support changing MAC addresses of interfaces svn path=/nixos/trunk/; revision=24846 --- modules/tasks/network-interfaces.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index d24f7c923cee..0c1180af6453 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -115,6 +115,15 @@ in ''; }; + macAddress = mkOption { + default = ""; + example = "00:11:22:33:44:55"; + type = types.string; + description = '' + MAC address of the interface. Leave empty to use the default. + ''; + }; + }; }; @@ -157,6 +166,16 @@ in export PATH=${config.system.sbin.modprobe}/sbin:$PATH modprobe af_packet || true + ${pkgs.lib.concatMapStrings (i: + if i.macAddress != "" then + '' + echo "Configuring interface ${i.name}..." + ${ifconfig} "${i.name}" down || true + ${ifconfig} hw ether "${i.name}" "${i.macAddress}" || true + '' + else "") cfg.interfaces + } + for i in $(cd /sys/class/net && ls -d *); do echo "Bringing up network device $i..." ${ifconfig} $i up || true From 2224d78b33b07686dcea8a192944b3f622109541 Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Wed, 24 Nov 2010 22:58:53 +0000 Subject: [PATCH 16/20] network-interfaces: MAC address support take 2: now it seems to work svn path=/nixos/trunk/; revision=24847 --- modules/services/networking/dhclient.nix | 2 +- modules/tasks/network-interfaces.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/services/networking/dhclient.nix b/modules/services/networking/dhclient.nix index bd3f781c19a5..454bd361b12d 100644 --- a/modules/services/networking/dhclient.nix +++ b/modules/services/networking/dhclient.nix @@ -8,7 +8,7 @@ let # Don't start dhclient on explicitly configured interfaces. ignoredInterfaces = - map (i: i.name) (lib.filter (i: i ? ipAddress) config.networking.interfaces); + map (i: i.name) (lib.filter (i: i ? ipAddress && i.ipAddress != "" ) config.networking.interfaces); stateDir = "/var/lib/dhcp"; # Don't use /var/state/dhcp; not FHS-compliant. diff --git a/modules/tasks/network-interfaces.nix b/modules/tasks/network-interfaces.nix index 0c1180af6453..640ef0821fca 100644 --- a/modules/tasks/network-interfaces.nix +++ b/modules/tasks/network-interfaces.nix @@ -171,7 +171,7 @@ in '' echo "Configuring interface ${i.name}..." ${ifconfig} "${i.name}" down || true - ${ifconfig} hw ether "${i.name}" "${i.macAddress}" || true + ${ifconfig} "${i.name}" hw ether "${i.macAddress}" || true '' else "") cfg.interfaces } From 31b8ac8120c8acc5223468bce6fee0c5ed5f6be8 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Wed, 24 Nov 2010 23:00:21 +0000 Subject: [PATCH 17/20] Implemented 'deployment' option to capture custom attributes related to the system configuration svn path=/nixos/trunk/; revision=24848 --- modules/misc/deployment.nix | 23 +++++++++++++++++++++++ modules/module-list.nix | 1 + 2 files changed, 24 insertions(+) create mode 100644 modules/misc/deployment.nix diff --git a/modules/misc/deployment.nix b/modules/misc/deployment.nix new file mode 100644 index 000000000000..08559cc2a160 --- /dev/null +++ b/modules/misc/deployment.nix @@ -0,0 +1,23 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +{ + options = { + + deployment = mkOption { + description = '' + This option captures various custom attributes related to the configuration of the system, which + are not directly used for building a system configuration. Usually these attributes + are used by external tooling, such as the nixos-deploy-network tool or the Disnix Avahi + publisher. + ''; + default = {}; + example = { + description = "My production machine"; + hostname = "my.test.org"; + country = "NL"; + }; + }; + }; +} diff --git a/modules/module-list.nix b/modules/module-list.nix index 1364b28182d1..8c927aa61429 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -24,6 +24,7 @@ ./installer/tools/tools.nix ./misc/assertions.nix ./misc/check-config.nix + ./misc/deployment.nix ./misc/ids.nix ./misc/locate.nix ./misc/nixpkgs.nix From b064f5c80ecc012b252d9856784485d4a82714e1 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Wed, 24 Nov 2010 23:00:52 +0000 Subject: [PATCH 18/20] The Disnix avahi server now also publishes the 'system' attribute and the properties defined in config.deployment svn path=/nixos/trunk/; revision=24849 --- modules/services/misc/disnix.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/services/misc/disnix.nix b/modules/services/misc/disnix.nix index 7eeed998d2df..dee19b0577a8 100644 --- a/modules/services/misc/disnix.nix +++ b/modules/services/misc/disnix.nix @@ -94,12 +94,14 @@ in '' ${pkgs.avahi}/bin/avahi-publish-service disnix-$(${pkgs.nettools}/bin/hostname) _disnix._tcp 22 \ "hostname=\"$(${pkgs.nettools}/bin/hostname)\"" \ + "system=\"$(uname -m)-linux\"" \ "mem=$(grep 'MemTotal:' /proc/meminfo | sed -e 's/kB//' -e 's/MemTotal://' -e 's/ //g')" \ ${optionalString (cfg.useWebServiceInterface) ''"targetEPR=\"http://(${pkgs.nettools}/bin/hostname):8080/DisnixWebService/services/DisnixWebService\""''} \ ${optionalString (config.services.httpd.enable) ''"documentRoot=\"${config.services.httpd.documentRoot}\""''} \ ${optionalString (config.services.mysql.enable) ''"mysqlPort=3306"''} \ ${optionalString (config.services.tomcat.enable) ''"tomcatPort=8080"''} \ - "supportedTypes=[$(for i in ${disnix_activation_scripts}/libexec/disnix/activation-scripts/*; do echo -n " \"$(basename $i)\""; done) ]" + "supportedTypes=[$(for i in ${disnix_activation_scripts}/libexec/disnix/activation-scripts/*; do echo -n " \"$(basename $i)\""; done) ]" \ + ${concatMapStrings (deploymentAttrName: let deploymentAttrValue = getAttr deploymentAttrName (config.deployment); in ''${deploymentAttrName}=\"${deploymentAttrValue}\" '' ) (attrNames (config.deployment))} ''; }; }; From 636307c62b9e57a108d2759f6a284dfc0ec91996 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 25 Nov 2010 16:51:07 +0000 Subject: [PATCH 19/20] * Create /var/lib/nfs/v4recovery. svn path=/nixos/trunk/; revision=24858 --- modules/services/network-filesystems/nfs-kernel.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/services/network-filesystems/nfs-kernel.nix b/modules/services/network-filesystems/nfs-kernel.nix index 603e63f6005e..290622b09977 100644 --- a/modules/services/network-filesystems/nfs-kernel.nix +++ b/modules/services/network-filesystems/nfs-kernel.nix @@ -133,7 +133,15 @@ in startOn = "started nfs-kernel-exports and started nfs-kernel-mountd and started nfs-kernel-statd and started portmap"; stopOn = "stopping nfs-kernel-exports"; - preStart = "${pkgs.nfsUtils}/sbin/rpc.nfsd ${if cfg.server.hostName != null then "-H ${cfg.server.hostName}" else ""} ${builtins.toString cfg.server.nproc}"; + preStart = + '' + # Create a state directory required by NFSv4. + mkdir -p /var/lib/nfs/v4recovery + + ${pkgs.nfsUtils}/sbin/rpc.nfsd \ + ${if cfg.server.hostName != null then "-H ${cfg.server.hostName}" else ""} \ + ${builtins.toString cfg.server.nproc} + ''; postStop = "${pkgs.nfsUtils}/sbin/rpc.nfsd 0"; }; From bef46f15531ede38beb0136833688c22164f3f4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 26 Nov 2010 09:57:38 +0000 Subject: [PATCH 20/20] Moving which to type -P, so 'which ls', 'which time', ... work. svn path=/nixos/trunk/; revision=24862 --- modules/programs/bash/bashrc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/programs/bash/bashrc.sh b/modules/programs/bash/bashrc.sh index 50768635d36b..c301ffde73a4 100644 --- a/modules/programs/bash/bashrc.sh +++ b/modules/programs/bash/bashrc.sh @@ -68,7 +68,7 @@ fi alias ls="ls --color=tty" alias ll="ls -l" alias l="ls -alh" -alias which="type -p" +alias which="type -P" # The "non-interactive" Bash build does not support programmable # completion so check whether it's available.