-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
442 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{ lib, pkgs, config, ... }: | ||
with lib; | ||
|
||
let | ||
settingsFormat = pkgs.formats.yaml { }; | ||
|
||
# gemstash uses a yaml config where the keys are ruby symbols, | ||
# which means they start with ':'. This would be annoying to use | ||
# on the nix side, so we rewrite plain names instead. | ||
prefixColon = s: listToAttrs (map | ||
(attrName: { | ||
name = ":${attrName}"; | ||
value = | ||
if isAttrs s.${attrName} | ||
then prefixColon s."${attrName}" | ||
else s."${attrName}"; | ||
}) | ||
(attrNames s)); | ||
|
||
# parse the port number out of the tcp://ip:port bind setting string | ||
parseBindPort = bind: strings.toInt (last (strings.splitString ":" bind)); | ||
|
||
cfg = config.services.gemstash; | ||
in | ||
{ | ||
options.services.gemstash = { | ||
enable = mkEnableOption (lib.mdDoc "gemstash service"); | ||
|
||
openFirewall = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = lib.mdDoc '' | ||
Whether to open the firewall for the port in {option}`services.gemstash.bind`. | ||
''; | ||
}; | ||
|
||
settings = mkOption { | ||
default = {}; | ||
description = lib.mdDoc '' | ||
Configuration for Gemstash. The details can be found at in | ||
[gemstash documentation](https://github.com/rubygems/gemstash/blob/master/man/gemstash-configuration.5.md). | ||
Each key set here is automatically prefixed with ":" to match the gemstash expectations. | ||
''; | ||
type = types.submodule { | ||
freeformType = settingsFormat.type; | ||
options = { | ||
base_path = mkOption { | ||
type = types.path; | ||
default = "/var/lib/gemstash"; | ||
description = lib.mdDoc "Path to store the gem files and the sqlite database. If left unchanged, the directory will be created."; | ||
}; | ||
bind = mkOption { | ||
type = types.str; | ||
default = "tcp://0.0.0.0:9292"; | ||
description = lib.mdDoc "Host and port combination for the server to listen on."; | ||
}; | ||
db_adapter = mkOption { | ||
type = types.nullOr (types.enum [ "sqlite3" "postgres" "mysql" "mysql2" ]); | ||
default = null; | ||
description = lib.mdDoc "Which database type to use. For choices other than sqlite3, the dbUrl has to be specified as well."; | ||
}; | ||
db_url = mkOption { | ||
type = types.nullOr types.str; | ||
default = null; | ||
description = lib.mdDoc "The database to connect to when using postgres, mysql, or mysql2."; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
config = | ||
mkIf cfg.enable { | ||
users = { | ||
users.gemstash = { | ||
group = "gemstash"; | ||
isSystemUser = true; | ||
}; | ||
groups.gemstash = { }; | ||
}; | ||
|
||
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ (parseBindPort cfg.settings.bind) ]; | ||
|
||
systemd.services.gemstash = { | ||
wantedBy = [ "multi-user.target" ]; | ||
after = [ "network.target" ]; | ||
serviceConfig = mkMerge [ | ||
{ | ||
ExecStart = "${pkgs.gemstash}/bin/gemstash start --no-daemonize --config-file ${settingsFormat.generate "gemstash.yaml" (prefixColon cfg.settings)}"; | ||
NoNewPrivileges = true; | ||
User = "gemstash"; | ||
Group = "gemstash"; | ||
PrivateTmp = true; | ||
RestrictSUIDSGID = true; | ||
LockPersonality = true; | ||
} | ||
(mkIf (cfg.settings.base_path == "/var/lib/gemstash") { | ||
StateDirectory = "gemstash"; | ||
}) | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ system ? builtins.currentSystem, config ? { } | ||
, pkgs ? import ../.. { inherit system config; } }: | ||
|
||
with import ../lib/testing-python.nix { inherit system pkgs; }; | ||
with pkgs.lib; | ||
|
||
let common_meta = { maintainers = [ maintainers.viraptor ]; }; | ||
in | ||
{ | ||
gemstash_works = makeTest { | ||
name = "gemstash-works"; | ||
meta = common_meta; | ||
|
||
nodes.machine = { config, pkgs, ... }: { | ||
services.gemstash = { | ||
enable = true; | ||
}; | ||
}; | ||
|
||
# gemstash responds to http requests | ||
testScript = '' | ||
machine.wait_for_unit("gemstash.service") | ||
machine.wait_for_file("/var/lib/gemstash") | ||
machine.wait_for_open_port(9292) | ||
machine.succeed("curl http://localhost:9292") | ||
''; | ||
}; | ||
|
||
gemstash_custom_port = makeTest { | ||
name = "gemstash-custom-port"; | ||
meta = common_meta; | ||
|
||
nodes.machine = { config, pkgs, ... }: { | ||
services.gemstash = { | ||
enable = true; | ||
openFirewall = true; | ||
settings = { | ||
bind = "tcp://0.0.0.0:12345"; | ||
}; | ||
}; | ||
}; | ||
|
||
# gemstash responds to http requests | ||
testScript = '' | ||
machine.wait_for_unit("gemstash.service") | ||
machine.wait_for_file("/var/lib/gemstash") | ||
machine.wait_for_open_port(12345) | ||
machine.succeed("curl http://localhost:12345") | ||
''; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
pkgs/applications/networking/instant-messengers/signal-desktop/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ callPackage }: builtins.mapAttrs (pname: attrs: callPackage ./generic.nix (attrs // { inherit pname; })) { | ||
signal-desktop = { | ||
dir = "Signal"; | ||
version = "6.5.1"; | ||
hash = "sha256-At4ILl6nHltP1TMI5cjK7gE4NENAccS4MPMHXJoGveM="; | ||
version = "6.7.0"; | ||
hash = "sha256-njiVPTkzYdt7QZcpohXUI3hj/o+fO4/O0ZlQrq2oP6Y="; | ||
}; | ||
signal-desktop-beta = { | ||
dir = "Signal Beta"; | ||
version = "6.6.0-beta.1"; | ||
hash = "sha256-txSvMg7Q+r9UWJMC9Rj2XQ8y1WN3xphMruvOZok/VPk="; | ||
version = "6.8.0-beta.1"; | ||
hash = "sha256-akQmGxDW6SBQCRLU6TgfODP8ZjEPsvaBvrkdd+6DqKs="; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.