Unverified Commit 37314035 authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Merge staging-next into staging

parents 3262d954 d284ef37
Loading
Loading
Loading
Loading
+43 −41
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ let
    version
    versionSuffix
    warn;
  inherit (lib)
    isString
    ;
in {

  ## Simple (higher order) functions
@@ -718,98 +721,97 @@ in {
  importTOML = path:
    builtins.fromTOML (builtins.readFile path);

  ## Warnings

  # See https://github.com/NixOS/nix/issues/749. Eventually we'd like these
  # to expand to Nix builtins that carry metadata so that Nix can filter out
  # the INFO messages without parsing the message string.
  #
  # Usage:
  # {
  #   foo = lib.warn "foo is deprecated" oldFoo;
  #   bar = lib.warnIf (bar == "") "Empty bar is deprecated" bar;
  # }
  #
  # TODO: figure out a clever way to integrate location information from
  # something like __unsafeGetAttrPos.

  /**
    Print a warning before returning the second argument. This function behaves
    like `builtins.trace`, but requires a string message and formats it as a
    warning, including the `warning: ` prefix.

    To get a call stack trace and abort evaluation, set the environment variable
    `NIX_ABORT_ON_WARN=true` and set the Nix options `--option pure-eval false --show-trace`
    `warn` *`message`* *`value`*

    Print a warning before returning the second argument.

    See [`builtins.warn`](https://nix.dev/manual/nix/latest/language/builtins.html#builtins-warn) (Nix >= 2.23).
    On older versions, the Nix 2.23 behavior is emulated with [`builtins.trace`](https://nix.dev/manual/nix/latest/language/builtins.html#builtins-warn), including the [`NIX_ABORT_ON_WARN`](https://nix.dev/manual/nix/latest/command-ref/conf-file#conf-abort-on-warn) behavior, but not the `nix.conf` setting or command line option.

    # Inputs

    `msg`
    *`message`* (String)

    : Warning message to print.
    : Warning message to print before evaluating *`value`*.

    `val`
    *`value`* (any value)

    : Value to return as-is.

    # Type

    ```
    string -> a -> a
    String -> a -> a
    ```
  */
  warn =
    if lib.elem (builtins.getEnv "NIX_ABORT_ON_WARN") ["1" "true" "yes"]
    then msg: builtins.trace "warning: ${msg}" (abort "NIX_ABORT_ON_WARN=true; warnings are treated as unrecoverable errors.")
    else msg: builtins.trace "warning: ${msg}";
    # Since Nix 2.23, https://github.com/NixOS/nix/pull/10592
    builtins.warn or (
      let mustAbort = lib.elem (builtins.getEnv "NIX_ABORT_ON_WARN") ["1" "true" "yes"];
      in
        # Do not eta reduce v, so that we have the same strictness as `builtins.warn`.
        msg: v:
          # `builtins.warn` requires a string message, so we enforce that in our implementation, so that callers aren't accidentally incompatible with newer Nix versions.
          assert isString msg;
          if mustAbort
          then builtins.trace "evaluation warning: ${msg}" (abort "NIX_ABORT_ON_WARN=true; warnings are treated as unrecoverable errors.")
          else builtins.trace "evaluation warning: ${msg}" v
    );

  /**
    Like warn, but only warn when the first argument is `true`.

    `warnIf` *`condition`* *`message`* *`value`*

    Like `warn`, but only warn when the first argument is `true`.

    # Inputs

    `cond`
    *`condition`* (Boolean)

    : 1\. Function argument
    : `true` to trigger the warning before continuing with *`value`*.

    `msg`
    *`message`* (String)

    : 2\. Function argument
    : Warning message to print before evaluating

    `val`
    *`value`* (any value)

    : Value to return as-is.

    # Type

    ```
    bool -> string -> a -> a
    Bool -> String -> a -> a
    ```
  */
  warnIf = cond: msg: if cond then warn msg else x: x;

  /**
    Like warnIf, but negated (warn if the first argument is `false`).

    `warnIfNot` *`condition`* *`message`* *`value`*

    Like `warnIf`, but negated: warn if the first argument is `false`.

    # Inputs

    `cond`
    *`condition`*

    : 1\. Function argument
    : `false` to trigger the warning before continuing with `val`.

    `msg`
    *`message`*

    : 2\. Function argument
    : Warning message to print before evaluating *`value`*.

    `val`
    *`value`*

    : Value to return as-is.

    # Type

    ```
    bool -> string -> a -> a
    Boolean -> String -> a -> a
    ```
  */
  warnIfNot = cond: msg: if cond then x: x else warn msg;
+2 −0
Original line number Diff line number Diff line
@@ -56,6 +56,8 @@

- [Apache Tika](https://github.com/apache/tika), a toolkit that detects and extracts metadata and text from over a thousand different file types. Available as [services.tika](option.html#opt-services.tika).

- [Improved File Manager](https://github.com/misterunknown/ifm), or IFM, a single-file web-based file manager.

## Backward Incompatibilities {#sec-release-24.11-incompatibilities}

- `transmission` package has been aliased with a `trace` warning to `transmission_3`. Since [Transmission 4 has been released last year](https://github.com/transmission/transmission/releases/tag/4.0.0), and Transmission 3 will eventually go away, it was decided perform this warning alias to make people aware of the new version. The `services.transmission.package` defaults to `transmission_3` as well because the upgrade can cause data loss in certain specific usage patterns (examples: [#5153](https://github.com/transmission/transmission/issues/5153), [#6796](https://github.com/transmission/transmission/issues/6796)). Please make sure to back up to your data directory per your usage:
+1 −0
Original line number Diff line number Diff line
@@ -1405,6 +1405,7 @@
  ./services/web-apps/honk.nix
  ./services/web-apps/icingaweb2/icingaweb2.nix
  ./services/web-apps/icingaweb2/module-monitoring.nix
  ./services/web-apps/ifm.nix
  ./services/web-apps/invidious.nix
  ./services/web-apps/invoiceplane.nix
  ./services/web-apps/isso.nix
+81 −0
Original line number Diff line number Diff line
{ config, lib, pkgs, ...}:
let
  cfg = config.services.ifm;

  version = "4.0.2";
  src = pkgs.fetchurl {
    url = "https://github.com/misterunknown/ifm/releases/download/v${version}/cdn.ifm.php";
    hash = "sha256-37WbRM6D7JGmd//06zMhxMGIh8ioY8vRUmxX4OHgqBE=";
  };

  php = pkgs.php83;
in {
  options.services.ifm = {
    enable = lib.mkEnableOption ''
      Improved file manager, a single-file web-based filemanager

      Lightweight and minimal, served using PHP's built-in server
  '';

    dataDir = lib.mkOption {
      type = lib.types.str;
      description = "Directory to serve throught the file managing service";
    };

    listenAddress = lib.mkOption {
      type = lib.types.str;
      default = "127.0.0.1";
      description = "Address on which the service is listening";
      example = "0.0.0.0";
    };

    port = lib.mkOption {
      type = lib.types.port;
      default = 9090;
      description = "Port on which to serve the IFM service";
    };

    settings = lib.mkOption {
      type = with lib.types; attrsOf anything;
      default = {};
      description = ''
        Configuration of the IFM service.

        See [the documentation](https://github.com/misterunknown/ifm/wiki/Configuration)
        for available options and default values.
      '';
      example = {
        IFM_GUI_SHOWPATH = 0;
      };
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.ifm = {
      description = "Improved file manager, a single-file web based filemanager";

      after = [ "network-online.target" ];
      wantedBy = [ "multi-user.target" ];

      environment = {
        IFM_ROOT_DIR = "/data";
      } // (builtins.mapAttrs (_: val: toString val) cfg.settings);

      script = ''
        mkdir -p /tmp/ifm
        ln -s ${src} /tmp/ifm/index.php
        ${lib.getExe php} -S ${cfg.listenAddress}:${builtins.toString cfg.port} -t /tmp/ifm
      '';

      serviceConfig = {
        DynamicUser = true;
        User = "ifm";
        StandardOutput = "journal";
        BindPaths = "${cfg.dataDir}:/data";
        PrivateTmp = true;
      };
    };
  };

  meta.maintainers = with lib.maintainers; [ litchipi ];
}
+1 −0
Original line number Diff line number Diff line
@@ -441,6 +441,7 @@ in {
  hydra = handleTest ./hydra {};
  i3wm = handleTest ./i3wm.nix {};
  icingaweb2 = handleTest ./icingaweb2.nix {};
  ifm = handleTest ./ifm.nix {};
  iftop = handleTest ./iftop.nix {};
  incron = handleTest ./incron.nix {};
  incus = pkgs.recurseIntoAttrs (handleTest ./incus { inherit handleTestOn; inherit (pkgs) incus; });
Loading