From af9c658c6bdbc68fc65de15c412cc84c01ed2aa6 Mon Sep 17 00:00:00 2001 From: wucke13 Date: Sat, 16 Jan 2021 16:20:25 +0100 Subject: [PATCH] add nix derivation This allows nix users to easily run the scripts on systems with nix --- .gitignore | 3 +++ doc/Linux.md | 17 +++++++++++++++++ linux/default.nix | 21 +++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 linux/default.nix diff --git a/.gitignore b/.gitignore index 355a98d..89da095 100644 --- a/.gitignore +++ b/.gitignore @@ -331,3 +331,6 @@ ASALocalRun/ # Coverity cov-int/ + +# nix stuff +**/result diff --git a/doc/Linux.md b/doc/Linux.md index 6fc7774..9bdfa3b 100644 --- a/doc/Linux.md +++ b/doc/Linux.md @@ -135,3 +135,20 @@ Starting execution at address 0x08002000... done. Firmware flashed successfully. ``` + +# Using `nix` + +In case you happen to have [`nix`](https://nixos.org/explore.html) installed, +you can simply use the `default.nix` file in the linux folder to build a +compatible derivation of both `flash-multi` and `multi-bootreloader`. To +install it in your users environment, simply run `nix-env -f . -i`. + +Beware: This does not alter udev rules, so you likely will run into permission +problems with the DFU device and/or the serial device. Possible solution in +descending level of recommendability: + ++ install appropiate udev rules in your system ++ run the script in question as `root` user ++ run `while true; do sudo chown $USER /dev/bus/usb/*; done` while using the + script. Afterwards run `sudo udevadm control --reload-rules && udevadm trigger` to + reaply all udev rules in question. diff --git a/linux/default.nix b/linux/default.nix new file mode 100644 index 0000000..b1e6f77 --- /dev/null +++ b/linux/default.nix @@ -0,0 +1,21 @@ +{ pkgs ? import {} }: + +with pkgs; + +stdenv.mkDerivation rec { + name = "flash-multi"; + + src = ./.; + + nativeBuildInputs = [ autoPatchelfHook ]; + buildInputs = [ libusb ]; + + installPhase = '' + runHook preInstall + mkdir -p $out/{bin,${name}} + mv * $out/${name}/ + ln -s $out/${name}/flash-multi $out/bin/ + ln -s $out/${name}/multi-bootreloader $out/bin/ + runHook postInstall + ''; +}