Skip to content

Commit

Permalink
Merge pull request #39 from wucke13/dev/wucke13/add-nix
Browse files Browse the repository at this point in the history
add nix derivation
  • Loading branch information
benlye authored Jan 16, 2021
2 parents 70ac4ec + af9c658 commit de836e1
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 de836e1

Please sign in to comment.