Re: [Nix-dev] Generating nixos-compatible binaries? And bootstrapped packages.

2016-08-25 Thread Nick Sabalausky

On 08/25/2016 04:12 PM, Roland Koebler wrote:

Hi,


- ...Is there a way binaries can be built on non-nixos linux so that they
WILL work out-of-the-box on nixos?

maybe the following articles help:
http://anderspapitto.com/posts/2015-02-28-deb-installation-nixos.html
https://sandervanderburg.blogspot.de/2015/10/deploying-prebuilt-binary-software-with.html

Remember that you can install Nix on many Linux distributions, and don't
need to run NixOS to have Nix (see https://nixos.org/nix/). I'm running
Nix on Debian here.



Thanks. That first link I'd come across before and had trouble grokking, 
but I'll take a closer look again (at both), especially now that I think 
I have a better understanding of patchelf.



Extra side question: AIUI, Binaries built on nixos do generally work
out-of-the-box on OTHER nixos installations, right?

No:
If you *only* copy a binary from one NixOS to another, it only works, if
the 2nd NixOS coincidentally has installed all dependencies of the binary.
And it may break by the next update.

If you copy the closure of the package (=the package itself + all
dependencies; this will probably be a bunch of /nix/store/*-paths),
it works. See: man nix-copy-closure



Ahh, ok I see now. And it sounds like these closures are involved in how 
nix's binary caches are able to work successfully then?


___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Generating nixos-compatible binaries? And bootstrapped packages.

2016-08-25 Thread Nick Sabalausky

On 08/25/2016 03:33 PM, Bjørn Forsman wrote:

On 25 August 2016 at 21:08, Nick Sabalausky

Any downsides to setting the RPATH that way? By just setting it to
/run/current-system/sw/lib?


Both are hacks :-) The first method breaks when you garbage collect
the system and the paths embedded into the binary are removed. The
second method (may) break when you update the system so that the links
in /run/current-system/sw/lib/... point to different and incompatible
libraries.



Ok, I see.

Now, I assume using patchelf probably isn't recommended or suitable for 
packages in nixpkgs (unless maybe it's something closed-source?).


But what if a nix expression uses it as an intermediary build step on a 
tool downloaded as used AS part of the build process, but then simply 
discarded? Such as bootstrapping a compiler by downloading an older 
pre-built binary provided on the compiler's official release page, 
patchelf it, and use that to bootstrap the compiler being built.


Would that be non-hacky enough to be acceptable for a nixpkgs pull request?

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Generating nixos-compatible binaries? And bootstrapped packages.

2016-08-25 Thread Nick Sabalausky

On 08/25/2016 01:52 PM, Bjørn Forsman wrote:

On 25 August 2016 at 18:54, Nick Sabalausky
<bus_nixos_l...@semitwist.com> wrote:

On 08/24/2016 01:29 PM, stewart mackenzie wrote:

Have a look at patchelf


Ok, so according to <https://nixos.org/patchelf.html>, what I do is:

% patchelf --set-interpreter PATH_TO_LOADER program_binary
% patchelf --set-rpath LINKER_SEARCH_PATHS program_binary

But how do I know what my paths for PATH_TO_LOADER and LINKER_SEARCH_PATHS
are?


A place to start would be to look at the output of

   readelf -a $MYPROG | grep "NEEDED\|interpreter

For instance,

   $ readelf -a $(which ls) | grep "NEEDED\|interpreter"
   [Requesting program interpreter:
/nix/store/dad9vxniabwzidvvxfsfj6vb0xncsbbb-glibc-2.23/lib/ld-linux-x86-64.so.2]
0x0001 (NEEDED) Shared library: [libacl.so.1]
0x0001 (NEEDED) Shared library: [librt.so.1]
0x0001 (NEEDED) Shared library: [libpthread.so.0]
0x0001 (NEEDED) Shared library: [libc.so.6]

Then try with:

   PATH_TO_LOADER=$(nix-build -A glibc ''
--no-out-link)/lib/ld-linux-x86-64.so.2

(Assuming 64-bit program.)

When the interpreter is in place, I think you can use 'ldd' to figure
out the recursive set of libraries it needs. If not, one can do the
trial and error method by trying to run the program and seeing what it
says is missing.

LINKER_SEARCH_PATHS can be built like this:

   $ for p in acl glibc; do echo $(nix-build -A $p ''
--no-out-link)/lib; done | tr '\n' ':'
   
/nix/store/mq5a5h2p9wwwbpv0i7lmjzw2a503ph22-acl-2.2.52/lib:/nix/store/gwl3ppqj4i730nhd4f50ncl5jc4n97ks-glibc-2.23/lib:

   (TODO: strip the trailing colon)

Best regards,
Bjørn Forsman



Doing LINKER_SEARCH_PATHS like that, it left the executable complaining 
about missing libstdc++, which I had trouble finding until I looked into 
the '/run/current-profile/sw/lib' path Tomasz mentioned and realized I 
could find the paths by checking the symlinks inside there (Although for 
me it was '/run/current-system/...'. I don't have a 
'/run/current-profile/...')


Anyway, I tried doing this, which seems to work:

% PATH_TO_INTERP=$(nix-build -A glibc '' 
--no-out-link)/lib/ld-linux-x86-64.so.2

% patchelf --set-interpreter $PATH_TO_INTERP path/to/program_binary
% patchelf --set-rpath /run/current-system/sw/lib path/to/program_binary
% path/to/program_binary

Any downsides to setting the RPATH that way? By just setting it to 
/run/current-system/sw/lib?


___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] Generating nixos-compatible binaries? And bootstrapped packages.

2016-08-25 Thread Nick Sabalausky

On 08/24/2016 01:29 PM, stewart mackenzie wrote:

Have a look at patchelf



Ok, so according to , what I do is:

% patchelf --set-interpreter PATH_TO_LOADER program_binary
% patchelf --set-rpath LINKER_SEARCH_PATHS program_binary

But how do I know what my paths for PATH_TO_LOADER and 
LINKER_SEARCH_PATHS are?


___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] How to install specific version of a package?

2016-08-12 Thread Nick Sabalausky

On 08/12/2016 02:58 AM, Roger Qiu wrote:

Nix is based on content addressing. To install a specific version of a
package, just pick a version, fix the content address, and install it!
[...]
or if a previous (or newer) revision of nixpkgs had the
package, then you load that package set and point to a package there to
install it.



Can you point me to documentation for that? I only know of installing 
via "environment.systemPackages", enabling a service, or "nix-env -i ...".


I did just now try following this:

https://nixos.org/nixpkgs/manual/#sec-modify-via-packageOverrides

And created a ~/.nixpkgs/config.nix containing (just to try things out) 
this:


{
packageOverrides = pkgs: rec {
firefox = pkgs.firefox.override {
common.version = "33.0";
};
};
}

But then I just get:

$ nix-env -i firefox
error: attribute ‘override’ missing, at /home/nick/.nixpkgs/config.nix:3:13

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] Two declarative ways to install a package?

2016-08-11 Thread Nick Sabalausky
I'm noticing that when installing packages declaratively via 
configuration.nix and nixos-rebuild, some packages are install one way, 
but others are installed another way. For example:


# Some packages are installed via environment.systemPackages
environment.systemPackages = with pkgs; [
  wget firefox thunderbird git
];

# Others are installed via *.enabled = true;
services.openssh.enable = true;
services.printing.enable = true;
services.xserver.enable = true;
services.xserver.displayManager.kdm.enable = true;
services.xserver.desktopManager.kde4.enable = true;
services.vmwareGuest.enable = true;

What exactly is the difference? Is there any more nuance to it than 
"Services are installed one way, non-services are installed the other way"?


How do I know which way to install a given package? Especially if I'm 
not sure offhand whether a given package involves a service component.


Can all packages be installed wither way? Are all packages ONLY one way 
or the other?


How can I find what packages are available via one method or the other?
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] How to install specific version of a package?

2016-08-11 Thread Nick Sabalausky
In general, how do you install a specific version of a package? It seems 
that by default it will install the latest available version like other 
distros, but for the most part installing "packagename-1.2.3"/etc 
doesn't appear to work.


One of the biggest killer features of NixOS for me is the ability to 
sanely handle and manage different versions of the same package in 
different environments. But that ability seems severely crippled if I 
can't actually *install* any versions other than "latest" and "already 
previously installed on this machine while it *was* the latest, and 
hasn't yet been garbage collected".

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] A few beginner issues

2016-07-30 Thread Nick Sabalausky

On 07/30/2016 02:01 AM, Daniel Hlynskyi wrote:

Try setting services.xserver.resolutions. If that doesn't workflow, then it
is probably a bug



Ahh, that worked, thanks. I added:

services.xserver.resolutions = pkgs.lib.mkForce [ { x = 800; y = 600; } ];


___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] A few beginner issues

2016-07-29 Thread Nick Sabalausky

On 07/29/2016 11:14 PM, Peter Hoeg wrote:

2. When I'm in KDE4 on NixOS, I can change the display resolution,
but the
change doesn't persist across a reboot. Why is this? What is the
correct way


Could you try with kde5 instead of kde4? KDE5 is getting all the love
these days so maybe a bug snuck in there?



Ok, just tried now...

Gotta say, I'm thrilled how painless it was to switch from KDE4 to KDE5 
and back again. Exactly the sort of reason I've been unsatisfied with 
other distros and so intrigued by NixOS. Just changed the 
"...kde4.enable = true"/"...kdm.enable = true" to "...kde5.enable = 
true"/"...sddm.enable = true" and "nixos-rebuild switch && reboot". And 
just reverse the changes (or select old config from boot menu) to undo 
it, and it just works :) Really like the idea of being able to try 
things out without as much risk of messing things up or being stuck with 
the changes.


In KDE5/SDDM, my resolution settings changes DO persist, although only 
after the login screen. Which I suppose makes sense since I was changing 
the setting AS a logged in user. Seems as though with KDE4/KDM it just 
isn't loading any per-user resolution setting upon login (or maybe isn't 
saving it).


Is there a NixOS way to set a default resolution (presumably in 
configuration.nix) that would apply to the login screen? Or would it 
just be though whatever the display manager's (or X's) normal approach 
for doing that as with any other linux distro?



___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] A few beginner issues

2016-07-29 Thread Nick Sabalausky

On 07/29/2016 11:09 PM, Nick Sabalausky wrote:

On 07/29/2016 06:50 PM, Bjørn Forsman wrote:

   stage-1-init: modprobe: ERROR: could not insert 'vboxsf': No such
device


I guess that means the virtualbox driver doesn't work with vmware.
(Two competing VM technologies, no surprise really.)

I've never used vmware on Linux. I use VirtualBox. NixOS distributes
OVA files that you can import straight into VirtualBox. I think that's
a very easy way to get started.



/facepalm

Clearly I can't read ;)



BTW, I did notice the prebuilt virtual machines, ready for importing, 
which is very nice, but I wanted to try installing it myself just for 
the learning experience. If/When I install it on a physical machine, I 
won't necessarily be able to rely on a prebuilt image. It's the first 
time I've installed any Linux without a GUI installer, but with the 
NixOS manual, it turned out to be easy enough.


I'll see what I can figure out about installing guest additions from 
vmware. I'm noticing a vmware-guest module on github. Should be simple 
enough...


___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] A few beginner issues

2016-07-29 Thread Nick Sabalausky

On 07/29/2016 06:50 PM, Bjørn Forsman wrote:

   stage-1-init: modprobe: ERROR: could not insert 'vboxsf': No such device


I guess that means the virtualbox driver doesn't work with vmware.
(Two competing VM technologies, no surprise really.)

I've never used vmware on Linux. I use VirtualBox. NixOS distributes
OVA files that you can import straight into VirtualBox. I think that's
a very easy way to get started.



/facepalm

Clearly I can't read ;)


2. When I'm in KDE4 on NixOS, I can change the display resolution, but the
change doesn't persist across a reboot. Why is this? What is the correct way
to make it persist? Haven't had this happen in other distros.


Are you sure you're booting from your installation on disk and not the
Live CD? I don't use KDE, but at least in GNOME the screen resolution
is persisted (no need for NixOS option for that). I'd be surprised if
it didn't work like that on KDE too.



Yes, I'm certain. The GRUB boot menu is different from when I was 
booting the live disc, and the boot menu accumulates my new 
configurations when I do I configuration rebuild. Changes to my 
/etc/nixos/configuration.nix file persist. And I've made certain to 
disconnect the ISO from the virtual machine BEFORE booting and checked 
it's still disconnected after booting (and went back and double-checked 
that again just now).




3. I added "firefox" (minus quotes) to the environment.systemPackages list
in configuration.nix, did rebuild/switch, and it's now installed and works,
BUT it installed Firefox Nightly instead of a firefox release. How would I
go about installing a release instead of nightly?


I think NixOS only ships "nightly" due to licensing or branding rights
or something. Others may fill inn here.


4. When looking up the firefox packages, I noticed a "firefox-unwrapped".
What is that and how does it differ from the package "firefox"?


The -unwrapped version doesn't know about plugins. I guess most people
will want the normal "firefox" package.



Interesting, thanks.


___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] A few beginner issues

2016-07-29 Thread Nick Sabalausky
I'm new to NixOS (coming from various more traditionally-designed 
distros, like Debian and Manjaro), and trying to learn by working with 
it in a WMWare instance. I've gotten it installed into the vm instance 
via the live disc's gparted and "nixos-generate-config" and 
"nixos-install", mostly going by what's here:


https://nixos.org/nixos/manual/index.html#ch-installation

And I'm now able to boot into the newly installed, umm, installation 
running KDE4.


Now that I'm trying it out, there's a few things I'm having trouble 
figuring out, and was hoping someone could help me out with these 
examples so that I can have a better idea of how to work with NixOS.


1. I'm having trouble getting vmware guest additions to work. I followed 
the instruction here...


  https://nixos.org/wiki/Installing_NixOS_in_a_VirtualBox_guest

...to add the following line to my /etc/nixos/configuration.nix...

  virtualisation.virtualbox.guest.enable = true;

...but after I "nixos-rebuild switch" and reboot, the display manager no 
longer starts and dmesg includes this suspicious looking line:


  stage-1-init: modprobe: ERROR: could not insert 'vboxsf': No such device

I didn't need to add that line to configuration.nix before the original 
"nixos-install", did I? Or is something else going on here?


Luckily, I can just reboot back to the old working configuration, which 
is an *awesome* example of why I'm determined to learn my way around 
NixOS. But it would be nice to understand how to get these virtual guest 
services working.


2. When I'm in KDE4 on NixOS, I can change the display resolution, but 
the change doesn't persist across a reboot. Why is this? What is the 
correct way to make it persist? Haven't had this happen in other distros.


3. I added "firefox" (minus quotes) to the environment.systemPackages 
list in configuration.nix, did rebuild/switch, and it's now installed 
and works, BUT it installed Firefox Nightly instead of a firefox 
release. How would I go about installing a release instead of nightly?


4. When looking up the firefox packages, I noticed a 
"firefox-unwrapped". What is that and how does it differ from the 
package "firefox"?

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev