-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
100 lines (99 loc) · 3.48 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{
inputs = {
nixpkgs.url =
"github:NixOS/nixpkgs/6909e461de4ecafbfac42e7a7a9e53da01ebf244";
nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nix-github-actions }:
let
ghcVersion = "96";
mkHsPackage = pkgs: pkgs.haskell.packages."ghc${ghcVersion}";
in {
packages = builtins.mapAttrs (system: pkgs: {
youtube-mpv-native-host = ((mkHsPackage pkgs).developPackage {
root = ./native-host;
modifier = drv: pkgs.haskell.lib.appendConfigureFlag drv "-O2";
}).overrideAttrs (_: oa: {
# NOTE: https://stackoverflow.com/a/69395418
nativeBuildInputs = (oa.nativeBuildInputs or [ ])
++ [ pkgs.makeWrapper ];
postFixup = (oa.postFixup or "") + ''
wrapProgram $out/bin/youtube-mpv-native-host --prefix PATH : ${
pkgs.lib.makeBinPath [ pkgs.mpv ]
}
'';
});
youtube-mpv-chrome-extension = with pkgs;
buildNpmPackage {
pname = "youtube-mpv-chrome-extension";
version = "1.0.0";
nativeBuildInputs = [ typescript ];
src = with lib.fileset;
toSource {
root = ./extension;
fileset = fileFilter (file: !(file.hasExt "js")) ./extension;
};
npmDepsHash = "sha256-Z1IhQt2Yul1AjX3V1F0VHvjCOAxvDkxfOf3iNVfdI4E=";
buildPhase = "tsc";
postInstall = ''
mkdir -p $out/share/chrome/extensions
cp -r dist/* $out/share/chrome/extensions
rm -r $out/lib
'';
};
youtube-mpv = with pkgs;
let
inherit (self.packages.${system})
youtube-mpv-native-host youtube-mpv-chrome-extension;
in stdenvNoCC.mkDerivation {
pname = "youtube-mpv";
version = "1.0.0";
buildInputs =
[ youtube-mpv-native-host youtube-mpv-chrome-extension ];
phases = [ "installPhase" ];
installPhase = ''
mkdir $out
cp -r ${youtube-mpv-native-host}/bin $out
cp -r ${youtube-mpv-chrome-extension}/share $out
'';
};
default = self.packages.${system}.youtube-mpv;
}) nixpkgs.legacyPackages;
devShells = builtins.mapAttrs (system: pkgs:
with pkgs;
let hsPackage = mkHsPackage pkgs;
in {
default = (mkHsPackage pkgs).shellFor {
packages = _: [ self.packages.${system}.youtube-mpv-native-host ];
nativeBuildInputs = with pkgs;
[
(haskell-language-server.override {
supportedGhcVersions = [ ghcVersion ];
})
cabal-install
ghcid
typescript
mpv
] ++ (with nodePackages; [
typescript-language-server
pnpm
prettier
npm
]);
withHoogle = true;
};
}) nixpkgs.legacyPackages;
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = builtins.mapAttrs (_: pkgs: { inherit (pkgs) youtube-mpv; }) {
inherit (self.packages) x86_64-linux x86_64-darwin;
};
platforms = {
x86_64-linux = "ubuntu-22.04";
x86_64-darwin = "macos-13";
};
};
};
}