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

Cannot add external emacs packages in pkgs directory #339

Closed
codygman opened this issue Jul 10, 2021 · 2 comments
Closed

Cannot add external emacs packages in pkgs directory #339

codygman opened this issue Jul 10, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@codygman
Copy link
Contributor

codygman commented Jul 10, 2021

I think this might mean that #318 did not fix the issue. Feel free to skip to the reproduction steps below which should be copy pastable.

Expected Behavior

❯ flk tower switch
warning: Git tree '/home/cody/hci' is dirty
building the system configuration...
warning: Git tree '/home/cody/hci' is dirty
#### no error

Current Behavior

flk tower switch --show-trace Log
hci  move-to-devos 「📁 」  ⎔ took 9s 
❯ git log --oneline -n1
00d0e9a (HEAD -> move-to-devos, origin/move-to-devos) add external emacs package apheleia-mode

hci  move-to-devos 「𝚫 ✔ 📁 」  ⎔ took 6s 
❯ flk tower switch --show-trace
[sudo] password for cody: 
building the system configuration...
error: undefined variable 'apheleia-mode'

       at /nix/store/p3c67vcl3c5swdf1maxrw4s2cyvylb43-source/users/profiles/emacs/emacs-packages.nix:2:3:

            1| epkgs: with epkgs; [
            2|   apheleia-mode
             |   ^
            3|   f

       … while evaluating the attribute 'explicitRequires' of the derivation 'emacs-packages-deps'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/pkgs/build-support/trivial-builders.nix:7:7:

            6|     stdenv.mkDerivation ({
            7|       name = lib.strings.sanitizeDerivationName name;
             |       ^
            8|       inherit buildCommand;

       … while evaluating the attribute 'deps' of the derivation 'emacs-with-packages-27.1'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/pkgs/build-support/trivial-builders.nix:7:7:

            6|     stdenv.mkDerivation ({
            7|       name = lib.strings.sanitizeDerivationName name;
             |       ^
            8|       inherit buildCommand;

       … while evaluating the attribute 'passAsFile' of the derivation 'home-manager-path'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/pkgs/build-support/trivial-builders.nix:7:7:

            6|     stdenv.mkDerivation ({
            7|       name = lib.strings.sanitizeDerivationName name;
             |       ^
            8|       inherit buildCommand;

       … while evaluating the attribute 'passAsFile' of the derivation 'user-environment'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/pkgs/build-support/trivial-builders.nix:7:7:

            6|     stdenv.mkDerivation ({
            7|       name = lib.strings.sanitizeDerivationName name;
             |       ^
            8|       inherit buildCommand;

       … while evaluating 'check'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/types.nix:345:15:

          344|       name = "path";
          345|       check = x: isCoercibleToString x && builtins.substring 0 1 (toString x) == "/";
             |               ^
          346|       merge = mergeEqualOption;

       … from call site

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:546:22:

          545|       if isDefined then
          546|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                      ^
          547|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating anonymous lambda

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:546:17:

          545|       if isDefined then
          546|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                 ^
          547|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … from call site

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:546:12:

          545|       if isDefined then
          546|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |            ^
          547|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:544:5:

          543|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          544|     mergedValue =
             |     ^
          545|       if isDefined then

       … while evaluating the option `environment.etc.profiles/per-user/cody.source':
       … while evaluating the attribute 'value'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:512:9:

          511|     in warnDeprecation opt //
          512|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          513|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:139:72:

          138|           # For definitions that have an associated option
          139|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          140|

       … from call site

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/attrsets.nix:297:20:
          296|               then recurse (path ++ [name]) value
          297|               else f (path ++ [name]) value;
             |                    ^
          298|         in mapAttrs g set;

       … while evaluating 'g'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/attrsets.nix:294:19:
          293|           g =
          294|             name: value:
             |                   ^
          295|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'source'

       … while evaluating anonymous lambda

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/nixos/modules/system/etc/etc.nix:20:20:

           19|     /* !!! Use toXML. */
           20|     sources = map (x: x.source) etc';
             |                    ^
           21|     targets = map (x: x.target) etc';

       … from call site

       … while evaluating the attribute 'sources' of the derivation 'etc'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/nixos/modules/system/etc/etc.nix:12:5:

           11|   etc = pkgs.stdenvNoCC.mkDerivation {
           12|     name = "etc";
             |     ^
           13|

       … while evaluating the attribute 'value'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:379:44:

          378|       defnsByName' = byName "config" (module: value:
          379|           [{ inherit (module) file; inherit value; }]
             |                                            ^
          380|         ) configs;

       … while evaluating 'dischargeProperties'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:596:25:

          595|   */
          596|   dischargeProperties = def:
             |                         ^
          597|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:525:137:
          524|         defs' = concatMap (m:
          525|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          526|         ) defs;

       … while evaluating definitions from `/nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/nixos/modules/system/etc/etc.nix':

       … while evaluating anonymous lambda

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:524:28:

          523|         # Process mkMerge and mkIf properties.
          524|         defs' = concatMap (m:
             |                            ^
          525|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … from call site

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:524:17:

          523|         # Process mkMerge and mkIf properties.
          524|         defs' = concatMap (m:
             |                 ^
          525|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating the attribute 'values'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:637:7:

          636|     in {
          637|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          638|       inherit highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:538:9:

          537|       in {
          538|         values = defs''';
             |         ^
          539|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:544:5:

          543|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          544|     mergedValue =
             |     ^
          545|       if isDefined then

       … while evaluating the option `system.activationScripts.etc.text':

       … while evaluating the attribute 'value'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:512:9:

          511|     in warnDeprecation opt //
          512|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          513|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/modules.nix:139:72:

          138|           # For definitions that have an associated option
          139|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          140|

       … from call site

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/attrsets.nix:297:20:
          296|               then recurse (path ++ [name]) value
          297|               else f (path ++ [name]) value;
             |                    ^
          298|         in mapAttrs g set;

       … while evaluating 'g'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/attrsets.nix:294:19:
          293|           g =
          294|             name: value:
             |                   ^
          295|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'text'

       … while evaluating the attribute 'text'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/nixos/modules/system/activation/activation-script.nix:9:5:

            8|   addAttributeName = mapAttrs (a: v: v // {
            9|     text = ''
             |     ^
           10|       #### Activation script snippet ${a}:

       … while evaluating 'id'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/trivial.nix:14:5:

           13|     # The value to return
           14|     x: x;
             |     ^
           15|

       … from call site

       … while evaluating 'textClosureMap'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/lib/strings-with-deps.nix:75:35:

           74|
           75|   textClosureMap = f: predefined: names:
             |                                   ^
           76|     concatStringsSep "\n" (map f (textClosureList predefined names));

       … from call site

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/nixos/modules/system/activation/activation-script.nix:101:18:

          100|                 withHeadlines = addAttributeName set';
          101|               in textClosureMap id (withHeadlines) (attrNames withHeadlines)
             |                  ^
          102|             }

       … while evaluating the attribute 'system.activationScripts.script'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/nixos/modules/system/activation/activation-script.nix:80:9:

           79|       apply = set: {
           80|         script =
             |         ^
           81|           ''

       … while evaluating the attribute 'activationScript' of the derivation 'nixos-system-tower-21.05.20210315.266dc8c'

       at /nix/store/4dqrf3ly31g9ypgm89rn7b1p06vddll6-source/nixos/modules/system/activation/top-level.nix:95:5:

           94|   baseSystem = pkgs.stdenvNoCC.mkDerivation {
           95|     name = "nixos-system-${config.system.name}-${config.system.nixos.label}";
             |     ^
           96|     preferLocalBuild = true;

Possible Solution

Upstream all of my external emacs packages I use?

Do a deep dive on why this is happening and fix it?

Steps to Reproduce

Note that I also encounter the issue with direnv/devshell not working right somehow in reproduction steps below. I'm not sure if this is related, and if it is how flk tower switch still works anyway.

hci  move-to-devos 「📁 」  ⎔ 
❯ cd /tmp
direnv: unloading

/tmp  ⎔ 
❯ git clone https://github.com/codygman/hci.git
Cloning into 'hci'...
remote: Enumerating objects: 7868, done.
remote: Counting objects: 100% (5098/5098), done.
remote: Compressing objects: 100% (2041/2041), done.
remote: Total 7868 (delta 2670), reused 5094 (delta 2668), pack-reused 2770
Receiving objects: 100% (7868/7868), 1.84 MiB | 5.73 MiB/s, done.
Resolving deltas: 100% (4362/4362), done.

/tmp  ⎔ 
❯ cd hci

hci  master  ⎔ 
❯ git checkout move-to-devos
Branch 'move-to-devos' set up to track remote branch 'move-to-devos' from 'origin'.
Switched to a new branch 'move-to-devos'
direnv: error /tmp/hci/.envrc is blocked. Run `direnv allow` to approve its content

hci  move-to-devos  ⎔ 
❯ direnv allow
direnv: loading /tmp/hci/.envrc
direnv: using flake
error: 'print-dev-env' is not a recognised command
Try '/nix/store/rf97ba1qzrh07305n027jb91v3p1n4qi-nix-2.3.12/bin/nix --help' for more information.
error: 'flake' is not a recognised command
Try '/nix/store/rf97ba1qzrh07305n027jb91v3p1n4qi-nix-2.3.12/bin/nix --help' for more information.
direnv: renewed cache
direnv: export ~XDG_DATA_DIRS

hci  move-to-devos  ⎔ 
❯ git log --oneline -n1
00d0e9a (HEAD -> move-to-devos, origin/move-to-devos) add external emacs package apheleia-mode

hci  move-to-devos  ⎔ 
❯ flk tower switch
[sudo] password for cody: 
building the system configuration...
error: undefined variable 'apheleia-mode'

       at /nix/store/p3c67vcl3c5swdf1maxrw4s2cyvylb43-source/users/profiles/emacs/emacs-packages.nix:2:3:

            1| epkgs: with epkgs; [
            2|   apheleia-mode
             |   ^
            3|   f
(use '--show-trace' to show detailed location information)

Context

I'm trying to move to the latest version of devos to take advantage of #279 and to not diverge too much.

I've also taken this opportunity to start completely from scratch to produce my new version of devos based only on core. If you clone that and try to build it, you'll get the error also.

Your Environment

https://github.com/codygman/hci/tree/move-to-devos @ 00d0e9a68f2923c3c4fe76ee11e6b91793e355aa

@codygman codygman added the bug Something isn't working label Jul 10, 2021
@codygman
Copy link
Contributor Author

Actually it looks like I wrongly assumed that master had that change from #318.

I suppose I'll try building with develop since it looks like it has recent activity and uses digga develop.

@codygman
Copy link
Contributor Author

codygman commented Jul 10, 2021

I tried using the develop branch at fe73d2a and got the same error. The relevant pieces are:

pkgs.nix:

final: prev: {
  # keep sources this first
  sources = prev.callPackage (import ./_sources/generated.nix) { };
  # then, call packages with `final.callPackage`
  apheleia-mode = final.callPackage ./applications/editors/emacs/elisp-packages/apheleia-mode { };
}

./applications/editors/emacs/elisp-packages/apheleia-mode.nix :

{ pkgs, lib, fetchFromGitHub }:

pkgs.emacsPackages.trivialBuild {
    pname = "apheleia-mode";
    packageRequires = [  ];
    src = fetchFromGitHub { # TODO treat this as a flake input
          owner = "raxod502";
          repo = "apheleia";
          rev = "876078f473cabd14129eb78d610ef2cc46ead4f1";
          sha256 = "actIWr8fXYfPWRdMTmQFvn5PiJVRFIec7cwObjsn5lY=";
    };

    # INCOMPLETE
    meta = with lib; {
      description = "to do";
      license = licenses.gpl2Plus;
      maintainers = with maintainers; [ codygman ];
      platforms = platforms.all;
    };
}

I also double checked that my flake.nix had the developed version of digga and it does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants