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

nnn: Fix configuration file #80878

Merged
merged 1 commit into from Apr 10, 2020
Merged

nnn: Fix configuration file #80878

merged 1 commit into from Apr 10, 2020

Conversation

MilesBreslin
Copy link
Member

@MilesBreslin MilesBreslin commented Feb 23, 2020

Motivation for this change

nnn configuration is currently broken and has been since v2.1

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@aanderse
Copy link
Member

@filalex77 are you able to test and approve this so I can merge?

@MilesBreslin thanks for the contribution, sorry for the delay. If we don't hear anything back in a day or two ping me and I can test+merge.

@MilesBreslin
Copy link
Member Author

@aanderse

@aanderse
Copy link
Member

aanderse commented Apr 2, 2020

@MilesBreslin this package doesn't appear broken to me on master:

~/nixpkgs> git rev-parse HEAD                                                                                                                                                                       
63f8e22dd8ef523b656bcddb9ad3a115c952f79c
~/nixpkgs> nix-build -A nnn                                                                                                                                                                         
these paths will be fetched (0.05 MiB download, 0.11 MiB unpacked):
  /nix/store/6p1apzacn2q1654r2mj8i6h1zd5vhvjz-nnn-3.0
copying path '/nix/store/6p1apzacn2q1654r2mj8i6h1zd5vhvjz-nnn-3.0' from 'https://cache.nixos.org'...
/nix/store/6p1apzacn2q1654r2mj8i6h1zd5vhvjz-nnn-3.0

@MilesBreslin
Copy link
Member Author

@aanderse There is a derivation override that allows for configuration. This configuration is done via a header file compiled into the executable. The package itself is not broken on master, but the configuration via this previously available method is and has been since v2.1, when nnn changed its repository layout. My commit changes the location that the config attribute adds the header file prior to building to the location that works with v2.1+.

To show a test case, here is a nix statement which will evalutate to a derivation. Stick it in a nix-shell, nix-build or whatever, but this includes 2 versions, my version and a recent master branch. Change the pkgs statement to reflect which one you are building. This uses my configuration for nnn, which sets k to down and l to up. The current master branch ignores the configuration and will compile successfully, but my commit will use the given config file and apply it to the application.

let
    pkgs = import (builtins.fetchTarball pullRequest) {};
    pullRequest = {
        url="https://github.com/MilesBreslin/nixpkgs/archive/7fae3b1ca80e844adfddee837f681916dec90811.tar.gz";
        sha256="00zv7qic9y66wrrgh7w2qnfhck7m68jsl4dw0733cp28q8h7r501";
    };
    master = {
        url="https://github.com/nixos/nixpkgs/archive/f0959a7b0c4d9e9b51aa7e7ea32615468341ddbd.tar.gz";
        sha256="0v3i6g0yln9jfr9ymqmbh470xk1qila6xjac5l2c4qq9mm2nnc6j";
    }; 
    conf = builtins.readFile (pkgs.fetchurl {
        url="https://gist.github.com/MilesBreslin/2881e1551583073388c478bfb9981e3e/raw/49837f2b29f3a084a4d3d403d67e81555dfb7d1c/config.h";
        sha256="0cjx5vwgx9bs9z3ms2wwrhj3dnpqyyvbqck9a8pkshq7jlspizlr";
    });
in pkgs.nnn.override {inherit conf;}

@aanderse
Copy link
Member

aanderse commented Apr 5, 2020

@MilesBreslin thanks for sharing that. So I checked out your branch, downloaded your example config.h, and then ran as follows:

~/nixpkgs> git branch                                                                                                                                                                               
* (HEAD detached at MilesBreslin/nnn_config)
~/nixpkgs> nix-build -E 'with import ~/nixpkgs {}; nnn.override { conf = "/home/aaron/config.h"; }'
...
src/nnn.c: In function 'setup_config':
src/nnn.c:6317:2: error: unknown type name 'bool'
 6317 |  bool xdg = FALSE;
      |  ^~~~
src/nnn.c:6317:13: error: 'FALSE' undeclared (first use in this function)
 6317 |  bool xdg = FALSE;
      |             ^~~~~
src/nnn.c:6335:9: error: 'TRUE' undeclared (first use in this function)
 6335 |   xdg = TRUE;
      |         ^~~~
src/nnn.c: At top level:
src/nnn.c:6410:8: error: unknown type name 'bool'
 6410 | static bool set_tmp_path(void)
      |        ^~~~

Seems like some c++ to c type errors. I assume I'm doing something obviously wrong... care to point it out? Thanks!

@MilesBreslin
Copy link
Member Author

@aanderse You're missing the builtins.readFile above. The package requires a string then it converts that to a file, then copies it to it's place.

Reguardless, that shows my commit is working :)

Copy link
Member

@aanderse aanderse left a comment

Choose a reason for hiding this comment

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

@MilesBreslin I agree. Thanks for the detailed explanation and fix! 👍

@aanderse
Copy link
Member

@GrahamcOfBorg build nnn

@aanderse aanderse merged commit 276a27b into NixOS:master Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants