This commit is contained in:
Zef Hemel 2013-09-03 20:46:27 +02:00
commit 3812b20546
6 changed files with 175 additions and 96 deletions

View file

@ -151,7 +151,8 @@ var docs = {
"docs/julia.js": "Julia", "docs/julia.js": "Julia",
"docs/prolog.plg": "Prolog", "docs/prolog.plg": "Prolog",
"docs/rust.rs": "Rust", "docs/rust.rs": "Rust",
"docs/twig.twig": "Twig" "docs/twig.twig": "Twig",
"docs/Nix.nix": "Nix"
}; };
var ownSource = { var ownSource = {

View file

@ -0,0 +1,57 @@
{
# Name of our deployment
network.description = "HelloWorld";
# Enable rolling back to previous versions of our infrastructure
network.enableRollback = true;
# It consists of a single server named 'helloserver'
helloserver =
# Every server gets passed a few arguments, including a reference
# to nixpkgs (pkgs)
{ config, pkgs, ... }:
let
# We import our custom packages from ./default passing pkgs as argument
packages = import ./default.nix { pkgs = pkgs; };
# This is the nodejs version specified in default.nix
nodejs = packages.nodejs;
# And this is the application we'd like to deploy
app = packages.app;
in
{
# We'll be running our application on port 8080, because a regular
# user cannot bind to port 80
# Then, using some iptables magic we'll forward traffic designated to port 80 to 8080
networking.firewall.enable = true;
# We will open up port 22 (SSH) as well otherwise we're locking ourselves out
networking.firewall.allowedTCPPorts = [ 80 8080 22 ];
networking.firewall.allowPing = true;
# Port forwarding using iptables
networking.firewall.extraCommands = ''
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
'';
# To run our node.js program we're going to use a systemd service
# We can configure the service to automatically start on boot and to restart
# the process in case it crashes
systemd.services.helloserver = {
description = "Hello world application";
# Start the service after the network is available
after = [ "network.target" ];
# We're going to run it on port 8080 in production
environment = { PORT = "8080"; };
serviceConfig = {
# The actual command to run
ExecStart = "${nodejs}/bin/node ${app}/server.js";
# For security reasons we'll run this process as a special 'nodejs' user
User = "nodejs";
Restart = "always";
};
};
# And lastly we ensure the user we run our application as is created
users.extraUsers = {
nodejs = { };
};
};
}

View file

@ -29,7 +29,7 @@
* *
* Contributor(s): * Contributor(s):
* *
* * Zef Hemel
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */

View file

@ -1,10 +1,10 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var NixHighlightRules = function() { var NixHighlightRules = function() {
var constantLanguage = "true|false"; var constantLanguage = "true|false";
var keywordControl = "with|import|if|else|then"; var keywordControl = "with|import|if|else|then";
@ -24,6 +24,9 @@ var NixHighlightRules = function() {
token: "comment", token: "comment",
regex: /\/\*/, regex: /\/\*/,
next: "comment" next: "comment"
}, {
token: "constant",
regex: "<[^>]+>"
}, { }, {
regex: "(==|!=|<=?|>=?)", regex: "(==|!=|<=?|>=?)",
token: ["keyword.operator.comparison.nix"] token: ["keyword.operator.comparison.nix"]
@ -44,7 +47,7 @@ var NixHighlightRules = function() {
}, { }, {
token: "string", token: "string",
regex: '"', regex: '"',
next: "qqstring" push: "qqstring"
}, { }, {
token: "constant.numeric", // hex token: "constant.numeric", // hex
regex: "0[xX][0-9a-fA-F]+\\b" regex: "0[xX][0-9a-fA-F]+\\b"
@ -54,6 +57,12 @@ var NixHighlightRules = function() {
}, { }, {
token: keywordMapper, token: keywordMapper,
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
regex: "}",
token: function(val, start, stack) {
return stack[1] == "qqstring" ? "constant.language.escape" : "text"
},
next: "pop"
}], }],
"comment": [{ "comment": [{
token: "comment", // closing comment token: "comment", // closing comment
@ -63,43 +72,48 @@ var NixHighlightRules = function() {
token: "comment", // comment spanning whole line token: "comment", // comment spanning whole line
regex: ".+" regex: ".+"
}], }],
"qqdoc": [{ "qqdoc": [
{
token: "constant.language.escape", token: "constant.language.escape",
regex: /\$\{[^}]+\}/ regex: /\$\{/,
push: "start"
}, { }, {
token: "string", token: "string",
regex: "''", regex: "''",
next: "start" next: "pop"
}, { }, {
defaultToken: "string" defaultToken: "string"
}], }],
"qqstring": [
"qqstring": [{ {
token: "constant.language.escape", token: "constant.language.escape",
regex: /\$\{[^}]+\}/ regex: /\$\{/,
push: "start"
}, { }, {
token: "string", token: "string",
regex: '"', regex: '"',
next: "start" next: "pop"
}, { }, {
defaultToken: "string" defaultToken: "string"
}], }],
"qstring": [
"qstring": [{ {
token: "constant.language.escape", token: "constant.language.escape",
regex: /\$\{[^}]+\}/ regex: /\$\{/,
push: "start"
}, { }, {
token: "string", token: "string",
regex: "'", regex: "'",
next: "start" next: "pop"
}, { }, {
defaultToken: "string" defaultToken: "string"
}] }]
}; };
}; this.normalizeRules();
};
oop.inherits(NixHighlightRules, TextHighlightRules); oop.inherits(NixHighlightRules, TextHighlightRules);
exports.NixHighlightRules = NixHighlightRules; exports.NixHighlightRules = NixHighlightRules;
}); });

7
lib/ace/snippets/nix.js Normal file
View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./nix.snippets");
exports.scope = "nix";
});

View file