Nixpkgs: Can't install polybar with i3 support using `--arg i3Support`

Created on 19 May 2019  路  22Comments  路  Source: NixOS/nixpkgs

Issue description

Setting the argument i3Support for polybar to true still builds package without i3 support. Perhaps I'm doing something wrong especially since I'm not that experienced with nix package manger, but after reading the manual and many many other related posts I thought this would work.

Steps to reproduce

nix-env --arg i3Support true -i polybar then run polybar -v Result shows polybar not compiled with i3 support.

Technical details

```$ nix-shell -p nix-info --run "nix-info -m"
these paths will be fetched (0.00 MiB download, 0.00 MiB unpacked):
/nix/store/2bayxk1f5nml5lqlc908qs24acipqnz9-nix-info
copying path '/nix/store/2bayxk1f5nml5lqlc908qs24acipqnz9-nix-info' from 'https://cache.nixos.org'...

  • system: "x86_64-linux"
  • host os: Linux 4.19.36-1-MANJARO, Manjaro Linux, noversion
  • multi-user?: no
  • sandbox: yes
  • version: nix-env (Nix) 2.2.2
  • channels(daniel): "nixpkgs-19.09pre178895.9ebc6ad944c"
  • nixpkgs: `/home/daniel/.nix-defexpr/channels/nixpkgs````
stale

Most helpful comment

@danielakhterov I have no idea why --arg is failing
@JonnyHaystack Does it install correctly if you use an overlay instead of editing random files, for example make a file called ~/.config/nixpkgs/overlays/polybar.nix and put in

self: super:
{ polybar = super.polybar.override { i3Support = true; pulseSupport = true; }; }

On a side note this is probably the best way to install an overridden package with nix-env

All 22 comments

You're missing the i3 argument.

By default, i3Support is false and i3 is null. Within the buildInputs expression in the polybar package, there's this:

(if i3Support then i3 else null)

... which means that if i3Support is true, then the value of i3 becomes a build input. However, since i3 is null by default, if you don't specify it when specifying i3Support then the expression above evaluates to null (if true then null else null). This of course leads to a lack of i3 support in polybar.

I can't reproduce this issue, I ran
nix-build --arg i3Support true -A polybar
and then ran `result/bin/polybar -v

polybar 3.3.1

+alsa -curl +i3 -mpd +network(libnl) -pulseaudio +xkeyboard

is this not what is expected?

@emmanuelrosa The reason I didn't override the i3 variable is because of this optional packages-- override the variables ending in 'Support' to enable or disable modules which is written inside the polybar/default.nix However, what should I override i3 with? I'm not really sure what should go there to be honest.

@alexarice The result I got after running that command is error: getting status of '/home/daniel/default.nix': No such file or directory. So, I cd'd into the store for polybar and reran the command which got me this output error: cannot auto-call a function that has an argument without a default value ('cairo')

Edit: @emanueleperuffo I went into the default.nix file for polybar and changed i3Support ? false to i3Support ? true and kept everything else the same. Rebuilding polybar without any options nix-env -i polybar installs with i3. From these results it seems even more so that I shouldn't need to set the i3 ? null variable.

@danielakhterov Sorry, I should have been more clear, I ran the commands from within a clone of nixpkgs. Also for what it's worth I don't see why you should need to set the i3 variable

I'm also finding this a problem. However I am unable to get it working even doing it how @danielakhterov did it (I think).
What I did was:

  1. Edit ~/.nix-defexpr/channels/nixpkgs/pkgs/applications/misc/polybar/default.nix and set i3GapsSupport and pulseSupport to true instead of false
  2. Ran nix-env -i polybar

What happened was:

  • The build seemed to complete successfully
  • But the installation part failed:
[ 94%] Built target polybar
Scanning dependencies of target polybar-msg
[ 95%] Building CXX object bin/CMakeFiles/polybar-msg.dir/ipc.cpp.o
[ 96%] Building CXX object bin/CMakeFiles/polybar-msg.dir/utils/env.cpp.o
[ 97%] Building CXX object bin/CMakeFiles/polybar-msg.dir/utils/file.cpp.o
[ 98%] Building CXX object bin/CMakeFiles/polybar-msg.dir/utils/string.cpp.o
[100%] Linking CXX executable polybar-msg
[100%] Built target polybar-msg
glibPreInstallPhase
installing
install flags: SHELL=/nix/store/x0mlaj4z4ciycaycfwc36l1932mwywfj-bash-4.4-p23/bin/bash gsettingsschemadir=/nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/share/gsettings-schemas/polybar-3.3.1/glib-2.0/schemas/ install
[  5%] Built target xpp
[  8%] Built target i3ipc++
[ 92%] Built target poly
[ 94%] Built target polybar
[100%] Built target polybar-msg
Install the project...
-- Install configuration: "Release"
-- Installing: /nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/share/doc/polybar/config
-- Installing: /nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/share/bash-completion/completions/polybar
-- Installing: /nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/share/zsh/site-functions/_polybar
-- Installing: /nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/share/zsh/site-functions/_polybar_msg
-- Installing: /nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/share/man/man1/polybar.1
-- Installing: /nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/bin/polybar
-- Installing: /nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/bin/polybar-msg
mv: cannot move '/nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/bin/polybar' to '/nix/store/35w2gl3hd5zil1yi6svny6ha23mqlb34-polybar-3.3.1/bin/.polybar-wrapped': No such file or directory
builder for '/nix/store/9igkc9vjj1ybq3iizm5cixj8p82ilkdx-polybar-3.3.1.drv' failed with exit code 1
error: build of '/nix/store/9igkc9vjj1ybq3iizm5cixj8p82ilkdx-polybar-3.3.1.drv' failed

Full output: https://pastebin.com/NCMfBZGq

Not sure what I'm doing wrong

EDIT: I can actually use the binaries just fine if I copy them into my ~/bin, but I'd like to know the proper way to do this

EDIT2: Scratch that. Predictably, it breaks after the next time I run nix-collect-garbage -d

@JonnyHaystack The file I edited was not in my home directory. Here is the full file path:
/nix/store/a9lvdqpdndvx0dw12vlgswcbwbcbfl5m-nixpkgs-19.09pre178895.9ebc6ad944c/nixpkgs/pkgs/applications/misc/polybar Not sure if it matters if you edit this one or the one inside your home directory, but for me nix-env -i polybar installed completely updating the file in nix/store.

@danielakhterov I don't have those files. Maybe because my setup is different. I'm using Nix installed in a proot environment (~/.nix is mounted to /nix) and I have set sandbox = false in ~/.config/nix/nix.conf
I only have folders in /nix/store for packages that are installed or were used to build something that I installed

Hmm, I guess that could be because of those settings. I just installed nix using the default script provided on the website. Maybe try to install polybar, then go to root and find . -name "polybar". At least that's what I did to find that file.

@danielakhterov @JonnyHaystack I don't think editing store files is the correct way to do this. However I just tried the nix-env command you listed and it does seem to not work

I have no idea how I had this working 2 days ago, everything I try now seems to ignore the --arg flag

@alexarice I know you're not supposed to edit those files. I was just testing to to see if nix-env is ignoring the --arg flag or if the polybar nix expression is failing to install with the i3 module.

For me the --arg flag seems be ignored and when I edit the default.nix directly, it builds but fails to install.

@danielakhterov I have no idea why --arg is failing
@JonnyHaystack Does it install correctly if you use an overlay instead of editing random files, for example make a file called ~/.config/nixpkgs/overlays/polybar.nix and put in

self: super:
{ polybar = super.polybar.override { i3Support = true; pulseSupport = true; }; }

On a side note this is probably the best way to install an overridden package with nix-env

@danielakhterov I have no idea why --arg is failing
@JonnyHaystack Does it install correctly if you use an overlay instead of editing random files, for example make a file called ~/.config/nixpkgs/overlays/polybar.nix and put in

self: super:
{ polybar = super.polybar.override { i3Support = true; pulseSupport = true; }; }

On a side note this is probably the best way to install an overridden package with nix-env

Exact same problem :cry:

May I see the build output that either of you get?

@alexrice That worked! Where'd you learn about overlays? I read the manual start to finish several times and never found anything related to that. Still though, no idea why --arg isn't working. Nix just seems to be ignoring it completely.
@JonnyHaystack Here is the output I got after I creating the polybar.nix file. https://pastebin.com/nkwzLRmP

Thanks. No idea what's wrong with mine. Yours seems pretty much the same except it doesn't come up with the complaint that mine gives

@danielakhterov https://nixos.org/nixpkgs/manual/#chap-overlays

@JonnyHaystack you could try nix-store --verify --check-contents but other than that I'm not really sure, you may be able to get more help on IRC

@JonnyHaystack you could try nix-store --verify --check-contents but other than that I'm not really sure, you may be able to get more help on IRC

Showed no errors, and didn't fix the problem

Hi all, I fixed my problem. It was caused by a bug in the version of proot that I was using. I upgraded to a more recent build from their CI server (it isn't in the proot static builds on GitHub), and now it works fine.

Just for reference, if you're using NixOS's configuration.nix (like I was, while searching for solution), you can install polybar with i3 support using:

{ pkgs, ... }: {
  environment.systemPackages = with pkgs;
    let
      polybar = pkgs.polybar.override {
        i3Support = true;
      };
    in
      [
        polybar
        # the rest of your packages
      ];
}

Using overlays also works, although I think it's a bit more complicated.

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grahamc picture grahamc  路  3Comments

ob7 picture ob7  路  3Comments

tomberek picture tomberek  路  3Comments

copumpkin picture copumpkin  路  3Comments

vaibhavsagar picture vaibhavsagar  路  3Comments