commit 4e0acca4ccc644dbdaae90168796295ba3da9ee0 Author: Sebastian Wendel Date: Thu Oct 5 18:04:47 2023 +0200 initial commit diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..4fd71b3 --- /dev/null +++ b/.envrc @@ -0,0 +1,4 @@ +use flake + +watch_file flake.* +watch_file **/*.nix diff --git a/.gitea/actions/setup-nix/action.yaml b/.gitea/actions/setup-nix/action.yaml new file mode 100644 index 0000000..ae271f8 --- /dev/null +++ b/.gitea/actions/setup-nix/action.yaml @@ -0,0 +1,14 @@ +--- +name: Install Nix +description: Install Nix package manager using the Determinante Systems installer +runs: + using: composite + steps: + - uses: https://github.com/DeterminateSystems/nix-installer-action@v4 + with: + init: none + planner: linux + github-token: ${{ secrets.GH_TOKEN }} + extra-conf: | + accept-flake-config = true + experimental-features = nix-command flakes recursive-nix diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..a5bbe69 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,30 @@ +--- +name: build +on: push + +jobs: + check: + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Nix + uses: ./.gitea/actions/setup-nix + + - name: Nix check + run: nix flake check + + build: + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Nix + uses: ./.gitea/actions/setup-nix + + - name: Nix build + run: nix build .# diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ca8b14 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +# General +*~ +*.dll +*.log +*.so +*.swp +*.000 +*.bak +*.bck +*.tmp + +# macOS +.DS_Store + +# Nix +.direnv +.pre-commit-config.yaml +result diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 0000000..e1819ae --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,16 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: nix-microscopy +Upstream-Contact: Sebastian Wendel +Source: https://code.srx.dev/srx/nix-microscopy + +Files: .gitignore + .editorconfig + .envrc + .gitea + packages/* + shells/* + *.lock + *.nix + *.md +Copyright: 2023 Sebastian Wendel +License: MIT diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 0000000..2b64cd3 --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2023 Sebastian Wendel + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1df73d --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Nix Microscopy + +## Packages + +- [ToupLite](http://touptek.com/download/showdownload.php?lang=en&id=28) from [ToupTek](http://touptek.com/) + +## License + +This project follows the [REUSE Specification](https://reuse.software/spec/) and is licensed under the [MIT License - see the LICENSE file](./LICENSES/MIT.txt) for details. diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..0205bc8 --- /dev/null +++ b/default.nix @@ -0,0 +1,14 @@ +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { + src = ./.; + }) +.defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9cdf04f --- /dev/null +++ b/flake.lock @@ -0,0 +1,158 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1696193975, + "narHash": "sha256-mnQjUcYgp9Guu3RNVAB2Srr1TqKcPpRXmJf4LJk6KRY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fdd898f8f79e8d2f99ed2ab6b3751811ef683242", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": [ + "flake-utils" + ], + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1696510682, + "narHash": "sha256-Nki3ersvzmy9iQBkUI0yIRBHg6cQEHCT0oCd5BQMibg=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "b039621ad7536841c8da7b12f59af588360f7725", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ec63cb5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,74 @@ +{ + description = "Nix Microscopy"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + pre-commit-hooks = { + url = "github:cachix/pre-commit-hooks.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + pre-commit-hooks, + ... + } @ inputs: + flake-utils.lib.eachSystem ["x86_64-linux"] (system: rec { + pkgs = import nixpkgs { + inherit system; + config = {allowUnfree = true;}; + }; + + devShells.default = self.pkgs.${system}.mkShell { + name = "nix-microscopy"; + buildInputs = with self.pkgs.${system}; [ + alejandra + deadnix + git + nil + nixUnstable + pre-commit + reuse + statix + ]; + shellHook = '' + ${self.checks.${system}.pre-commit-check.shellHook} + ''; + }; + + checks = { + pre-commit-check = + pre-commit-hooks.lib.${system}.run + { + src = self.pkgs.${system}.lib.cleanSource ./.; + hooks = { + editorconfig-checker.enable = true; + statix.enable = true; + deadnix.enable = true; + alejandra.enable = true; + }; + }; + }; + + packages = { + amlite = self.pkgs.${system}.callPackage ./pkgs/amlite inputs; + default = self.packages.${system}.amlite; + }; + + apps = { + amlite = { + type = "app"; + program = "${self.packages.${system}.amlite}/bin/AmLite"; + }; + }; + }); +} diff --git a/pkgs/amlite/default.nix b/pkgs/amlite/default.nix new file mode 100644 index 0000000..9a0a9a4 --- /dev/null +++ b/pkgs/amlite/default.nix @@ -0,0 +1,46 @@ +{ + fetchurl, + lib, + stdenv, + ... +}: +stdenv.mkDerivation rec { + pname = "amlite"; + version = "20232603"; + + src = fetchurl { + url = "https://storage.googleapis.com/software-download-d79bb.appspot.com/software/AmLite/Linux/${version}/AmScopeAmLite.x64.tar.bz2"; + sha256 = "sha256-GyA3ogtpsNA/pTIa21ha9P1YtNE0reRDTAI7VOcdxnY="; + }; + + # FIX: "unpacker appears to have produced no directories" + sourceRoot = "."; + + postUnpack = '' + sed -n -e '1,/^exit 0$/!p' $sourceRoot/AmScopeAmLite.x64.sh > $sourceRoot/AmLite.tgz + cd $sourceRoot/ + tar -xzf AmLite.tgz + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/{lib,bin,share} \ + $out/lib/udev/rules.d + + cp AmLite $out/bin + cp *.so $out/lib + cp 99-amcam.rules $out/lib/udev/rules.d + + cp -r i18n $out/share/ + + runHook postInstall + ''; + + meta = with lib; { + description = "AmScope AmLite"; + homepage = "https://amscope.com/"; + license = licenses.unfree; + platforms = ["x86_64-linux"]; + }; +}