Skip to content

Commit af9c658

Browse files
committed
add nix derivation
This allows nix users to easily run the scripts on systems with nix
1 parent c41d8d1 commit af9c658

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,6 @@ ASALocalRun/
331331

332332
# Coverity
333333
cov-int/
334+
335+
# nix stuff
336+
**/result

doc/Linux.md

+17
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,20 @@ Starting execution at address 0x08002000... done.
135135
Firmware flashed successfully.
136136
137137
```
138+
139+
# Using `nix`
140+
141+
In case you happen to have [`nix`](https://nixos.org/explore.html) installed,
142+
you can simply use the `default.nix` file in the linux folder to build a
143+
compatible derivation of both `flash-multi` and `multi-bootreloader`. To
144+
install it in your users environment, simply run `nix-env -f . -i`.
145+
146+
Beware: This does not alter udev rules, so you likely will run into permission
147+
problems with the DFU device and/or the serial device. Possible solution in
148+
descending level of recommendability:
149+
150+
+ install appropiate udev rules in your system
151+
+ run the script in question as `root` user
152+
+ run `while true; do sudo chown $USER /dev/bus/usb/*; done` while using the
153+
script. Afterwards run `sudo udevadm control --reload-rules && udevadm trigger` to
154+
reaply all udev rules in question.

linux/default.nix

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
3+
with pkgs;
4+
5+
stdenv.mkDerivation rec {
6+
name = "flash-multi";
7+
8+
src = ./.;
9+
10+
nativeBuildInputs = [ autoPatchelfHook ];
11+
buildInputs = [ libusb ];
12+
13+
installPhase = ''
14+
runHook preInstall
15+
mkdir -p $out/{bin,${name}}
16+
mv * $out/${name}/
17+
ln -s $out/${name}/flash-multi $out/bin/
18+
ln -s $out/${name}/multi-bootreloader $out/bin/
19+
runHook postInstall
20+
'';
21+
}

0 commit comments

Comments
 (0)