Re: [Nix-dev] [NixOS] How to incorporate my Bash script in configuration.nix?

2017-05-10 Thread Strahinja Popovic
Thanks Peter, it did the trick :)

On Wed, May 10, 2017 at 1:18 AM, Peter Hoeg  wrote:

> Hi,
>
>   > The proper way to do this is to set up modaliases
>>
>>   Could you please elaborate further?
>>
>
> the alias in the line below depends on the exact PID and VID of your
> device so you may need to adjust it:
>
>  boot.kernelModules = [ "rt2800usb" ];
>  boot.extraModprobeConfig = ''
>alias usb:v0B05p17E8d*dc*dsc*dp*ic*isc*ip*in* rt2800usb
>install rt2800usb ${pkgs.kmod}/sbin/modprobe --ignore-install rt2800usb
> && echo 0x0B05 0x17E8 >/sys/bus/usb/drivers/rt2800usb/new_id
>  '';
>
> This is from: https://github.com/jethrokuan/nix-config/blob/master/desktop
> /configuration.nix
>
> --
> Regards,
> Peter
>



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


Re: [Nix-dev] [NixOS] How to incorporate my Bash script in configuration.nix?

2017-05-09 Thread Peter Hoeg

Hi,


  > The proper way to do this is to set up modaliases

  Could you please elaborate further?


the alias in the line below depends on the exact PID and VID of your device so 
you may need to adjust it:

 boot.kernelModules = [ "rt2800usb" ];
 boot.extraModprobeConfig = ''
   alias usb:v0B05p17E8d*dc*dsc*dp*ic*isc*ip*in* rt2800usb
   install rt2800usb ${pkgs.kmod}/sbin/modprobe --ignore-install rt2800usb && echo 
0x0B05 0x17E8 >/sys/bus/usb/drivers/rt2800usb/new_id
 '';

This is from: 
https://github.com/jethrokuan/nix-config/blob/master/desktop/configuration.nix

--
Regards,
Peter
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] [NixOS] How to incorporate my Bash script in configuration.nix?

2017-05-09 Thread Strahinja Popovic
> The proper way to do this is to set up modaliases

Could you please elaborate further?

On Tue, May 9, 2017 at 3:14 PM, Peter Hoeg  wrote:

> Hi,
>
> I would have gone to systemd.services. Slightly uglier looking (bigger
>> attrset), but should run after the kernel has loaded its modules. I'd
>> say it would be ideal to have it be "PartOf = networking.target"
>> and/or "Before = dhcpd.service" (or whatever networking thingy you
>> use).
>>
>
> Actually, that will not do the trick either if the device isn't plugged
> in yet.
>
> The proper way to do this is to set up modaliases
>
> /Peter
>
> ___
> nix-dev mailing list
> nix-dev@lists.science.uu.nl
> https://mailman.science.uu.nl/mailman/listinfo/nix-dev
>



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


Re: [Nix-dev] [NixOS] How to incorporate my Bash script in configuration.nix?

2017-05-09 Thread Peter Hoeg

Hi,


I would have gone to systemd.services. Slightly uglier looking (bigger
attrset), but should run after the kernel has loaded its modules. I'd
say it would be ideal to have it be "PartOf = networking.target"
and/or "Before = dhcpd.service" (or whatever networking thingy you
use).


Actually, that will not do the trick either if the device isn't plugged
in yet.

The proper way to do this is to set up modaliases

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


Re: [Nix-dev] [NixOS] How to incorporate my Bash script in configuration.nix?

2017-05-09 Thread Strahinja Popovic
Thanks for help Peter,

But I have in dmesg now:

[2.027361] stage-2-init:
/nix/store/zv42ylc0jangv5kv437577qq79v3xq5n-nixos-system-strale-17.03.1033.99dfb6dce3/activate:
line 136: /sys/bus/usb/drivers/rt2800usb/new_id: No such file or directory

How to make it to wait for kernel module?

On Tue, May 9, 2017 at 9:44 AM, Peter Hoeg  wrote:

> Hi,
>
>   I have made my USB WiFi to work,
>>   but I have to call this script whenever I restart the computer.
>>
>
> you can do it this way:
>
> system.activationScripts = {
>  rt2800usb = {
>text = ''
>  echo "0b05 17e8" > /sys/bus/usb/drivers/rt2800usb/new_id
>'';
>deps = [];
>  };
> };
>
> --
> Regards,
> Peter
>



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


Re: [Nix-dev] [NixOS] How to incorporate my Bash script in configuration.nix?

2017-05-09 Thread Peter Hoeg

Hi,


  I have made my USB WiFi to work,
  but I have to call this script whenever I restart the computer.


you can do it this way:

system.activationScripts = {
 rt2800usb = {
   text = ''
 echo "0b05 17e8" > /sys/bus/usb/drivers/rt2800usb/new_id
   '';
   deps = [];
 };
};

--
Regards,
Peter
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] [NixOS] How to incorporate my Bash script in configuration.nix?

2017-05-09 Thread Strahinja Popovic
Hi everyone,

I have made my USB WiFi to work,
but I have to call this script whenever I restart the computer.

#!/usr/bin/env bash
echo "0b05 17e8"|sudo tee /sys/bus/usb/drivers/rt2800usb/new_id

What is correct way to make this part of configuration.nix?

Cheers,
-- 
Strahinja Popovic
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev