From a29048ddce37e27b2b7e94b106968ebecd9464b5 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Tue, 5 Sep 2023 17:52:25 -0700 Subject: [PATCH] Use flake --- .envrc | 1 + .gitignore | 9 +- .vscode/settings.json | 5 + Cargo.toml | 25 +---- flake.lock | 96 ++++++++++++++++++ flake.nix | 66 ++++++++++++ septadrop/Cargo.toml | 22 ++++ build.rs => septadrop/build.rs | 0 {build => septadrop/build}/.gitignore | 0 {build => septadrop/build}/README.md | 0 {build => septadrop/build}/debian.sh | 0 .../septadrop_1.1.0_amd64/DEBIAN/changelog | 0 .../septadrop_1.1.0_amd64/DEBIAN/control | 0 .../septadrop_1.1.0_amd64/DEBIAN/copyright | 0 .../usr/share/applications/septadrop.desktop | 0 .../usr/share/icons/septadrop-icon.xpm | 0 {build => septadrop/build}/windows.bat | 0 {res => septadrop/res}/audio/game_over.wav | Bin {res => septadrop/res}/audio/level_up.wav | Bin .../res}/audio/new_highscore.wav | Bin {res => septadrop/res}/audio/rotate.wav | Bin {res => septadrop/res}/audio/row_clear.wav | Bin {res => septadrop/res}/audio/snap.wav | Bin .../res}/textures/background.png | Bin {res => septadrop/res}/textures/blocks.png | Bin {res => septadrop/res}/textures/icon.png | Bin {res => septadrop/res}/textures/numerals.png | Bin {res => septadrop/res}/textures/paused.png | Bin septadrop.ico => septadrop/septadrop.ico | Bin {src => septadrop/src}/config.rs | 0 {src => septadrop/src}/main.rs | 0 {src => septadrop/src}/structs/block.rs | 0 {src => septadrop/src}/structs/block_type.rs | 0 {src => septadrop/src}/structs/grid.rs | 0 {src => septadrop/src}/structs/mod.rs | 0 .../src}/structs/number_renderer.rs | 0 {src => septadrop/src}/structs/tile_type.rs | 0 37 files changed, 196 insertions(+), 28 deletions(-) create mode 100644 .envrc create mode 100644 .vscode/settings.json create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 septadrop/Cargo.toml rename build.rs => septadrop/build.rs (100%) rename {build => septadrop/build}/.gitignore (100%) rename {build => septadrop/build}/README.md (100%) rename {build => septadrop/build}/debian.sh (100%) rename {build => septadrop/build}/septadrop_1.1.0_amd64/DEBIAN/changelog (100%) rename {build => septadrop/build}/septadrop_1.1.0_amd64/DEBIAN/control (100%) rename {build => septadrop/build}/septadrop_1.1.0_amd64/DEBIAN/copyright (100%) rename {build => septadrop/build}/septadrop_1.1.0_amd64/usr/share/applications/septadrop.desktop (100%) rename {build => septadrop/build}/septadrop_1.1.0_amd64/usr/share/icons/septadrop-icon.xpm (100%) rename {build => septadrop/build}/windows.bat (100%) rename {res => septadrop/res}/audio/game_over.wav (100%) rename {res => septadrop/res}/audio/level_up.wav (100%) rename {res => septadrop/res}/audio/new_highscore.wav (100%) rename {res => septadrop/res}/audio/rotate.wav (100%) rename {res => septadrop/res}/audio/row_clear.wav (100%) rename {res => septadrop/res}/audio/snap.wav (100%) rename {res => septadrop/res}/textures/background.png (100%) rename {res => septadrop/res}/textures/blocks.png (100%) rename {res => septadrop/res}/textures/icon.png (100%) rename {res => septadrop/res}/textures/numerals.png (100%) rename {res => septadrop/res}/textures/paused.png (100%) rename septadrop.ico => septadrop/septadrop.ico (100%) rename {src => septadrop/src}/config.rs (100%) rename {src => septadrop/src}/main.rs (100%) rename {src => septadrop/src}/structs/block.rs (100%) rename {src => septadrop/src}/structs/block_type.rs (100%) rename {src => septadrop/src}/structs/grid.rs (100%) rename {src => septadrop/src}/structs/mod.rs (100%) rename {src => septadrop/src}/structs/number_renderer.rs (100%) rename {src => septadrop/src}/structs/tile_type.rs (100%) diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index b6bd966..9624092 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,3 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ - -# These are backup files generated by rustfmt -**/*.rs.bk \ No newline at end of file +/target +.direnv +result diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9a994aa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "rust-analyzer.linkedProjects": [ + "./septadrop/Cargo.toml", + ] +} diff --git a/Cargo.toml b/Cargo.toml index 5cc057f..0fcccdd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,22 +1,3 @@ -[package] -name = "septadrop" -version = "1.1.0" -edition = "2021" -build = "build.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[profile.release] -strip = true -lto = true -codegen-units = 1 - -[dependencies] -sfml = "0.16.0" -rand = "0.8.5" -home = "0.5.3" -gcd = "2.1.0" -const_format = "0.2.22" - -[build-dependencies] -winres = "0.1" \ No newline at end of file +[workspace] +members = ["septadrop"] +resolver = "2" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..45b4418 --- /dev/null +++ b/flake.lock @@ -0,0 +1,96 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1693663421, + "narHash": "sha256-ImMIlWE/idjcZAfxKK8sQA7A1Gi/O58u5/CJA+mxvl8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e56990880811a451abd32515698c712788be5720", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1693879802, + "narHash": "sha256-f+ceOsPpyiuExQIubKkLkyTZZiza1qJQGou4FZu9q1A=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "8a1d1bbe4c13eeb518e6159dd122c4f721f7543e", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a113fb1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,66 @@ +/* +Some utility commands: +- `nix flake update --commit-lock-file` +- `nix flake lock update-input ` +- `nix build .#septadrop` or `nix build .` +- `nix run .#septadrop` or `nix run .` +*/ + +{ + description = "A block game made in Rust and SFML."; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + + outputs = { self, nixpkgs, rust-overlay }: + let + overlays = [ (import rust-overlay) ]; + system = "x86_64-linux"; + pkgs = import nixpkgs { + inherit system overlays; + }; + rustSettings = with pkgs; { + src = ./.; + cargoHash = nixpkgs.lib.fakeHash; + }; + meta = with nixpkgs.lib; { + homepage = "https://git.elnu.com/ElnuDev/septadrop"; + license = [ licenses.gpl3 ]; + platforms = [ system ]; + maintainers = with maintainers; [ elnudev ]; + }; + in { + devShells.${system}.default = with pkgs; mkShell { + packages = [ + (pkgs.rust-bin.stable.latest.default.override { + extensions = [ "rust-src" ]; + }) + cargo-edit + bacon + ]; + inputsFrom = with self.packages.${system}; [ septadrop ]; + }; + packages.${system} = { + default = self.packages.${system}.septadrop; + septadrop = pkgs.rustPlatform.buildRustPackage (rustSettings // { + pname = "septadrop"; + version = "1.1.0"; + buildAndTestSubdir = "septadrop"; + buildInputs = with pkgs; [ csfml ]; + cargoHash = "sha256-1Eis+FuISmv1bn4TvOdKDxxjk/ypNqyqzLoqfmXaEVQ="; + postPatch = '' + pushd septadrop + sed -i -E "s|\"res\"|\"''${out}\/share\"|" src/config.rs + mkdir -p $out/share + cp -r res/* $out/share + popd + ''; + meta = meta // { + description = "A block game made in Rust and SFML."; + }; + }); + }; + }; +} diff --git a/septadrop/Cargo.toml b/septadrop/Cargo.toml new file mode 100644 index 0000000..5cc057f --- /dev/null +++ b/septadrop/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "septadrop" +version = "1.1.0" +edition = "2021" +build = "build.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[profile.release] +strip = true +lto = true +codegen-units = 1 + +[dependencies] +sfml = "0.16.0" +rand = "0.8.5" +home = "0.5.3" +gcd = "2.1.0" +const_format = "0.2.22" + +[build-dependencies] +winres = "0.1" \ No newline at end of file diff --git a/build.rs b/septadrop/build.rs similarity index 100% rename from build.rs rename to septadrop/build.rs diff --git a/build/.gitignore b/septadrop/build/.gitignore similarity index 100% rename from build/.gitignore rename to septadrop/build/.gitignore diff --git a/build/README.md b/septadrop/build/README.md similarity index 100% rename from build/README.md rename to septadrop/build/README.md diff --git a/build/debian.sh b/septadrop/build/debian.sh similarity index 100% rename from build/debian.sh rename to septadrop/build/debian.sh diff --git a/build/septadrop_1.1.0_amd64/DEBIAN/changelog b/septadrop/build/septadrop_1.1.0_amd64/DEBIAN/changelog similarity index 100% rename from build/septadrop_1.1.0_amd64/DEBIAN/changelog rename to septadrop/build/septadrop_1.1.0_amd64/DEBIAN/changelog diff --git a/build/septadrop_1.1.0_amd64/DEBIAN/control b/septadrop/build/septadrop_1.1.0_amd64/DEBIAN/control similarity index 100% rename from build/septadrop_1.1.0_amd64/DEBIAN/control rename to septadrop/build/septadrop_1.1.0_amd64/DEBIAN/control diff --git a/build/septadrop_1.1.0_amd64/DEBIAN/copyright b/septadrop/build/septadrop_1.1.0_amd64/DEBIAN/copyright similarity index 100% rename from build/septadrop_1.1.0_amd64/DEBIAN/copyright rename to septadrop/build/septadrop_1.1.0_amd64/DEBIAN/copyright diff --git a/build/septadrop_1.1.0_amd64/usr/share/applications/septadrop.desktop b/septadrop/build/septadrop_1.1.0_amd64/usr/share/applications/septadrop.desktop similarity index 100% rename from build/septadrop_1.1.0_amd64/usr/share/applications/septadrop.desktop rename to septadrop/build/septadrop_1.1.0_amd64/usr/share/applications/septadrop.desktop diff --git a/build/septadrop_1.1.0_amd64/usr/share/icons/septadrop-icon.xpm b/septadrop/build/septadrop_1.1.0_amd64/usr/share/icons/septadrop-icon.xpm similarity index 100% rename from build/septadrop_1.1.0_amd64/usr/share/icons/septadrop-icon.xpm rename to septadrop/build/septadrop_1.1.0_amd64/usr/share/icons/septadrop-icon.xpm diff --git a/build/windows.bat b/septadrop/build/windows.bat similarity index 100% rename from build/windows.bat rename to septadrop/build/windows.bat diff --git a/res/audio/game_over.wav b/septadrop/res/audio/game_over.wav similarity index 100% rename from res/audio/game_over.wav rename to septadrop/res/audio/game_over.wav diff --git a/res/audio/level_up.wav b/septadrop/res/audio/level_up.wav similarity index 100% rename from res/audio/level_up.wav rename to septadrop/res/audio/level_up.wav diff --git a/res/audio/new_highscore.wav b/septadrop/res/audio/new_highscore.wav similarity index 100% rename from res/audio/new_highscore.wav rename to septadrop/res/audio/new_highscore.wav diff --git a/res/audio/rotate.wav b/septadrop/res/audio/rotate.wav similarity index 100% rename from res/audio/rotate.wav rename to septadrop/res/audio/rotate.wav diff --git a/res/audio/row_clear.wav b/septadrop/res/audio/row_clear.wav similarity index 100% rename from res/audio/row_clear.wav rename to septadrop/res/audio/row_clear.wav diff --git a/res/audio/snap.wav b/septadrop/res/audio/snap.wav similarity index 100% rename from res/audio/snap.wav rename to septadrop/res/audio/snap.wav diff --git a/res/textures/background.png b/septadrop/res/textures/background.png similarity index 100% rename from res/textures/background.png rename to septadrop/res/textures/background.png diff --git a/res/textures/blocks.png b/septadrop/res/textures/blocks.png similarity index 100% rename from res/textures/blocks.png rename to septadrop/res/textures/blocks.png diff --git a/res/textures/icon.png b/septadrop/res/textures/icon.png similarity index 100% rename from res/textures/icon.png rename to septadrop/res/textures/icon.png diff --git a/res/textures/numerals.png b/septadrop/res/textures/numerals.png similarity index 100% rename from res/textures/numerals.png rename to septadrop/res/textures/numerals.png diff --git a/res/textures/paused.png b/septadrop/res/textures/paused.png similarity index 100% rename from res/textures/paused.png rename to septadrop/res/textures/paused.png diff --git a/septadrop.ico b/septadrop/septadrop.ico similarity index 100% rename from septadrop.ico rename to septadrop/septadrop.ico diff --git a/src/config.rs b/septadrop/src/config.rs similarity index 100% rename from src/config.rs rename to septadrop/src/config.rs diff --git a/src/main.rs b/septadrop/src/main.rs similarity index 100% rename from src/main.rs rename to septadrop/src/main.rs diff --git a/src/structs/block.rs b/septadrop/src/structs/block.rs similarity index 100% rename from src/structs/block.rs rename to septadrop/src/structs/block.rs diff --git a/src/structs/block_type.rs b/septadrop/src/structs/block_type.rs similarity index 100% rename from src/structs/block_type.rs rename to septadrop/src/structs/block_type.rs diff --git a/src/structs/grid.rs b/septadrop/src/structs/grid.rs similarity index 100% rename from src/structs/grid.rs rename to septadrop/src/structs/grid.rs diff --git a/src/structs/mod.rs b/septadrop/src/structs/mod.rs similarity index 100% rename from src/structs/mod.rs rename to septadrop/src/structs/mod.rs diff --git a/src/structs/number_renderer.rs b/septadrop/src/structs/number_renderer.rs similarity index 100% rename from src/structs/number_renderer.rs rename to septadrop/src/structs/number_renderer.rs diff --git a/src/structs/tile_type.rs b/septadrop/src/structs/tile_type.rs similarity index 100% rename from src/structs/tile_type.rs rename to septadrop/src/structs/tile_type.rs