push
This commit is contained in:
1 parent
8d55b87546
commit
c86ee98def
14 files changed
+472
-111
No files matched your search
@@ -0,0 +1,60 @@
|
||||
# MagicaVoxel / MagicaCSG via umu + Proton-GE.
|
||||
# Binaries live in ./_magica (git-excluded), so this needs --impure eval.
|
||||
{
|
||||
den.aspects.software.cad.homeManager = { config, lib, pkgs, ... }:
|
||||
let
|
||||
apps = {
|
||||
voxel = { name = "MagicaVoxel"; exe = "MagicaVoxel.exe"; bin = "magicavoxel"; mime = "model/x-vox"; ext = "vox"; };
|
||||
csg = { name = "MagicaCSG"; exe = "MagicaCSG.exe"; bin = "magicacsg"; mime = "model/x-mcsg"; ext = "mcsg"; };
|
||||
};
|
||||
srcOf = app: "${config.home.homeDirectory}/nix/modules/software/cad/_magica/${app}";
|
||||
present = lib.filterAttrs (app: _: builtins.pathExists (srcOf app)) apps;
|
||||
storeOf = app: builtins.path { path = srcOf app; name = "magica-${app}"; };
|
||||
|
||||
launcher = app: a: let store = storeOf app; in pkgs.writeShellApplication {
|
||||
name = a.bin;
|
||||
runtimeInputs = [ pkgs.umu-launcher pkgs.coreutils pkgs.rsync ];
|
||||
text = ''
|
||||
base="''${XDG_DATA_HOME:-$HOME/.local/share}/magica/${app}"
|
||||
export GAMEID=umu-0
|
||||
export PROTONPATH=${pkgs.proton-ge-bin.steamcompattool}
|
||||
export WINEPREFIX="$base/prefix"
|
||||
mkdir -p "$base/app" "$WINEPREFIX"
|
||||
if [ "$(cat "$base/stamp" 2>/dev/null)" != "${store}" ]; then
|
||||
excl=()
|
||||
[ -d "$base/app/config" ] && excl=(--exclude=/config)
|
||||
rsync -r --chmod=u+w "''${excl[@]}" "${store}/" "$base/app/"
|
||||
chmod -R u+w "$base/app"
|
||||
echo "${store}" > "$base/stamp"
|
||||
fi
|
||||
mkdir -p "$base/app/cache" "$base/app/export"
|
||||
args=()
|
||||
for f in "$@"; do args+=("$(realpath -- "$f")"); done
|
||||
cd "$base/app"
|
||||
exec umu-run ${a.exe} "''${args[@]}"
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
home.packages = lib.mapAttrsToList launcher present;
|
||||
# Register .vox/.mcsg; our desktop entries are the only handlers, so they become the default.
|
||||
xdg.dataFile."mime/packages/magica.xml".text = ''
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||
${lib.concatMapStrings (a: ''
|
||||
<mime-type type="${a.mime}">
|
||||
<comment>${a.name} model</comment>
|
||||
<glob pattern="*.${a.ext}"/>
|
||||
</mime-type>
|
||||
'') (lib.attrValues apps)}</mime-info>
|
||||
'';
|
||||
xdg.desktopEntries = lib.mapAttrs' (app: a: lib.nameValuePair a.bin ({
|
||||
inherit (a) name;
|
||||
exec = "${a.bin} %f";
|
||||
categories = [ "Graphics" ];
|
||||
mimeType = [ a.mime ];
|
||||
} // lib.optionalAttrs (builtins.pathExists "${srcOf app}/config/font/icon.png") {
|
||||
icon = "${storeOf app}/config/font/icon.png";
|
||||
})) present;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user