├── .github ├── dependabot.yml └── workflows │ └── build-packages.yml ├── .gitignore ├── LICENSE ├── README.md ├── data ├── packages.json └── packages.nix ├── flake.nix └── pkgs ├── adept2-runtime └── default.nix └── waveforms ├── default.nix └── rewrite-usr.c /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /.github/workflows/build-packages.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: build-packages 3 | 4 | on: push 5 | 6 | jobs: 7 | build-libraries: 8 | runs-on: ubuntu-20.04 9 | 10 | strategy: 11 | matrix: 12 | pkg: 13 | - adept2-runtime 14 | nixpkgs_branch: 15 | - nixos-unstable 16 | - nixos-21.11 17 | system: 18 | - x86_64-linux 19 | # - aarch64-linux 20 | 21 | name: "Build library ${{ matrix.pkg }} for ${{ matrix.nixpkgs_branch }} on ${{ matrix.system }}" 22 | 23 | steps: 24 | - uses: actions/checkout@v4 25 | - uses: cachix/install-nix-action@v31 26 | with: 27 | extra_nix_config: | 28 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 29 | - uses: cachix/cachix-action@v16 30 | with: 31 | name: liff 32 | signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' 33 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' 34 | - name: Build package ${{ matrix.pkg }} 35 | run: |- 36 | nix -L build \ 37 | --override-input nixpkgs github:nixos/nixpkgs/${{ matrix.nixpkgs_branch }} \ 38 | --system ${{ matrix.system }} \ 39 | .#${{ matrix.pkg }} 40 | 41 | build-applications: 42 | runs-on: ubuntu-20.04 43 | needs: build-libraries 44 | 45 | strategy: 46 | matrix: 47 | pkg: 48 | - waveforms 49 | nixpkgs_branch: 50 | - nixos-unstable 51 | - nixos-21.11 52 | system: 53 | - x86_64-linux 54 | # - aarch64-linux 55 | 56 | name: "Build application ${{ matrix.pkg }} for ${{ matrix.nixpkgs_branch }} on ${{ matrix.system }}" 57 | 58 | steps: 59 | - uses: actions/checkout@v4 60 | - uses: cachix/install-nix-action@v31 61 | with: 62 | extra_nix_config: | 63 | access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} 64 | - uses: cachix/cachix-action@v16 65 | with: 66 | name: liff 67 | signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' 68 | authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' 69 | - name: Build package ${{ matrix.pkg }} 70 | run: |- 71 | nix -L build \ 72 | --override-input nixpkgs github:nixos/nixpkgs/${{ matrix.nixpkgs_branch }} \ 73 | --system ${{ matrix.system }} \ 74 | .#${{ matrix.pkg }} 75 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /result 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build packages](https://github.com/liff/waveforms-flake/actions/workflows/build-packages.yml/badge.svg)](https://github.com/liff/waveforms-flake/actions/workflows/build-packages.yml) 2 | 3 | A Nix [flake](https://nixos.wiki/wiki/Flakes) for 4 | [Digilent Waveforms](https://store.digilentinc.com/digilent-waveforms/) 5 | on Linux. 6 | 7 | # Usage 8 | 9 | In addition to the `waveforms` package and app, this Flake provides a 10 | NixOS module that installs the package and sets up the USB device 11 | permissions so that `plugdev` group users are allowed to access. 12 | 13 | ```nix 14 | { 15 | inputs.waveforms.url = "github:liff/waveforms-flake"; 16 | 17 | outputs = { self, nixpkgs, waveforms }: { 18 | # replace 'joes-desktop' with your hostname here. 19 | nixosConfigurations.joes-desktop = nixpkgs.lib.nixosSystem { 20 | system = "x86_64-linux"; 21 | modules = [ 22 | # … 23 | waveforms.nixosModule 24 | ({ users.users.joe.extraGroups = [ "plugdev" ]; }) 25 | ]; 26 | }; 27 | }; 28 | } 29 | ``` 30 | 31 | # Note on unfree packages 32 | 33 | Due to limitations of flakes, this flake enables `config.allowUnfree` 34 | on its import of nixpkgs, meaining that packages can be built without 35 | otherwise enabling unfree software. 36 | -------------------------------------------------------------------------------- /data/packages.json: -------------------------------------------------------------------------------- 1 | { 2 | "adept2-runtime": { 3 | "version": "2.27.9", 4 | "systems": { 5 | "x86_64-linux": { 6 | "url": "https://files.digilent.com/Software/Adept2%20Runtime/2.27.9/digilent.adept.runtime_2.27.9-amd64.deb", 7 | "hash": "sha256-yKLM8tnqH/oPOkrk7S/2kKBof/gzgrYtrjD6ExmLv1M=" 8 | }, 9 | "i686-linux": { 10 | "url": "https://files.digilent.com/Software/Adept2%20Runtime/2.27.9/digilent.adept.runtime_2.27.9-i386.deb", 11 | "hash": "sha256-mEydJgHJve+zLjqjDxsYfcvZzVHmeSVRVsfn+9iA5FQ=" 12 | }, 13 | "aarch64-linux": { 14 | "url": "https://files.digilent.com/Software/Adept2%20Runtime/2.27.9/digilent.adept.runtime_2.27.9-arm64.deb", 15 | "hash": "sha256-JkeYRYyOH5NSHndWUWO4Ig7weWnbmhnEa9QPHYnPKek=" 16 | }, 17 | "armv7l-linux": { 18 | "url": "https://files.digilent.com/Software/Adept2%20Runtime/2.27.9/digilent.adept.runtime_2.27.9-armhf.deb", 19 | "hash": "sha256-zKuK5nMcWmbH/CPTA1pvL6N0wzaOIm4/BI90sPEAby8=" 20 | } 21 | } 22 | }, 23 | "waveforms": { 24 | "version": "3.24.2", 25 | "systems": { 26 | "x86_64-linux": { 27 | "url": "https://files.digilent.com/Software/Waveforms2015/3.24.2/digilent.waveforms_3.24.2_amd64.deb", 28 | "hash": "sha256-EETVcpOy3eQ+8yFI8eBKGosxEIZACJ6UbQTF+cL1MIc=" 29 | }, 30 | "i686-linux": { 31 | "url": "https://files.digilent.com/Software/Waveforms2015/3.24.2/digilent.waveforms_3.24.2_i386.deb", 32 | "hash": "sha256-mh4+ahCyzAam1XPbuHVM6TDUo+e+XfqxDFLYbRxz9PI=" 33 | }, 34 | "aarch64-linux": { 35 | "url": "https://files.digilent.com/Software/Waveforms2015/3.24.2/digilent.waveforms_3.24.2_arm64.deb", 36 | "hash": "sha256-dtakEQRNYF/FlpNKC9fSyhKYcdH3jf6+5cNG65JZOgs=" 37 | }, 38 | "armv7l-linux": { 39 | "url": "https://files.digilent.com/Software/Waveforms2015/3.24.2/digilent.waveforms_3.24.2_armhf.deb", 40 | "hash": "sha256-KY8tRbLq+sxEYyK7L0qFVAsUygcdVmjCzWuzUQ5Bv90=" 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /data/packages.nix: -------------------------------------------------------------------------------- 1 | with builtins; 2 | 3 | fromJSON (readFile ./packages.json) 4 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | { 2 | description = "Digilent Waveforms"; 3 | 4 | outputs = { self, nixpkgs }: 5 | let systems = [ "i686-linux" "x86_64-linux" "armv7l-linux" "aarch64-linux" ]; 6 | names = [ 7 | "adept2-runtime" 8 | "waveforms" 9 | ]; 10 | 11 | toFlakePackage = system: name: { 12 | inherit name; 13 | value = (import nixpkgs { 14 | inherit system; 15 | config.allowUnfree = true; 16 | overlays = [ self.overlay ]; 17 | })."${name}"; 18 | }; 19 | 20 | inherit (builtins) map listToAttrs; 21 | 22 | eachSystem = f: listToAttrs (map (system: { name = system; value = f system; }) systems); 23 | 24 | packages = eachSystem (system: 25 | let all = listToAttrs (map (toFlakePackage system) names); 26 | in all // { default = all.waveforms; } 27 | ); 28 | 29 | overlay = final: prev: 30 | listToAttrs ( 31 | map (name: { 32 | inherit name; 33 | value = final.callPackage (./pkgs + "/${name}") {}; 34 | }) 35 | names); 36 | 37 | apps = eachSystem (system: rec { 38 | waveforms = { 39 | type = "app"; 40 | program = "${packages.${system}.waveforms}/bin/waveforms"; 41 | }; 42 | default = waveforms; 43 | }); 44 | 45 | defaultPackage = eachSystem (system: packages.${system}.default); 46 | 47 | defaultApp = eachSystem (system: apps.${system}.default); 48 | 49 | nixosModule = { pkgs, ... }: { 50 | nixpkgs.overlays = [ self.overlay ]; 51 | services.udev.packages = [ pkgs.adept2-runtime ]; 52 | environment.systemPackages = [ pkgs.waveforms ]; 53 | }; 54 | 55 | devShells = eachSystem (system: 56 | let pkgs = import nixpkgs { inherit system; }; 57 | in { 58 | default = pkgs.mkShell { 59 | packages = [ (pkgs.python3.withPackages (py: [ 60 | py.python-lsp-server 61 | py.requests 62 | py.beautifulsoup4 63 | py.black 64 | ]))]; 65 | }; 66 | } 67 | ); 68 | 69 | in { 70 | inherit packages overlay defaultPackage apps defaultApp nixosModule; 71 | 72 | overlays.default = overlay; 73 | 74 | nixosModules.default = nixosModule; 75 | 76 | devShells = devShells; 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /pkgs/adept2-runtime/default.nix: -------------------------------------------------------------------------------- 1 | { lib 2 | , stdenv 3 | , fetchurl 4 | , autoPatchelfHook 5 | , libusb1 6 | , avahi 7 | , dpkg 8 | }: 9 | 10 | let 11 | 12 | digilentPackages = import ../../data/packages.nix; 13 | inherit (digilentPackages.adept2-runtime) version systems; 14 | srcInfo = systems.${stdenv.targetPlatform.system}; 15 | 16 | in 17 | 18 | stdenv.mkDerivation rec { 19 | pname = "adept2-runtime"; 20 | inherit version; 21 | 22 | src = fetchurl { 23 | inherit (srcInfo) url hash; 24 | }; 25 | 26 | nativeBuildInputs = [ dpkg autoPatchelfHook ]; 27 | 28 | buildInputs = [ stdenv.cc.cc.lib libusb1 avahi ]; 29 | 30 | unpackCmd = "dpkg -x $curSrc out"; 31 | 32 | dontBuild = true; 33 | 34 | installPhase = '' 35 | runHook preInstall 36 | 37 | mkdir -p $out/{etc,share} $out/etc/udev/rules.d 38 | 39 | cp -a usr/lib*/digilent/adept $out/lib 40 | cp -a usr/sbin $out/ 41 | cp -a usr/share/{doc,digilent} $out/share/ 42 | 43 | cat > $out/etc/digilent-adept.conf < $out/etc/udev/rules.d/52-digilent-usb.rules < xdg-open < 3 | #include 4 | #include 5 | #include 6 | 7 | FILE *fopen(const char *restrict pathname, const char *restrict mode) { 8 | FILE *(*fopen_real)(const char *restrict pathname, 9 | const char *restrict mode) = dlsym(RTLD_NEXT, "fopen"); 10 | 11 | if (strncmp(pathname, "/usr/", 5) == 0) { 12 | char buf[1024]; 13 | strcpy(buf, DRV_DIR); 14 | strcat(buf, pathname + 4); 15 | return fopen_real(buf, mode); 16 | } 17 | 18 | return fopen_real(pathname, mode); 19 | } 20 | 21 | DIR *opendir(const char *name) { 22 | DIR *(*opendir_real)(const char *name) = dlsym(RTLD_NEXT, "opendir"); 23 | 24 | if (strncmp(name, "/usr/", 5) == 0) { 25 | char buf[1024]; 26 | strcpy(buf, DRV_DIR); 27 | strcat(buf, name + 4); 28 | return opendir_real(buf); 29 | } 30 | 31 | return opendir_real(name); 32 | } 33 | --------------------------------------------------------------------------------