Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eiwd: init at 2.8-1 #208844

Merged
merged 10 commits into from Nov 3, 2023
Merged
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
85 changes: 85 additions & 0 deletions pkgs/by-name/ei/eiwd/package.nix
@@ -0,0 +1,85 @@
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
, pkg-config
, python3Packages # for tests
, openssl # for tests
, enableManpages ? true
, docutils # for manpages
}:

stdenv.mkDerivation (finalAttrs: {
pname = "eiwd";
version = "2.8-1";

src = fetchFromGitHub {
owner = "illiliti";
repo = "eiwd";
rev = finalAttrs.version;
hash = "sha256-SD/RJFuGBwFT4G73f93VrWO/6mGKQxjVhmNrpKRA/WY=";
fetchSubmodules = true;
};

outputs = [
"out" "doc"
] ++ lib.optionals enableManpages [
"man"
] ++ lib.optionals finalAttrs.doCheck [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
] ++ lib.optionals finalAttrs.doCheck [
] ++ lib.optionals finalAttrs.finalPackage.doCheck [

finalAttrs.finalPackage.doCheck contains the logic in mkDerivation so setting doCheck here will be unnecessary

Copy link
Author

@ghost ghost Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but you can't reference finalPackage in the definition of the package itself. It's infinite recursion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah but not for outputs. mkDerivation is extra-strict in those. Go ahead try your suggestion; you'll get this:

$ nix-instantiate . -A eiwd
error:
       … while calling a functor (an attribute set with a '__functor' attribute)
     at /git/pr/eiwd/init/lib/customisation.nix:174:34:

      173|
      174|     in if missingArgs == [] then makeOverridable f allArgs else abort error;
         |                                  ^
      175|

   … while evaluating a branch condition

     at /git/pr/eiwd/init/lib/customisation.nix:86:7:

       85|     in
       86|       if builtins.isAttrs result then
         |       ^
       87|         result // {

   (stack trace truncated; use '--show-trace' to show the full trace)

   error: infinite recursion encountered

   at «none»:0: (source not available)

nix@moore:/git/pr/eiwd/init$ nix-instantiate . -A eiwd --show-trace
error:
… while calling '_internalCallByNamePackageFile'

     at /git/pr/eiwd/init/pkgs/top-level/by-name-overlay.nix:55:36:

       54|   # Because at that point the code in ./stage.nix can be changed to not allow definitions in `all-packages.nix` to override ones from `pkgs/by-name` anymore and throw an error if that happens instead.
       55|   _internalCallByNamePackageFile = file: self.callPackage file { };
         |                                    ^
       56| }

   … from call site

     at /git/pr/eiwd/init/pkgs/top-level/by-name-overlay.nix:55:42:

       54|   # Because at that point the code in ./stage.nix can be changed to not allow definitions in `all-packages.nix` to override ones from `pkgs/by-name` anymore and throw an error if that happens instead.
       55|   _internalCallByNamePackageFile = file: self.callPackage file { };
         |                                          ^
       56| }

   … while calling 'callPackageWith'

     at /git/pr/eiwd/init/lib/customisation.nix:123:35:

      122|   */
      123|   callPackageWith = autoArgs: fn: args:
         |                                   ^
      124|     let

   … from call site

     at /git/pr/eiwd/init/lib/trivial.nix:430:7:

      429|     { # TODO: Should we add call-time "type" checking like built in?
      430|       __functor = self: f;
         |       ^
      431|       __functionArgs = args;

   … while calling anonymous lambda

     at /git/pr/eiwd/init/lib/customisation.nix:73:6:

       72|   makeOverridable = f: lib.setFunctionArgs
       73|     (origArgs: let
         |      ^
       74|       result = f origArgs;

   … from call site

     at /git/pr/eiwd/init/lib/customisation.nix:74:16:

       73|     (origArgs: let
       74|       result = f origArgs;
         |                ^
       75|

   … while calling anonymous lambda

     at /git/pr/eiwd/init/pkgs/by-name/ei/eiwd/package.nix:1:1:

        1| { lib
         | ^
        2| , stdenv

   … from call site

     at /git/pr/eiwd/init/pkgs/by-name/ei/eiwd/package.nix:12:1:

       11|
       12| stdenv.mkDerivation (finalAttrs: {
         | ^
       13|   pname = "eiwd";

   … while calling anonymous lambda

     at /git/pr/eiwd/init/pkgs/stdenv/generic/make-derivation.nix:548:3:

      547| in
      548|   fnOrAttrs:
         |   ^
      549|     if builtins.isFunction fnOrAttrs

   … from call site

     at /git/pr/eiwd/init/pkgs/stdenv/generic/make-derivation.nix:550:10:

      549|     if builtins.isFunction fnOrAttrs
      550|     then makeDerivationExtensible fnOrAttrs
         |          ^
      551|     else makeDerivationExtensibleConst fnOrAttrs

   … while calling 'makeDerivationExtensible'

     at /git/pr/eiwd/init/pkgs/stdenv/generic/make-derivation.nix:14:30:

       13|   # Based off lib.makeExtensible, with modifications:
       14|   makeDerivationExtensible = rattrs:
         |                              ^
       15|     let

   … from call site

     at /git/pr/eiwd/init/pkgs/stdenv/generic/make-derivation.nix:47:9:

       46|       finalPackage =
       47|         mkDerivationSimple overrideAttrs args;
         |         ^
       48|

   … while calling 'mkDerivationSimple'

     at /git/pr/eiwd/init/pkgs/stdenv/generic/make-derivation.nix:81:1:

       80| #   Explanation about derivations in general
       81| {
         | ^
       82|

   … from call site

     at /git/pr/eiwd/init/pkgs/stdenv/generic/make-derivation.nix:496:1:

      495|
      496| lib.extendDerivation
         | ^
      497|   validity.handled

   … while calling 'extendDerivation'

     at /git/pr/eiwd/init/lib/customisation.nix:197:43:

      196|      the derivation itself and check a given condition when evaluating. */
      197|   extendDerivation = condition: passthru: drv:
         |                                           ^
      198|     let

   … from call site

     at /git/pr/eiwd/init/pkgs/stdenv/generic/make-derivation.nix:545:4:

      544|    passthru)
      545|   (derivation (derivationArg // lib.optionalAttrs envIsExportable checkedEnv));
         |    ^
      546|

   … while calling anonymous lambda

     at /builtin/derivation.nix:5:1: (source not available)

   … from call site

     at /git/pr/eiwd/init/pkgs/by-name/ei/eiwd/package.nix:28:8:

       27|     "man"
       28|   ] ++ lib.optionals finalAttrs.finalPackage.doCheck [
         |        ^
       29|     "test"

   … while calling 'optionals'

     at /git/pr/eiwd/init/lib/lists.nix:375:5:

      374|     # List to return if condition is true
      375|     elems: if cond then elems else [];
         |     ^
      376|

   error: infinite recursion encountered

   at «none»:0: (source not available)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think outputs is extra-strict because technically you could have insane things like

outputs = [ "doCheck" ];

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words, finalAttrs.finalPackage is strict in outputs, because the attrnames of outputs become attrnames of finalPackage, and Nix attrsets are strict in their attrnames (lazy only in their attrvalues).

So outputs can't depend on finalAttrs.

"test"
];

postUnpack = ''
patchShebangs .
'';

nativeBuildInputs = [
autoreconfHook
pkg-config
] ++ lib.optionals enableManpages [
docutils # only for the man pages
];

buildInputs = [ ];
This conversation was marked as resolved.
Show resolved Hide resolved

checkInputs = [
python3Packages.python
(lib.getBin openssl)
];

configureFlags = [
"--disable-dbus"
] ++ lib.optionals (!enableManpages) [
"--disable-manual-pages"
];

enableParallelBuilding = true;

# override this to false if you don't want to build python3
doCheck = stdenv.hostPlatform == stdenv.buildPlatform;

# prevent the `install-data-local` Makefile rule from running;
# all it does is attempt to `mkdir` the `localstatedir`.
preInstall = ''
mkdir install-data-local
substituteInPlace Makefile --replace \
'$(MKDIR_P) -m 700 $(DESTDIR)$(daemon_storagedir)' \
'true'
'';

postInstall = ''
mkdir -p $doc/share/doc
cp -a doc $doc/share/doc/iwd
cp -a README AUTHORS TODO $doc/share/doc/iwd
'' + lib.optionalString finalAttrs.doCheck ''
mkdir -p $test/bin
cp -a test/* $test/bin/
'';

meta = with lib; {
homepage = "https://github.com/illiliti/eiwd/";
description = "Fork of iwd (wifi daemon) which does not require dbus";
license = licenses.lgpl21Plus;
platforms = platforms.linux;
};
})