[Nix-dev] Hi nix developers!

Nicolas Pierron nicolas.b.pierron at gmail.com
Fri Apr 3 11:57:02 CEST 2009


Hi Tony,

On Fri, Apr 3, 2009 at 10:31, Tony White <tonywhite100 at googlemail.com> wrote:
> So, I decided to try to copy the ipw2200 firmware expression in
> nixpkgs to build a new package :
>
> I've got /etc/nixos/nixpkgs/pkgs/os-specific/linux/firmware/ipw2100
>
> Then I've added :
>
>  ipw2100fw = import ../os-specific/linux/firmware/ipw2100 {
>    inherit fetchurl stdenv;
>  };
>
> Right above the ipw2200fw entry in
> /etc/nixos/nixpkgs/pkgs/top-level/all-packages.nix
>
> When I go to do :
>
> nix-build /etc/nixos/nixpkgs/pkgs/top-level/all-packages.nix -A ipw2100fw
>
> I get an error complaining about the archive extraction not creating a
> folder, Which is true because unlike the ipw2200 firmware archive, The
> firmware files are'nt inside a folder inside the archive, They're just
> slapped straight into the archive.

Creating multiple files inside the nix/store generates your error
because one derivation correspond to one file inside the /nix/store.
The source of your error is inside the unpackPhase function of
pkgs/stdenv/generic/setup.sh

> So how can I create an expression that will workaround this? Do I need
> to create a builder?

Usually the generic builder can be configure to do what we want by
replacing phases which do not fit our expectations like you have done
with buildPhase and installPhase which are shell scripts evaluated in
a precise order.

What you should do is to use the default builder (so do not override
the builder attribute) and inside your nix expression, add the
following line:

  unpackPhase = "
    ensureDir $src
    cd $src
    tar xvf $srcs
  ";

> Does it have anything to do with ensureDir $out?

No, ensureDir is similar to "mkdir -p".



> Would it be possible to tell me how the ipw2200fw package works in
> relation to what I know because in LSB type Linux, Firmware is
> searched for in /lib/firmware by default.
> Is the default kernel firmware location changed at all when the kernel
> is configured before compliation?

The problem with usual directory like /bin, /usr, /lib, etc ... is
that you cannot change their states in one atomic operation.  So NixOS
cannot rely on these by default.  One the other hand you get the same
scheme inside /var/run/current-system/sw directory.  This directory
corresponds to the aggregation of almost all derivations build by
NixOS.

So, to answer your question about how you should place your firmware,
I suggest you to have a look at
https://svn.nixos.org/repos/nix/configurations/trunk/hardware/network/Intel2200BG.nix
which is exactly what you should put inside your configuration.nix to
add your network card firmware.

> What also puzzles me and probably because I'm still missing something, Is that :
>
> nix-env -f /etc/nixos/nixpkgs/pkgs/top-level/all-packages.nix -i ipw2100fw

Have you tried with "ipw2100-fw" as the name contain a dash?


> Once I've got the firmware loading at boot, I'm going to need to
> create /etc/wpa_supplicant.conf (Probably not in /etc.)
> I use a wpa encrypted wireless connection.
> I have wpa_supplicant installed using :
>
> nix-env -f /etc/nixos/nixpkgs/pkgs/top-level/all-packages.nix -i wpa_supplicant
>
> So any clues as to how to go about doing that would be greatly appreciated.

I am sorry, I've never investigate that before, So I can't help you on
this point.


> How do I add mem=1024M to grub's menu.lst? (Named
> /boot/nixos-grub-config in Nixos.)
> Is it possible without editing nixos-grub-config and setting it as
> default for all further kernel entries?

The menu.lst file is not the one that your are pointing.  The menu.lst
file is contained inside /boot/grub/.  To add the kernel parameter to
each new NixOS entry you have to set the option boot.kernelParams
inside your configuration.nix file.

{
  boot = {
    kernelParams = [
      "selinux=0"
      "apm=on"
      "acpi=on"
      "vga=0x317"
      "console=tty1"
      "splash=verbose"
      "mem=1024M" # The machine suffers from a memory allocation bug
    ];
  };
}


-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
- If you are doing something twice then you should try to do it once.



More information about the nix-dev mailing list