forked from I-am-Erk/CDDA-Tilesets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for nix flake (I-am-Erk#2117)
- Loading branch information
1 parent
2564064
commit 2a730c5
Showing
7 changed files
with
156 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if ! has nix_direnv_version || ! nix_direnv_version 2.1.1; then | ||
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.1/direnvrc" "sha256-b6qJ4r34rbE23yWjMqbmu3ia2z4b2wIlZUksBke/ol0=" | ||
fi | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Nix Installation | ||
|
||
Documentation of developing tileset with [Nix](https://nixos.org/). | ||
|
||
## Build | ||
|
||
As this repository uses flakes, it's possible to build any of the tileset (not only UlitCa) using `nix build .#{name}` command. For example: | ||
|
||
```sh | ||
# This will build UltiCa | ||
nix build .#UltimateCataclysm | ||
|
||
# But this will build Mushroom Dream | ||
nix build .#Mushroom-Dream | ||
``` | ||
|
||
And the result will be in *result* directory, ready to put into the game. If you want to link the result to the different directory, use `--out-link {path}` argument. | ||
|
||
## Devshell | ||
|
||
Tileset flake also provide a simple devshell with python and vips to run tools such as `compose.py` or `generate_preview.py`. | ||
|
||
```sh | ||
# Enter the devshell | ||
nix develop . | ||
|
||
# This now works | ||
python3 tools/compose.py --use-all gfx/UltimateCataclysm out | ||
``` | ||
|
||
Or if you have [direnv](https://direnv.net/) enabled, it will automatically enter the devshell upon opening the repository. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
inputs = { | ||
nixpkgs = { | ||
url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
}; | ||
utils = { | ||
url = "github:numtide/flake-utils"; | ||
}; | ||
}; | ||
|
||
outputs = { self, nixpkgs, utils }: | ||
utils.lib.eachDefaultSystem (system: | ||
let | ||
pkgs = import nixpkgs { inherit system; }; | ||
|
||
requires = with pkgs; [ | ||
(python311.withPackages(ps: [ ps.pyvips ])) | ||
vips | ||
]; | ||
in | ||
rec { | ||
# `nix build` | ||
packages = (pkgs.lib.mapAttrs' (name: _: | ||
pkgs.lib.nameValuePair name (pkgs.stdenv.mkDerivation { | ||
inherit name; | ||
version = "master"; | ||
src = ./gfx/${name}; | ||
buildInputs = requires; | ||
|
||
dontCheck = true; | ||
dontPatch = true; | ||
dontConfigure = true; | ||
|
||
buildPhase = '' | ||
python3 ${./tools/compose.py} --use-all --feedback CONCISE . compiled | ||
''; | ||
installPhase = '' | ||
mkdir -p $out | ||
cp compiled/* $out | ||
for file in [ "fallback.png" "layering.json" "tileset.txt" ]; do | ||
[ -f "$file" ] && cp "$file" $out ||: | ||
done | ||
''; | ||
}) | ||
) (builtins.readDir ./gfx)); | ||
|
||
# `nix develop` | ||
devShell = pkgs.mkShell rec { | ||
nativeBuildInputs = requires; | ||
}; | ||
}); | ||
} |