Skip to content

Commit

Permalink
add nix derivation
Browse files Browse the repository at this point in the history
This allows nix users to easily run the scripts on systems with nix
  • Loading branch information
wucke13 committed Jan 16, 2021
1 parent c41d8d1 commit af9c658
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,6 @@ ASALocalRun/

# Coverity
cov-int/

# nix stuff
**/result
17 changes: 17 additions & 0 deletions doc/Linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
21 changes: 21 additions & 0 deletions linux/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ pkgs ? import <nixpkgs> {} }:

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
'';
}

0 comments on commit af9c658

Please sign in to comment.