Initialize repo for bs-manager flake

This commit is contained in:
pleb
2026-06-28 10:44:05 -07:00
commit fb59c1647d
6 changed files with 371 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
# nix-beatsaber
Nix flake for Beat Saber tools.
## Packages
```sh
nix run .#bs-manager
```
## Updating BSManager
```sh
nix flake lock --update-input bs-manager-src
```
Generated
+44
View File
@@ -0,0 +1,44 @@
{
"nodes": {
"bs-manager-src": {
"flake": false,
"locked": {
"lastModified": 1782401198,
"narHash": "sha256-zf4l8ctIBah+qwhbC1t31Y/BtWmV11AnGokAMjcBbt8=",
"owner": "Zagrios",
"repo": "bs-manager",
"rev": "106584cf84a34e7dc4e4b915212444e73b71acc0",
"type": "github"
},
"original": {
"owner": "Zagrios",
"repo": "bs-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1782467914,
"narHash": "sha256-pGvFkM8N0xEkIIXDe5YYfbEAvHrk4IxBrjB/x8OomhE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e73de5be04e0eff4190a1432b946d469c794e7b4",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"bs-manager-src": "bs-manager-src",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
+57
View File
@@ -0,0 +1,57 @@
{
description = "Nix packages for Beat Saber tools";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
bs-manager-src = {
url = "github:Zagrios/bs-manager";
flake = false;
};
};
outputs =
{
self,
nixpkgs,
bs-manager-src,
}:
let
inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
];
forSystems = lib.genAttrs systems;
in
{
packages = forSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages = [
"electron-39.8.10"
];
};
};
bs-manager = pkgs.callPackage ./pkgs/bs-manager {
src = bs-manager-src;
};
in
{
inherit bs-manager;
default = bs-manager;
}
);
overlays.default = final: _prev: {
bs-manager = final.callPackage ./pkgs/bs-manager {
src = bs-manager-src;
};
};
};
}
+148
View File
@@ -0,0 +1,148 @@
{
lib,
stdenv,
callPackage,
buildNpmPackage,
fetchNpmDeps,
makeDesktopItem,
autoPatchelfHook,
copyDesktopItems,
makeWrapper,
electron_39,
steam-run-free,
src,
}:
buildNpmPackage (finalAttrs: {
pname = "bs-manager";
version = (lib.importJSON "${finalAttrs.src}/package.json").version;
inherit src;
postPatch = ''
# Don't search for resources in electron's resource directory, but our own.
substituteInPlace src/main/services/utils.service.ts \
--replace-fail "process.resourcesPath" "'$out/share/bs-manager/resources'"
# Replace vendored DepotDownloader with our own.
rm assets/scripts/DepotDownloader
ln -s ${finalAttrs.passthru.depotdownloader}/bin/DepotDownloader assets/scripts/DepotDownloader
'';
npmDepsHash = "sha256-wmPZv1lqGr31wBGaeLw7LL6ZMzq/x8lkoy/iMxU+M80=";
extraNpmDeps = fetchNpmDeps {
name = "${finalAttrs.pname}-${finalAttrs.version}-extra-npm-deps";
inherit (finalAttrs) src;
sourceRoot = "${baseNameOf finalAttrs.src}/release/app";
hash = "sha256-jE/M22QQzuTS0zgcB+tLEL8Ey61HE8MP7H1MTX060gY=";
};
makeCacheWritable = true;
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
npmRebuildFlags = [ "--ignore-scripts" ];
nativeBuildInputs = [
autoPatchelfHook
copyDesktopItems
makeWrapper
];
buildInputs = [
stdenv.cc.cc
];
preBuild = ''
pushd release/app
rm -r "$npm_config_cache"
npmDeps="$extraNpmDeps" npmConfigHook
npm run postinstall
popd
'';
postBuild = ''
cp -r ${electron_39.dist} electron-dist
chmod -R u+w electron-dist
npm exec electron-builder -- \
--dir \
--config=electron-builder.config.js \
-c.electronDist=electron-dist \
-c.electronVersion=${electron_39.version}
# glibc NixOS cannot satisfy musl-linked prebuilts; remove unused musl addons.
for unpacked in release/build/*-unpacked; do
nm="$unpacked/resources/app.asar.unpacked/node_modules"
if [[ -d "$nm" ]]; then
find "$nm" -depth -type d -name '*musl*' -exec rm -rf {} ';'
fi
done
'';
installPhase = ''
runHook preInstall
for icon in build/icons/png/*.png; do
install -Dm644 $icon $out/share/icons/hicolor/$(basename $icon .png)/apps/bs-manager.png
done
mkdir -p $out/share/bs-manager
cp -r release/build/*-unpacked/{locales,resources{,.pak}} $out/share/bs-manager
makeWrapper ${lib.getExe electron_39} $out/bin/bs-manager \
--set-default ELECTRON_FORCE_IS_PACKAGED 1 \
--add-flags $out/share/bs-manager/resources/app.asar \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
--prefix PATH : ${lib.makeBinPath [ steam-run-free ]} \
--inherit-argv0
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
desktopName = "BSManager";
name = "BSManager";
exec = "bs-manager";
terminal = false;
type = "Application";
icon = "bs-manager";
mimeTypes = [
"x-scheme-handler/bsmanager"
"x-scheme-handler/beatsaver"
"x-scheme-handler/bsplaylist"
"x-scheme-handler/modelsaber"
"x-scheme-handler/web+bsmap"
];
categories = [
"Utility"
"Game"
];
})
];
passthru = {
depotdownloader = callPackage ./depotdownloader { };
};
meta = {
changelog = "https://github.com/Zagrios/bs-manager/blob/v${finalAttrs.version}/CHANGELOG.md";
description = "Manage maps, mods and more for Beat Saber";
homepage = "https://github.com/Zagrios/bs-manager";
license = lib.licenses.gpl3Only;
mainProgram = "bs-manager";
maintainers = [ ];
platforms = lib.platforms.linux;
sourceProvenance = with lib.sourceTypes; [
binaryNativeCode
];
};
})
@@ -0,0 +1,35 @@
{
lib,
buildDotnetModule,
fetchFromGitHub,
dotnetCorePackages,
}:
buildDotnetModule {
pname = "depotdownloader";
version = "3.4.0-unstable-2026-05-14";
src = fetchFromGitHub {
owner = "Iluhadesu";
repo = "DepotDownloader";
rev = "0ab6676c51f27d3b9e63278e3c18484d4d2bf063";
hash = "sha256-qC9EakT1tu8NNwbmj7HmYgcIoEUlMRRHNGnKggVNDgk=";
};
projectFile = "DepotDownloader.sln";
nugetDeps = ./deps.json;
dotnet-sdk = dotnetCorePackages.sdk_9_0;
dotnet-runtime = dotnetCorePackages.runtime_9_0;
meta = {
description = "Fork of DepotDownloader to be used by BSManager";
license = lib.licenses.gpl2Only;
platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
mainProgram = "DepotDownloader";
};
}
+72
View File
@@ -0,0 +1,72 @@
[
{
"pname": "Microsoft.NETCore.Platforms",
"version": "5.0.0",
"hash": "sha256-LIcg1StDcQLPOABp4JRXIs837d7z0ia6+++3SF3jl1c="
},
{
"pname": "Microsoft.Win32.Registry",
"version": "5.0.0",
"hash": "sha256-9kylPGfKZc58yFqNKa77stomcoNnMeERXozWJzDcUIA="
},
{
"pname": "Microsoft.Windows.CsWin32",
"version": "0.3.275",
"hash": "sha256-sqIFj1dNatchuS9R7sk0Os6vSoSXFjm20qppvnnw78c="
},
{
"pname": "Microsoft.Windows.SDK.Win32Docs",
"version": "0.1.42-alpha",
"hash": "sha256-6DvzmNzrGVfWmNJNqooj+Ya+7bAQlyeg7pmyKaUlIws="
},
{
"pname": "Microsoft.Windows.SDK.Win32Metadata",
"version": "63.0.31-preview",
"hash": "sha256-MMvQoyVT15IU93EKZ46rhP/hyx3wV452vuFnf8OTd60="
},
{
"pname": "Microsoft.Windows.SDK.Win32Metadata",
"version": "70.0.11-preview",
"hash": "sha256-JRcTFlzV+sDfgUKPtn0oOn25SdNivmhbS8+0HcAozu8="
},
{
"pname": "Microsoft.Windows.WDK.Win32Metadata",
"version": "0.13.25-experimental",
"hash": "sha256-eQeaRJ2PYhBSvK8TA55BHRwbd67EqJzwTZZRjQphlhc="
},
{
"pname": "protobuf-net",
"version": "3.2.56",
"hash": "sha256-KjwRHyGwflQDjVaudT+NjRnfGhHb4CpCfn9hHVixI+E="
},
{
"pname": "protobuf-net.Core",
"version": "3.2.56",
"hash": "sha256-NVvLreCvvvnS/s0syL5/L3mRpXeswP7E71C6WP9f2Dc="
},
{
"pname": "SteamKit2",
"version": "3.3.1",
"hash": "sha256-f6kc15RKNxCSIlynlVHU8fBqQ7N8nG1xV3DNbBlRmvo="
},
{
"pname": "System.IO.Hashing",
"version": "9.0.8",
"hash": "sha256-Jj1XwumBjBa5LJqSVTN2naQJ0FM4wwPvZS8NxGd5Hnw="
},
{
"pname": "System.Security.AccessControl",
"version": "5.0.0",
"hash": "sha256-ueSG+Yn82evxyGBnE49N4D+ngODDXgornlBtQ3Omw54="
},
{
"pname": "System.Security.Principal.Windows",
"version": "5.0.0",
"hash": "sha256-CBOQwl9veFkrKK2oU8JFFEiKIh/p+aJO+q9Tc2Q/89Y="
},
{
"pname": "ZstdSharp.Port",
"version": "0.8.6",
"hash": "sha256-rc3YWP80fykqujDsD72SXOA1tBDoy2KrvVETOC8eTx8="
}
]