From 76a4de68c17217e016043dc19b98a96ea5073b0f Mon Sep 17 00:00:00 2001 From: Chris Farmiloe Date: Thu, 12 Jun 2014 16:08:49 +0200 Subject: [PATCH] formatting/retab --- nixos/modules/virtualisation/openvswitch.nix | 195 +++++++++--------- .../os-specific/linux/openvswitch/default.nix | 83 ++++---- 2 files changed, 138 insertions(+), 140 deletions(-) diff --git a/nixos/modules/virtualisation/openvswitch.nix b/nixos/modules/virtualisation/openvswitch.nix index 2070dd0f783..c1579d94657 100644 --- a/nixos/modules/virtualisation/openvswitch.nix +++ b/nixos/modules/virtualisation/openvswitch.nix @@ -5,116 +5,113 @@ with lib; let - cfg = config.virtualisation.vswitch; + cfg = config.virtualisation.vswitch; in { - # ------------------------------------------------------------ - options = { + options = { - virtualisation.vswitch.enable = mkOption { - type = types.bool; - default = false; - description = - '' - Enable Open vSwitch. A configuration - daemon (ovs-server) will be started. - ''; - }; + virtualisation.vswitch.enable = mkOption { + type = types.bool; + default = false; + description = + '' + Enable Open vSwitch. A configuration + daemon (ovs-server) will be started. + ''; + }; - virtualisation.vswitch.package = mkOption { - type = types.package; - default = pkgs.openvswitch; - description = - '' - Open vSwitch package to use. - ''; - }; + virtualisation.vswitch.package = mkOption { + type = types.package; + default = pkgs.openvswitch; + description = + '' + Open vSwitch package to use. + ''; + }; + + }; + + config = mkIf cfg.enable (let + + # Where the communication sockets live + runDir = "/var/run/openvswitch"; + + # Where the config database live (can't be in nix-store) + stateDir = "/var/db/openvswitch"; + + # The path to the an initialized version of the database + db = pkgs.stdenv.mkDerivation { + name = "vswitch.db"; + unpackPhase = "true"; + buildPhase = "true"; + buildInputs = with pkgs; [ + cfg.package + ]; + installPhase = + '' + ensureDir $out/ + ''; + }; + + in { + + environment.systemPackages = [ cfg.package ]; + + boot.kernelModules = [ "tun" "openvswitch" ]; + + boot.extraModulePackages = [ cfg.package ]; + + systemd.services.ovsdb = { + description = "Open_vSwitch Database Server"; + wantedBy = [ "multi-user.target" ]; + after = [ "systemd-udev-settle.service" ]; + wants = [ "vswitchd.service" ]; + path = [ cfg.package ]; + restartTriggers = [ db cfg.package ]; + # Create the config database + preStart = + '' + mkdir -p ${runDir} + mkdir -p /var/db/openvswitch + chmod +w /var/db/openvswitch + if [[ ! -e /var/db/openvswitch/conf.db ]]; then + ${cfg.package}/bin/ovsdb-tool create \ + "/var/db/openvswitch/conf.db" \ + "${cfg.package}/share/openvswitch/vswitch.ovsschema" + fi + chmod -R +w /var/db/openvswitch + ''; + serviceConfig.ExecStart = + '' + ${cfg.package}/bin/ovsdb-server \ + --remote=punix:${runDir}/db.sock \ + --private-key=db:Open_vSwitch,SSL,private_key \ + --certificate=db:Open_vSwitch,SSL,certificate \ + --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \ + --unixctl=ovsdb.ctl.sock \ + /var/db/openvswitch/conf.db + ''; + serviceConfig.Restart = "always"; + serviceConfig.RestartSec = 3; + postStart = + '' + ${cfg.package}/bin/ovs-vsctl --timeout 3 --retry --no-wait init + ''; }; - # ------------------------------------------------------------ + systemd.services.vswitchd = { + description = "Open_vSwitch Daemon"; + bindsTo = [ "ovsdb.service" ]; + after = [ "ovsdb.service" ]; + path = [ cfg.package ]; + serviceConfig.ExecStart = ''${cfg.package}/bin/ovs-vswitchd''; + }; - config = mkIf cfg.enable (let - - # Where the communication sockets live - runDir = "/var/run/openvswitch"; - - # Where the config database live (can't be in nix-store) - stateDir = "/var/db/openvswitch"; - - # The path to the an initialized version of the database - db = pkgs.stdenv.mkDerivation { - name = "vswitch.db"; - unpackPhase = "true"; - buildPhase = "true"; - buildInputs = with pkgs; [ - cfg.package - ]; - installPhase = - '' - ensureDir $out/ - ''; - }; - - in { - - environment.systemPackages = [ cfg.package ]; - - boot.kernelModules = [ "tun" "openvswitch" ]; - - boot.extraModulePackages = [ cfg.package ]; - - systemd.services.ovsdb = { - description = "Open_vSwitch Database Server"; - wantedBy = [ "multi-user.target" ]; - after = [ "systemd-udev-settle.service" ]; - wants = [ "vswitchd.service" ]; - path = [ cfg.package ]; - restartTriggers = [ db cfg.package ]; - # Create the config database - preStart = - '' - mkdir -p ${runDir} - mkdir -p /var/db/openvswitch - chmod +w /var/db/openvswitch - if [[ ! -e /var/db/openvswitch/conf.db ]]; then - ${cfg.package}/bin/ovsdb-tool create \ - "/var/db/openvswitch/conf.db" \ - "${cfg.package}/share/openvswitch/vswitch.ovsschema" - fi - chmod -R +w /var/db/openvswitch - ''; - serviceConfig.ExecStart = - '' - ${cfg.package}/bin/ovsdb-server \ - --remote=punix:${runDir}/db.sock \ - --private-key=db:Open_vSwitch,SSL,private_key \ - --certificate=db:Open_vSwitch,SSL,certificate \ - --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \ - --unixctl=ovsdb.ctl.sock \ - /var/db/openvswitch/conf.db - ''; - serviceConfig.Restart = "always"; - serviceConfig.RestartSec = 3; - postStart = - '' - ${cfg.package}/bin/ovs-vsctl --timeout 3 --retry --no-wait init - ''; - - }; - - systemd.services.vswitchd = { - description = "Open_vSwitch Daemon"; - bindsTo = [ "ovsdb.service" ]; - after = [ "ovsdb.service" ]; - path = [ cfg.package ]; - serviceConfig.ExecStart = ''${cfg.package}/bin/ovs-vswitchd''; - }; - - }); + }); } diff --git a/pkgs/os-specific/linux/openvswitch/default.nix b/pkgs/os-specific/linux/openvswitch/default.nix index 13b41ebe9c8..6b82cc5f9b6 100644 --- a/pkgs/os-specific/linux/openvswitch/default.nix +++ b/pkgs/os-specific/linux/openvswitch/default.nix @@ -1,49 +1,50 @@ { stdenv, fetchurl, openssl, python27, iproute, perl510, kernel ? null}: let - version = "2.1.2"; + version = "2.1.2"; - skipKernelMod = kernel == null; + skipKernelMod = kernel == null; in stdenv.mkDerivation { - version = "2.1.2"; - name = "openvswitch-${version}"; - src = fetchurl { - url = "http://openvswitch.org/releases/openvswitch-2.1.2.tar.gz"; - sha256 = "16q7faqrj2pfchhn0x5s9ggi5ckcg9n62f6bnqaih064aaq2jm47"; - }; - kernel = if skipKernelMod then null else kernel.dev; - buildInputs = [ - openssl - python27 - perl510 - ]; - configureFlags = [ - "--localstatedir=/var" - "--sharedstatedir=/var" - "--sbindir=$(out)/bin" - ] ++ (if skipKernelMod then [] else ["--with-linux"]); - # Leave /var out of this! - installFlags = [ - "LOGDIR=$(TMPDIR)/dummy" - "RUNDIR=$(TMPDIR)/dummy" - "PKIDIR=$(TMPDIR)/dummy" - ]; - meta = { - platforms = stdenv.lib.platforms.linux; - description = "A multilayer virtual switch"; - longDescription = '' - Open vSwitch is a production quality, multilayer virtual switch - licensed under the open source Apache 2.0 license. It is - designed to enable massive network automation through - programmatic extension, while still supporting standard - management interfaces and protocols (e.g. NetFlow, sFlow, SPAN, - RSPAN, CLI, LACP, 802.1ag). In addition, it is designed to - support distribution across multiple physical servers similar - to VMware's vNetwork distributed vswitch or Cisco's Nexus 1000V. - ''; - homepage = "http://openvswitch.org/"; - licence = "Apache 2.0"; - }; + version = "2.1.2"; + name = "openvswitch-${version}"; + src = fetchurl { + url = "http://openvswitch.org/releases/openvswitch-2.1.2.tar.gz"; + sha256 = "16q7faqrj2pfchhn0x5s9ggi5ckcg9n62f6bnqaih064aaq2jm47"; + }; + kernel = if skipKernelMod then null else kernel.dev; + buildInputs = [ + openssl + python27 + perl510 + ]; + configureFlags = [ + "--localstatedir=/var" + "--sharedstatedir=/var" + "--sbindir=$(out)/bin" + ] ++ (if skipKernelMod then [] else ["--with-linux"]); + # Leave /var out of this! + installFlags = [ + "LOGDIR=$(TMPDIR)/dummy" + "RUNDIR=$(TMPDIR)/dummy" + "PKIDIR=$(TMPDIR)/dummy" + ]; + meta = { + platforms = stdenv.lib.platforms.linux; + description = "A multilayer virtual switch"; + longDescription = + '' + Open vSwitch is a production quality, multilayer virtual switch + licensed under the open source Apache 2.0 license. It is + designed to enable massive network automation through + programmatic extension, while still supporting standard + management interfaces and protocols (e.g. NetFlow, sFlow, SPAN, + RSPAN, CLI, LACP, 802.1ag). In addition, it is designed to + support distribution across multiple physical servers similar + to VMware's vNetwork distributed vswitch or Cisco's Nexus 1000V. + ''; + homepage = "http://openvswitch.org/"; + licence = "Apache 2.0"; + }; }