Nix mode
This commit is contained in:
parent
a44b053eab
commit
3812b20546
6 changed files with 175 additions and 96 deletions
|
|
@ -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 = {
|
||||||
|
|
|
||||||
57
demo/kitchen-sink/docs/Nix.nix
Normal file
57
demo/kitchen-sink/docs/Nix.nix
Normal 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 = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*
|
*
|
||||||
*
|
* Zef Hemel
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,105 +1,119 @@
|
||||||
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";
|
||||||
var keywordDeclaration = "let|in|rec";
|
var keywordDeclaration = "let|in|rec";
|
||||||
|
|
||||||
var keywordMapper = this.createKeywordMapper({
|
var keywordMapper = this.createKeywordMapper({
|
||||||
"constant.language.nix": constantLanguage,
|
"constant.language.nix": constantLanguage,
|
||||||
"keyword.control.nix": keywordControl,
|
"keyword.control.nix": keywordControl,
|
||||||
"keyword.declaration.nix": keywordDeclaration
|
"keyword.declaration.nix": keywordDeclaration
|
||||||
}, "identifier");
|
}, "identifier");
|
||||||
|
|
||||||
this.$rules = {
|
this.$rules = {
|
||||||
"start": [{
|
"start": [{
|
||||||
token: "comment",
|
token: "comment",
|
||||||
regex: /#.*$/
|
regex: /#.*$/
|
||||||
}, {
|
}, {
|
||||||
token: "comment",
|
token: "comment",
|
||||||
regex: /\/\*/,
|
regex: /\/\*/,
|
||||||
next: "comment"
|
next: "comment"
|
||||||
}, {
|
}, {
|
||||||
regex: "(==|!=|<=?|>=?)",
|
token: "constant",
|
||||||
token: ["keyword.operator.comparison.nix"]
|
regex: "<[^>]+>"
|
||||||
}, {
|
}, {
|
||||||
regex: "((?:[+*/%-]|\\~)=)",
|
regex: "(==|!=|<=?|>=?)",
|
||||||
token: ["keyword.operator.assignment.arithmetic.nix"]
|
token: ["keyword.operator.comparison.nix"]
|
||||||
}, {
|
}, {
|
||||||
regex: "=",
|
regex: "((?:[+*/%-]|\\~)=)",
|
||||||
token: "keyword.operator.assignment.nix"
|
token: ["keyword.operator.assignment.arithmetic.nix"]
|
||||||
}, {
|
}, {
|
||||||
token: "string",
|
regex: "=",
|
||||||
regex: "''",
|
token: "keyword.operator.assignment.nix"
|
||||||
next: "qqdoc"
|
}, {
|
||||||
}, {
|
token: "string",
|
||||||
token: "string",
|
regex: "''",
|
||||||
regex: "'",
|
next: "qqdoc"
|
||||||
next: "qstring"
|
}, {
|
||||||
}, {
|
token: "string",
|
||||||
token: "string",
|
regex: "'",
|
||||||
regex: '"',
|
next: "qstring"
|
||||||
next: "qqstring"
|
}, {
|
||||||
}, {
|
token: "string",
|
||||||
token: "constant.numeric", // hex
|
regex: '"',
|
||||||
regex: "0[xX][0-9a-fA-F]+\\b"
|
push: "qqstring"
|
||||||
}, {
|
}, {
|
||||||
token: "constant.numeric", // float
|
token: "constant.numeric", // hex
|
||||||
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
regex: "0[xX][0-9a-fA-F]+\\b"
|
||||||
}, {
|
}, {
|
||||||
token: keywordMapper,
|
token: "constant.numeric", // float
|
||||||
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
|
||||||
}],
|
}, {
|
||||||
"comment": [{
|
token: keywordMapper,
|
||||||
token: "comment", // closing comment
|
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
|
||||||
regex: ".*?\\*\\/",
|
}, {
|
||||||
next: "start"
|
regex: "}",
|
||||||
}, {
|
token: function(val, start, stack) {
|
||||||
token: "comment", // comment spanning whole line
|
return stack[1] == "qqstring" ? "constant.language.escape" : "text"
|
||||||
regex: ".+"
|
},
|
||||||
}],
|
next: "pop"
|
||||||
"qqdoc": [{
|
}],
|
||||||
token: "constant.language.escape",
|
"comment": [{
|
||||||
regex: /\$\{[^}]+\}/
|
token: "comment", // closing comment
|
||||||
}, {
|
regex: ".*?\\*\\/",
|
||||||
token: "string",
|
next: "start"
|
||||||
regex: "''",
|
}, {
|
||||||
next: "start"
|
token: "comment", // comment spanning whole line
|
||||||
}, {
|
regex: ".+"
|
||||||
defaultToken: "string"
|
}],
|
||||||
}],
|
"qqdoc": [
|
||||||
|
{
|
||||||
|
token: "constant.language.escape",
|
||||||
|
regex: /\$\{/,
|
||||||
|
push: "start"
|
||||||
|
}, {
|
||||||
|
token: "string",
|
||||||
|
regex: "''",
|
||||||
|
next: "pop"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}],
|
||||||
|
"qqstring": [
|
||||||
|
{
|
||||||
|
token: "constant.language.escape",
|
||||||
|
regex: /\$\{/,
|
||||||
|
push: "start"
|
||||||
|
}, {
|
||||||
|
token: "string",
|
||||||
|
regex: '"',
|
||||||
|
next: "pop"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}],
|
||||||
|
"qstring": [
|
||||||
|
{
|
||||||
|
token: "constant.language.escape",
|
||||||
|
regex: /\$\{/,
|
||||||
|
push: "start"
|
||||||
|
}, {
|
||||||
|
token: "string",
|
||||||
|
regex: "'",
|
||||||
|
next: "pop"
|
||||||
|
}, {
|
||||||
|
defaultToken: "string"
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
"qqstring": [{
|
this.normalizeRules();
|
||||||
token: "constant.language.escape",
|
|
||||||
regex: /\$\{[^}]+\}/
|
|
||||||
}, {
|
|
||||||
token: "string",
|
|
||||||
regex: '"',
|
|
||||||
next: "start"
|
|
||||||
}, {
|
|
||||||
defaultToken: "string"
|
|
||||||
}],
|
|
||||||
|
|
||||||
"qstring": [{
|
|
||||||
token: "constant.language.escape",
|
|
||||||
regex: /\$\{[^}]+\}/
|
|
||||||
}, {
|
|
||||||
token: "string",
|
|
||||||
regex: "'",
|
|
||||||
next: "start"
|
|
||||||
}, {
|
|
||||||
defaultToken: "string"
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
oop.inherits(NixHighlightRules, TextHighlightRules);
|
||||||
|
|
||||||
oop.inherits(NixHighlightRules, TextHighlightRules);
|
exports.NixHighlightRules = NixHighlightRules;
|
||||||
|
|
||||||
exports.NixHighlightRules = NixHighlightRules;
|
|
||||||
});
|
});
|
||||||
7
lib/ace/snippets/nix.js
Normal file
7
lib/ace/snippets/nix.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
define(function(require, exports, module) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
exports.snippetText = require("../requirejs/text!./nix.snippets");
|
||||||
|
exports.scope = "nix";
|
||||||
|
|
||||||
|
});
|
||||||
0
lib/ace/snippets/nix.snippets
Normal file
0
lib/ace/snippets/nix.snippets
Normal file
Loading…
Add table
Add a link
Reference in a new issue