1{ lib
2, pkgs
3, stdenv
4, fetchFromGitHub
5, dataDir ? "/var/lib/snipe-it"
6, mariadb
7, nixosTests
8}:
9
10let
11 package = (import ./composition.nix {
12 inherit pkgs;
13 inherit (stdenv.hostPlatform) system;
14 noDev = true; # Disable development dependencies
15 }).overrideAttrs (attrs : {
16 installPhase = attrs.installPhase + ''
17 # Before symlinking the following directories, copy the invalid_barcode.gif
18 # to a different location. The `snipe-it-setup` oneshot service will then
19 # copy the file back during bootstrap.
20 mkdir -p $out/share/snipe-it
21 cp $out/public/uploads/barcodes/invalid_barcode.gif $out/share/snipe-it/
22
23 rm -R $out/storage $out/public/uploads $out/bootstrap/cache
24 ln -s ${dataDir}/.env $out/.env
25 ln -s ${dataDir}/storage $out/
26 ln -s ${dataDir}/public/uploads $out/public/uploads
27 ln -s ${dataDir}/bootstrap/cache $out/bootstrap/cache
28
29 chmod +x $out/artisan
30
31 substituteInPlace config/database.php --replace "env('DB_DUMP_PATH', '/usr/local/bin')" "env('DB_DUMP_PATH', '${mariadb}/bin')"
32 '';
33 });
34
35in package.override rec {
36 pname = "snipe-it";
37 version = "6.1.0";
38
39 src = fetchFromGitHub {
40 owner = "snipe";
41 repo = pname;
42 rev = "v${version}";
43 sha256 = "0c8cjywhyiywfav2syjkah777qj5f1jrckgri70ypqyxbwgb4rpm";
44 };
45
46 passthru.tests = nixosTests.snipe-it;
47
48 meta = with lib; {
49 description = "A free open source IT asset/license management system";
50 longDescription = ''
51 Snipe-IT was made for IT asset management, to enable IT departments to track
52 who has which laptop, when it was purchased, which software licenses and accessories
53 are available, and so on.
54 Details for snipe-it can be found on the official website at https://snipeitapp.com/.
55 '';
56 homepage = "https://snipeitapp.com/";
57 changelog = "https://github.com/snipe/snipe-it/releases/tag/v${version}";
58 license = licenses.agpl3Only;
59 maintainers = with maintainers; [ yayayayaka ];
60 platforms = platforms.linux;
61 };
62}