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

Profpatsch mail at profpatsch.de
Fri May 12 17:02:46 CEST 2017


On 17-05-08 02:28pm, Strahinja Popovic wrote:
> 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?

probably by adding service file to bootup, like:

systemd.service.myUsbService = 
  let startupScript = ''
    #!${pkgs.bash}
    echo "0b05 17e8" | tee /sys/bus/usb/drivers/rt2800usb/new_id
  '';
  in { 
    description = "get my US WiFi to work";
    wantedBy = [ "default.target" ];
    serviceConfig = {
      ExecStart = startupScript;
    };
  };

Maybe you’ll have to play with the units it needs to run before.
I point you to `man configuration.nix` and `man systemd.unit`.

-- 
Proudly written in Mutt with Vim on NixOS.
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
May take up to five days to read your message. If it’s urgent, call me.


More information about the nix-dev mailing list