Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
SpiralP committed Dec 12, 2024
1 parent 003727a commit c955f1c
Show file tree
Hide file tree
Showing 10 changed files with 8,477 additions and 4,175 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__diff_output__
/bin/
/pkg/*
!/pkg/package.json
Expand Down
76 changes: 59 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
inherit system;
};
chatsounds-cli = chatsounds-cli-repo.outputs.packages.${system}.default;

# use FC_DEBUG=1024 when running to debug what config files are loaded
fontconfig = pkgs.runCommand "fontconfig"
{
nativeBuildInputs = with pkgs; [ sd ];
}
''
mkdir -vp "$out/conf.d"
ln -vs ${pkgs.fontconfig.out}/etc/fonts/conf.d/* "$out/conf.d/"
cat '${pkgs.fontconfig.out}/etc/fonts/fonts.conf' > "$out/fonts.conf"
sd --fixed-strings '${pkgs.dejavu_fonts.minimal}' '${pkgs.noto-fonts}' "$out/fonts.conf"
sd --fixed-strings '/etc/fonts/conf.d' "$out/conf.d" "$out/fonts.conf"
sd --fixed-strings '/var/cache/fontconfig' "/tmp/fontconfig" "$out/fonts.conf"
'';
in
rec {
default = pkgs.buildNpmPackage {
Expand All @@ -32,7 +47,28 @@
"^web(/.*)?$"
];

npmDepsHash = "sha256-e4Dn8PdjNo6dZ+21E6zo+FmrQkdBrVj7oWHbgFyBlbM=";
npmDepsHash = "sha256-iYGyxiUGGmcSV17J9zZ2nAx5xmX3n6pZitAagd4U7DQ=";

nativeBuildInputs = (with pkgs; [
# for tests
procps
])
++ (if dev then
(wasm.nativeBuildInputs ++ (with pkgs; [
chatsounds-cli
clippy
ffmpeg
rust-analyzer
(rustfmt.override { asNightly = true; })
])) else [ ]);

buildInputs =
if dev
then wasm.buildInputs
else [ ];

PUPPETEER_SKIP_DOWNLOAD = true;
PUPPETEER_EXECUTABLE_PATH = "${lib.getExe pkgs.chromium}";

preBuild = ''
ln -vsf ${wasm}/pkg ./node_modules/chatsounds-web
Expand All @@ -43,26 +79,32 @@
--prefix PATH : ${lib.makeBinPath [ chatsounds-cli ffmpeg ]}
'';

nativeBuildInputs = with pkgs;
if dev
then
(wasm.nativeBuildInputs ++ [
chatsounds-cli
clippy
ffmpeg
rust-analyzer
(rustfmt.override { asNightly = true; })
])
else [ ];

buildInputs =
if dev
then wasm.buildInputs
else [ ];
FONTCONFIG_FILE = "${fontconfig.out}/fonts.conf";
FONTCONFIG_PATH = "${fontconfig.out}/";
doCheck = true;
# preCheck = ''
# # fix for:
# # Failed to launch the browser process!
# # chrome_crashpad_handler: --database is required
# export HOME="$TMPDIR"

# # fix for missing fonts
# mkdir -vp "$HOME/.config/fontconfig"
# ln -vs '${pkgs.fontconfig.out}/etc/fonts/conf.d' "$HOME/.config/fontconfig/conf.d"
# cat '${pkgs.fontconfig.out}/etc/fonts/fonts.conf' \
# | ${lib.getExe pkgs.sd} --fixed-strings '${pkgs.dejavu_fonts.minimal}' '${pkgs.noto-fonts}' \
# > "$HOME/.config/fontconfig/fonts.conf"
# '';
checkPhase = ''
runHook preCheck
npm run test
runHook postCheck
'';

meta.mainProgram = "chatsounds-web";
};

# TODO use rust builder?
wasm = pkgs.stdenv.mkDerivation {
pname = "chatsounds-web-wasm";
version = "0.0.1";
Expand Down
Loading

0 comments on commit c955f1c

Please sign in to comment.