Skip to content

Commit

Permalink
Merge staging-next into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jan 5, 2023
2 parents 0c8280b + a341044 commit 4acd5a9
Show file tree
Hide file tree
Showing 12 changed files with 221 additions and 72 deletions.
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
./programs/haguichi.nix
./programs/hamster.nix
./programs/htop.nix
./programs/iay.nix
./programs/iftop.nix
./programs/i3lock.nix
./programs/iotop.nix
Expand Down
37 changes: 37 additions & 0 deletions nixos/modules/programs/iay.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{ config, lib, pkgs, ... }:

let
cfg = config.programs.iay;
inherit (lib) mkEnableOption mkIf mkOption mkPackageOption optionalString types;
in {
options.programs.iay = {
enable = mkEnableOption (lib.mdDoc "iay");
package = mkPackageOption pkgs "iay" {};

minimalPrompt = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc "Use minimal one-liner prompt.";
};
};

config = mkIf cfg.enable {
programs.bash.promptInit = ''
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
PS1='$(iay ${optionalString cfg.minimalPrompt "-m"})'
fi
'';

programs.zsh.promptInit = ''
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
autoload -Uz add-zsh-hook
_iay_prompt() {
PROMPT="$(iay -z ${optionalString cfg.minimalPrompt "-m"})"
}
add-zsh-hook precmd _iay_prompt
fi
'';
};

meta.maintainers = pkgs.iay.meta.maintainers;
}
90 changes: 66 additions & 24 deletions nixos/modules/services/continuous-integration/gitlab-runner.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,41 @@ with lib;
let
cfg = config.services.gitlab-runner;
hasDocker = config.virtualisation.docker.enable;

/* The whole logic of this module is to diff the hashes of the desired vs existing runners
The hash is recorded in the runner's name because we can't do better yet
See https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29350 for more details
*/
genRunnerName = service: let
hash = substring 0 12 (hashString "md5" (unsafeDiscardStringContext (toJSON service)));
in if service ? description
then "${hash} ${service.description}"
else "${name}_${config.networking.hostName}_${hash}";

hashedServices = mapAttrs'
(name: service: nameValuePair
"${name}_${config.networking.hostName}_${
substring 0 12
(hashString "md5" (unsafeDiscardStringContext (toJSON service)))}"
service)
cfg.services;
configPath = "$HOME/.gitlab-runner/config.toml";
configureScript = pkgs.writeShellScriptBin "gitlab-runner-configure" (
if (cfg.configFile != null) then ''
mkdir -p $(dirname ${configPath})
(name: service: nameValuePair (genRunnerName service) service) cfg.services;
configPath = ''"$HOME"/.gitlab-runner/config.toml'';
configureScript = pkgs.writeShellApplication {
name = "gitlab-runner-configure";
runtimeInputs = with pkgs; [
bash
gawk
jq
moreutils
remarshal
util-linux
cfg.package
perl
python3
];
text = if (cfg.configFile != null) then ''
cp ${cfg.configFile} ${configPath}
# make config file readable by service
chown -R --reference=$HOME $(dirname ${configPath})
'' else ''
export CONFIG_FILE=${configPath}
mkdir -p $(dirname ${configPath})
mkdir -p "$(dirname "${configPath}")"
touch ${configPath}
# update global options
Expand All @@ -34,22 +51,43 @@ let
# remove no longer existing services
gitlab-runner verify --delete
# current and desired state
NEEDED_SERVICES=$(echo ${concatStringsSep " " (attrNames hashedServices)} | tr " " "\n")
REGISTERED_SERVICES=$(gitlab-runner list 2>&1 | grep 'Executor' | awk '{ print $1 }')
${toShellVar "NEEDED_SERVICES" (lib.mapAttrs (name: value: 1) hashedServices)}
declare -A REGISTERED_SERVICES
while IFS="," read -r name token;
do
REGISTERED_SERVICES["$name"]="$token"
done < <(gitlab-runner --log-format json list 2>&1 | grep Token | jq -r '.msg +"," + .Token')
echo "NEEDED_SERVICES: " "''${!NEEDED_SERVICES[@]}"
echo "REGISTERED_SERVICES:" "''${!REGISTERED_SERVICES[@]}"
# difference between current and desired state
NEW_SERVICES=$(grep -vxF -f <(echo "$REGISTERED_SERVICES") <(echo "$NEEDED_SERVICES") || true)
OLD_SERVICES=$(grep -vxF -f <(echo "$NEEDED_SERVICES") <(echo "$REGISTERED_SERVICES") || true)
declare -A NEW_SERVICES
for name in "''${!NEEDED_SERVICES[@]}"; do
if [ ! -v 'REGISTERED_SERVICES[$name]' ]; then
NEW_SERVICES[$name]=1
fi
done
declare -A OLD_SERVICES
# shellcheck disable=SC2034
for name in "''${!REGISTERED_SERVICES[@]}"; do
if [ ! -v 'NEEDED_SERVICES[$name]' ]; then
OLD_SERVICES[$name]=1
fi
done
# register new services
${concatStringsSep "\n" (mapAttrsToList (name: service: ''
if echo "$NEW_SERVICES" | grep -xq "${name}"; then
# TODO so here we should mention NEW_SERVICES
if [ -v 'NEW_SERVICES["${name}"]' ] ; then
bash -c ${escapeShellArg (concatStringsSep " \\\n " ([
"set -a && source ${service.registrationConfigFile} &&"
"gitlab-runner register"
"--non-interactive"
(if service.description != null then "--description \"${service.description}\"" else "--name '${name}'")
"--name '${name}'"
"--executor ${service.executor}"
"--limit ${toString service.limit}"
"--request-concurrency ${toString service.requestConcurrency}"
Expand Down Expand Up @@ -92,22 +130,26 @@ let
fi
'') hashedServices)}
# check key is in array https://stackoverflow.com/questions/30353951/how-to-check-if-dictionary-contains-a-key-in-bash
echo "NEW_SERVICES: ''${NEW_SERVICES[*]}"
echo "OLD_SERVICES: ''${OLD_SERVICES[*]}"
# unregister old services
for NAME in $(echo "$OLD_SERVICES")
for NAME in "''${!OLD_SERVICES[@]}"
do
[ ! -z "$NAME" ] && gitlab-runner unregister \
[ -n "$NAME" ] && gitlab-runner unregister \
--name "$NAME" && sleep 1
done
# make config file readable by service
chown -R --reference=$HOME $(dirname ${configPath})
'');
chown -R --reference="$HOME" "$(dirname ${configPath})"
'';
};
startScript = pkgs.writeShellScriptBin "gitlab-runner-start" ''
export CONFIG_FILE=${configPath}
exec gitlab-runner run --working-directory $HOME
'';
in
{
in {
options.services.gitlab-runner = {
enable = mkEnableOption (lib.mdDoc "Gitlab Runner");
configFile = mkOption {
Expand Down
33 changes: 22 additions & 11 deletions nixos/tests/wordpress.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ./make-test-python.nix ({ pkgs, ... }:
import ./make-test-python.nix ({ lib, pkgs, ... }:

{
rec {
name = "wordpress";
meta = with pkgs.lib.maintainers; {
maintainers = [
Expand All @@ -10,67 +10,78 @@ import ./make-test-python.nix ({ pkgs, ... }:
];
};

nodes = {
wp_httpd = { ... }: {
nodes = lib.foldl (a: version: let
package = pkgs."wordpress${version}";
in a // {
"wp${version}_httpd" = _: {
services.httpd.adminAddr = "[email protected]";
services.httpd.logPerVirtualHost = true;

services.wordpress.webserver = "httpd";
services.wordpress.sites = {
"site1.local" = {
database.tablePrefix = "site1_";
inherit package;
};
"site2.local" = {
database.tablePrefix = "site2_";
inherit package;
};
};

networking.firewall.allowedTCPPorts = [ 80 ];
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
};

wp_nginx = { ... }: {
"wp${version}_nginx" = _: {
services.wordpress.webserver = "nginx";
services.wordpress.sites = {
"site1.local" = {
database.tablePrefix = "site1_";
inherit package;
};
"site2.local" = {
database.tablePrefix = "site2_";
inherit package;
};
};

networking.firewall.allowedTCPPorts = [ 80 ];
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
};

wp_caddy = { ... }: {
"wp${version}_caddy" = _: {
services.wordpress.webserver = "caddy";
services.wordpress.sites = {
"site1.local" = {
database.tablePrefix = "site1_";
inherit package;
};
"site2.local" = {
database.tablePrefix = "site2_";
inherit package;
};
};

networking.firewall.allowedTCPPorts = [ 80 ];
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
};
};
}) {} [
"6_1"
];

testScript = ''
import re
start_all()
wp_httpd.wait_for_unit("httpd")
wp_nginx.wait_for_unit("nginx")
wp_caddy.wait_for_unit("caddy")
${lib.concatStrings (lib.mapAttrsToList (name: value: ''
${name}.wait_for_unit("${(value null).services.wordpress.webserver}")
'') nodes)}
site_names = ["site1.local", "site2.local"]
for machine in (wp_httpd, wp_nginx, wp_caddy):
for machine in (${lib.concatStringsSep ", " (builtins.attrNames nodes)}):
for site_name in site_names:
machine.wait_for_unit(f"phpfpm-wordpress-{site_name}")
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/audio/cmt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

stdenv.mkDerivation rec {
pname = "cmt";
version = "1.17";
version = "1.18";

src = fetchurl {
url = "http://www.ladspa.org/download/cmt_${version}.tgz";
sha256 = "07xd0xmwpa0j12813jpf87fr9hwzihii5l35mp8ady7xxfmxfmpb";
sha256 = "sha256-qC+GNt4fSto4ahmaAXqc13Wkm0nnFrEejdP3I8k99so=";
};

buildInputs = [ ladspaH ];
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/misc/josm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
}:
let
pname = "josm";
version = "18621";
version = "18622";
srcs = {
jar = fetchurl {
url = "https://josm.openstreetmap.de/download/josm-snapshot-${version}.jar";
hash = "sha256-RZiYHDqowk0oG/rQVcsoYpZvL4wNmegZD2EHlsQggw8=";
hash = "sha256-AtV7Lj+z1GOCEl8xUaumYcN848pMsLIfMGmBXved6WU=";
};
macosx = fetchurl {
url = "https://josm.openstreetmap.de/download/macosx/josm-macos-${version}-java17.zip";
hash = "sha256-Sf5mgxWjq240U1tUByBS6FFb0Tpj/QP7yHl+wvTIfng=";
hash = "sha256-q3Kr0YWe6Jm6wO6h7fMANKLCWKfU0zDpBZjRH662eSg=";
};
pkg = fetchsvn {
url = "https://josm.openstreetmap.de/svn/trunk/native/linux/tested";
Expand Down
37 changes: 12 additions & 25 deletions pkgs/applications/networking/instant-messengers/qq/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@
, at-spi2-core
, autoPatchelfHook
, wrapGAppsHook
, copyDesktopItems
, makeDesktopItem
}:

let
version = "2.0.3-543";
version = "3.0.0-565";
srcs = {
x86_64-linux = fetchurl {
url = "https://dldir1.qq.com/qqfile/qq/QQNT/50eed662/QQ-v${version}_x64.deb";
sha256 = "sha256-O8zaVHt/oXserPVHe/r6pAFpWFeLDVsiaazgaX7kxu8=";
url = "https://dldir1.qq.com/qqfile/qq/QQNT/64bd2578/linuxqq_${version}_amd64.deb";
sha256 = "sha256-IfBbheVwg4b5PuLX9bzqSuTcElxNaV3tmbGd3v/NkCY=";
};
aarch64-linux = fetchurl {
url = "https://dldir1.qq.com/qqfile/qq/QQNT/50eed662/QQ-v${version}_arm64.deb";
sha256 = "sha256-01ZpcoSDc5b0MCKAMq16N4cXzbouHNckOGsv+Z4et7w=";
url = "https://dldir1.qq.com/qqfile/qq/QQNT/64bd2578/linuxqq_${version}_arm64.deb";
sha256 = "sha256-6IlAJdPknaQzOE48sdxb5QbB+ZF1xKstF3ARGHM30GY=";
};
};
src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
Expand All @@ -44,7 +42,6 @@ stdenv.mkDerivation {
nativeBuildInputs = [
autoPatchelfHook
wrapGAppsHook
copyDesktopItems
dpkg
];

Expand All @@ -67,28 +64,18 @@ stdenv.mkDerivation {

installPhase = ''
runHook preInstall
mkdir -p "$out/share/icons/hicolor/0x0/apps"
cp usr/share/icons/hicolor/0x0/apps/qq.png $out/share/icons/hicolor/0x0/apps
mkdir -p "$out/opt"
cp -r "opt/"* $out/opt
mkdir -p $out/bin
cp -r opt $out/opt
cp -r usr/share $out/share
substituteInPlace $out/share/applications/qq.desktop \
--replace "/opt/QQ/qq" "$out/bin/qq" \
--replace "/usr/share" "$out/share"
ln -s $out/opt/QQ/qq $out/bin/qq
mkdir -p "$out/bin"
ln -s "$out/opt/QQ/qq" "$out/bin/qq"
runHook postInstall
'';

desktopItems = [
(makeDesktopItem {
desktopName = "Tencent QQ";
genericName = "A messaging app";
categories = [ "Network" ];
icon = "qq";
exec = "qq";
name = "qq";
})
];

meta = with lib; {
homepage = "https://im.qq.com/linuxqq/";
description = "Messaging app";
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/video/obs-studio/plugins/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# - Add plugin to it's own directory (because of future patches).

{
droidcam-obs = callPackage ./droidcam-obs { };

input-overlay = qt6Packages.callPackage ./input-overlay.nix { };

looking-glass-obs = callPackage ./looking-glass-obs.nix { };
Expand Down
Loading

0 comments on commit 4acd5a9

Please sign in to comment.