-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
72 lines (62 loc) · 1.98 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
description = "Discord bot for DOTA 2 availability developed by Jay";
inputs = {
flake-utils = {
url = "github:numtide/flake-utils";
};
nixpkgs = {
url = "nixpkgs/nixos-unstable-small";
};
composer-nix = {
url = "github:tristanpemble/composer-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "flake-utils";
};
};
outputs = { self, nixpkgs, composer-nix, ... }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
version = "${nixpkgs.lib.substring 0 8 self.lastModifiedDate}.${self.shortRev or "dirty"}";
in
{
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system};
composerRepo = composer-nix.lib.mkComposerRepo {
inherit system;
composerJson = ./composer.json;
};
in
{
default = pkgs.stdenvNoCC.mkDerivation {
pname = "discord-availability";
inherit version;
src = self;
COMPOSER = "${composerRepo}/composer.json";
buildInputs = [ pkgs.php.packages.composer ];
patchPhase = ''
rm -rf ./vendor
sed -i '1 i #!${pkgs.php}/bin/php' ./availability.php
'';
buildPhase = ''
composer install --no-dev --optimize-autoloader
'';
installPhase = ''
mkdir -p "$out"
cp -r . "$out/src"
chmod +x "$out/src/availability.php"
mkdir "$out/bin"
ln -s "$out/src/availability.php" "$out/bin/discord-availability"
# Clean up a bit.
rm "$out"/src/composer*
rm "$out"/src/flake*
rm "$out"/src/README.md
rm "$out"/src/ruleset.xml
'';
};
}
);
};
}