Add nix build and development files
This commit is contained in:
parent
18eeea5539
commit
1bb6cea247
|
|
@ -1,3 +1,4 @@
|
|||
*md.backup
|
||||
src/.godot/
|
||||
*.blend1
|
||||
result
|
||||
|
|
|
|||
|
|
@ -9,6 +9,14 @@ Frame of Mind is a queer game about mental health.
|
|||
## Installation
|
||||
Get [Godot](https://godotengine.org/download) and open the src folder as a new project.
|
||||
|
||||
## Building and developing with Nix
|
||||
### Building
|
||||
This project can be build with `$ nix-build` or `$ nix build` (flakes).
|
||||
### Building for Linux without Nix
|
||||
Use `$ nix bundle`, the resulting binary should be completly self contained.
|
||||
### Developing
|
||||
It is recommended to use `direnv`, but `$ nix develop`, `$ nix shell` and `$ nix-shell` also work.
|
||||
|
||||
## Support Me
|
||||
You can support the development of Frame of Mind by
|
||||
- [Becoming a Patreon](https://www.patreon.com/betalars)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
(import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
) {
|
||||
src = ./.;
|
||||
})
|
||||
.defaultNix
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1678901627,
|
||||
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "flake-utils",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1679793451,
|
||||
"narHash": "sha256-JafTtgMDATE8dZOImBhWMA9RCn9AP8FVOpN+9K/tTlg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0cd51a933d91078775b300cf0f29aa3495231aa2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
{
|
||||
description = "Frame of Mind";
|
||||
|
||||
inputs = {
|
||||
flake-compat = {
|
||||
url = "github:edolstra/flake-compat";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
flake-compat,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
|
||||
overlays = [
|
||||
(self: super: {
|
||||
godot = super.godot_4;
|
||||
|
||||
godot-export-templates =
|
||||
(super.godot_4.overrideAttrs (old: let
|
||||
version = builtins.replaceStrings ["-"] ["."] old.version;
|
||||
in {
|
||||
pname = "godot-export-templates";
|
||||
|
||||
installPhase = ''
|
||||
# The godot export command expects the export templates at
|
||||
# .../share/godot/export_templates/4.0.stable/linux_release.x86_64 with 4.0_stable being the godot version.
|
||||
mkdir -p "$out/share/godot/export_templates/${version}"
|
||||
cp bin/godot* "$out/share/godot/export_templates/${version}/linux_release.x86_64"
|
||||
'';
|
||||
|
||||
# https://docs.godotengine.org/en/stable/development/compiling/optimizing_for_size.html
|
||||
# Stripping reduces the template size from around 500MB to 40MB for Linux.
|
||||
# This also impacts the size of the exported games.
|
||||
# This is added explicitly here because mkDerivation does not automatically
|
||||
# strip binaries in the template directory.
|
||||
stripAllList = (old.stripAllList or []) ++ ["share/godot/export_templates"];
|
||||
|
||||
outputs = ["out"];
|
||||
|
||||
meta.description = "Free and Open Source 2D and 3D game engine (export templates)";
|
||||
}))
|
||||
.override
|
||||
{
|
||||
withTarget = "template_release";
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
in rec {
|
||||
packages = rec {
|
||||
frame-of-mind = pkgs.stdenv.mkDerivation rec {
|
||||
pname = "frame-of-mind";
|
||||
version = "0.0.0";
|
||||
src = ./src;
|
||||
src-logo = ./design/smol_logo.png;
|
||||
dontUnpack = true;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
copyDesktopItems
|
||||
godot
|
||||
];
|
||||
|
||||
runtimeDependencies = pkgs.godot.runtimeDependencies;
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
cp -r ${src}/* ./
|
||||
|
||||
# Cannot create file '/homeless-shelter/.config/godot/projects/...'
|
||||
export HOME=$TMPDIR
|
||||
|
||||
# Link the export-templates to the expected location. The --export commands
|
||||
# expects the template-file at .../templates/<version>/linux_x11_64_release
|
||||
mkdir -p $HOME/.local/share/godot
|
||||
ln -sr ${pkgs.godot-export-templates}/share/godot/export_templates $HOME/.local/share/godot/export_templates
|
||||
|
||||
mkdir -p $out/share/${pname}
|
||||
# This just copies the export template and packs the game files next to it
|
||||
godot --headless --export-release "linux" $out/share/${pname}/${pname}
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
ln -s $out/share/${pname}/${pname} $out/bin
|
||||
|
||||
mkdir -p $out/share/pixmaps
|
||||
cp ${src-logo} $out/share/pixmaps/${pname}.png
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
# Godot has some "optional" dependencies like display drivers
|
||||
patchelf --set-rpath ${pkgs.lib.makeLibraryPath runtimeDependencies} $out/share/${pname}/${pname}
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(pkgs.makeDesktopItem {
|
||||
name = "Frame of Mind";
|
||||
exec = pname;
|
||||
icon = pname;
|
||||
desktopName = "Frame of Mind";
|
||||
comment = "";
|
||||
genericName = "";
|
||||
categories = ["Game"];
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
devShell = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [
|
||||
godot
|
||||
godot-export-templates
|
||||
blender
|
||||
inkscape
|
||||
];
|
||||
|
||||
# FIXME
|
||||
shellHook = ''
|
||||
GODOT_EXPORT_TEMPLATE=${pkgs.godot-export-templates}/share/godot/templates/*/linux_x11_64_release
|
||||
'';
|
||||
};
|
||||
defaultPackage = packages.frame-of-mind;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
(import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
) {
|
||||
src = ./.;
|
||||
})
|
||||
.shellNix
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
[preset.0]
|
||||
|
||||
name="linux"
|
||||
platform="Linux/X11"
|
||||
runnable=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="../build/linux/frame-of-mind.x86_64"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
script_encryption_key=""
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
debug/export_console_script=1
|
||||
binary_format/embed_pck=false
|
||||
texture_format/bptc=true
|
||||
texture_format/s3tc=true
|
||||
texture_format/etc=false
|
||||
texture_format/etc2=false
|
||||
binary_format/architecture="x86_64"
|
||||
ssh_remote_deploy/enabled=false
|
||||
ssh_remote_deploy/host="user@host_ip"
|
||||
ssh_remote_deploy/port="22"
|
||||
ssh_remote_deploy/extra_args_ssh=""
|
||||
ssh_remote_deploy/extra_args_scp=""
|
||||
ssh_remote_deploy/run_script="#!/usr/bin/env bash
|
||||
export DISPLAY=:0
|
||||
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
|
||||
\"{temp_dir}/{exe_name}\" {cmd_args}"
|
||||
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
|
||||
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
|
||||
rm -rf \"{temp_dir}\""
|
||||
Loading…
Reference in New Issue