diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 68bc3966440d9..dbebca815bec2 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -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 diff --git a/nixos/modules/programs/iay.nix b/nixos/modules/programs/iay.nix new file mode 100644 index 0000000000000..1fa00e43795ad --- /dev/null +++ b/nixos/modules/programs/iay.nix @@ -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; +} diff --git a/nixos/modules/services/continuous-integration/gitlab-runner.nix b/nixos/modules/services/continuous-integration/gitlab-runner.nix index 7b1c4da862606..d18c4cff04057 100644 --- a/nixos/modules/services/continuous-integration/gitlab-runner.nix +++ b/nixos/modules/services/continuous-integration/gitlab-runner.nix @@ -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 @@ -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}" @@ -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 { diff --git a/nixos/tests/wordpress.nix b/nixos/tests/wordpress.nix index 416a20aa7fe81..6a460dbce3547 100644 --- a/nixos/tests/wordpress.nix +++ b/nixos/tests/wordpress.nix @@ -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 = [ @@ -10,17 +10,22 @@ 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 = "webmaster@site.local"; 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; }; }; @@ -28,14 +33,16 @@ import ./make-test-python.nix ({ pkgs, ... }: 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; }; }; @@ -43,34 +50,38 @@ import ./make-test-python.nix ({ pkgs, ... }: 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}") diff --git a/pkgs/applications/audio/cmt/default.nix b/pkgs/applications/audio/cmt/default.nix index 1062d897c6bde..bf7ed0ee37d4b 100644 --- a/pkgs/applications/audio/cmt/default.nix +++ b/pkgs/applications/audio/cmt/default.nix @@ -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 ]; diff --git a/pkgs/applications/misc/josm/default.nix b/pkgs/applications/misc/josm/default.nix index 2efe9ec440e1c..9890ea9ad8db6 100644 --- a/pkgs/applications/misc/josm/default.nix +++ b/pkgs/applications/misc/josm/default.nix @@ -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"; diff --git a/pkgs/applications/networking/instant-messengers/qq/default.nix b/pkgs/applications/networking/instant-messengers/qq/default.nix index 6d1a2696a4c99..42b8a929a2130 100644 --- a/pkgs/applications/networking/instant-messengers/qq/default.nix +++ b/pkgs/applications/networking/instant-messengers/qq/default.nix @@ -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}"); @@ -44,7 +42,6 @@ stdenv.mkDerivation { nativeBuildInputs = [ autoPatchelfHook wrapGAppsHook - copyDesktopItems dpkg ]; @@ -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"; diff --git a/pkgs/applications/video/obs-studio/plugins/default.nix b/pkgs/applications/video/obs-studio/plugins/default.nix index 493079a25bba6..1a7be5aa98114 100644 --- a/pkgs/applications/video/obs-studio/plugins/default.nix +++ b/pkgs/applications/video/obs-studio/plugins/default.nix @@ -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 { }; diff --git a/pkgs/applications/video/obs-studio/plugins/droidcam-obs/default.nix b/pkgs/applications/video/obs-studio/plugins/droidcam-obs/default.nix new file mode 100644 index 0000000000000..131817a2589f8 --- /dev/null +++ b/pkgs/applications/video/obs-studio/plugins/droidcam-obs/default.nix @@ -0,0 +1,70 @@ +{ lib +, stdenv +, fetchFromGitHub +, obs-studio +, ffmpeg +, libjpeg +, libimobiledevice +, libusbmuxd +, libplist +}: + +stdenv.mkDerivation rec { + pname = "droidcam-obs"; + version = "2.0.1"; + + src = fetchFromGitHub { + owner = "dev47apps"; + repo = "droidcam-obs-plugin"; + rev = version; + sha256 = "sha256-oaw/mq4WCQMlf3sv9WtNlv9J9rm79xnqDwKzHtyFW50="; + }; + + postPatch = '' + substituteInPlace ./linux/linux.mk \ + --replace "-limobiledevice" "-limobiledevice-1.0" \ + --replace "-I/usr/include/obs" "-I${obs-studio}/include/obs" \ + --replace "-I/usr/include/ffmpeg" "-I${ffmpeg}/include" + ''; + + preBuild = '' + mkdir ./build + ''; + + buildInputs = [ + libjpeg + libimobiledevice + libusbmuxd + libplist + obs-studio + ffmpeg + ]; + + makeFlags = [ + "ALLOW_STATIC=no" + "JPEG_DIR=${lib.getDev libjpeg}" + "JPEG_LIB=${lib.getLib libjpeg}/lib" + "IMOBILEDEV_DIR=${libimobiledevice}" + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share/obs/obs-plugins/droidcam-obs + mkdir -p $out/lib/obs-plugins + cp build/droidcam-obs.so $out/lib/obs-plugins + cp -R ./data/locale $out/share/obs/obs-plugins/droidcam-obs/locale + + runHook postInstall + ''; + + doCheck = false; + + meta = with lib; { + description = "DroidCam OBS"; + homepage = "https://github.com/dev47apps/droidcam-obs-plugin"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ ulrikstrid ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/desktops/pantheon/artwork/elementary-wallpapers/default.nix b/pkgs/desktops/pantheon/artwork/elementary-wallpapers/default.nix index b3568fb0bc386..addef5891d2c7 100644 --- a/pkgs/desktops/pantheon/artwork/elementary-wallpapers/default.nix +++ b/pkgs/desktops/pantheon/artwork/elementary-wallpapers/default.nix @@ -10,13 +10,13 @@ stdenv.mkDerivation rec { pname = "elementary-wallpapers"; - version = "6.1.0"; + version = "7.0.0"; src = fetchFromGitHub { owner = "elementary"; repo = "wallpapers"; rev = version; - sha256 = "sha256-E/cUxa/GNt/01EjuuvurHxJu3qV9e+jcdcCi2+NxVDA="; + sha256 = "sha256-i9tIz5UckON8uwGlE62b/y0M0Neqt86rR3VdNUWBo04="; }; nativeBuildInputs = [ diff --git a/pkgs/development/compilers/go/1.20.nix b/pkgs/development/compilers/go/1.20.nix index 5081e5efecfe1..9ae9af3c66820 100644 --- a/pkgs/development/compilers/go/1.20.nix +++ b/pkgs/development/compilers/go/1.20.nix @@ -45,11 +45,11 @@ let in stdenv.mkDerivation rec { pname = "go"; - version = "1.20rc1"; + version = "1.20rc2"; src = fetchurl { url = "https://go.dev/dl/go${version}.src.tar.gz"; - sha256 = "sha256-FzEFTKmE8l/dCD0Ejt+gghDMkWf1oIanHeuhKMcTtBQ="; + sha256 = "sha256-V1IqKi4pXKYpJJRQHxMfiJO1kRqMD4VzfniqdOC5/PY="; }; strictDeps = true; diff --git a/pkgs/tools/misc/iay/default.nix b/pkgs/tools/misc/iay/default.nix index 9c8b0a47ab867..88e14f582394a 100644 --- a/pkgs/tools/misc/iay/default.nix +++ b/pkgs/tools/misc/iay/default.nix @@ -38,10 +38,9 @@ rustPlatform.buildRustPackage rec { NIX_LDFLAGS = lib.optionals stdenv.isDarwin [ "-framework" "AppKit" ]; meta = with lib; { - description = - "Minimalistic, blazing-fast, and extendable prompt for bash and zsh"; + description = "Minimalistic, blazing-fast, and extendable prompt for bash and zsh"; homepage = "https://github.com/aaqaishtyaq/iay"; license = licenses.mit; - maintainers = with maintainers; [ aaqaishtyaq ]; + maintainers = with maintainers; [ aaqaishtyaq omasanori ]; }; }