From b1b9c6446897a09c8735ffede96c9affc4135e1f Mon Sep 17 00:00:00 2001 From: august kline Date: Wed, 10 Apr 2024 18:10:25 -0400 Subject: [PATCH] nix! flakes! --- .gitignore | 1 + flake.lock | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 62 +++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index b995fdb..e85b4e6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ log george.o .DS_Store *.bin +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..71af2c7 --- /dev/null +++ b/flake.lock @@ -0,0 +1,112 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1698420672, + "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", + "owner": "nmattia", + "repo": "naersk", + "rev": "aeb58d5e8faead8980a807c840232697982d47b9", + "type": "github" + }, + "original": { + "owner": "nmattia", + "ref": "master", + "repo": "naersk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1712696601, + "narHash": "sha256-puFPFSa/RC83JilUgB48/VL387eu2QN066Jv6X971LY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "062fc6cf99d809921ecef47317752fc92468e6ae", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1712608508, + "narHash": "sha256-vMZ5603yU0wxgyQeHJryOI+O61yrX2AHwY6LOFyV1gM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4cba8b53da471aea2ab2b0c1f30a81e7c451f4b6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2", + "utils": "utils" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8a254bb --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + inputs = { + naersk.url = "github:nmattia/naersk/master"; + # This must be the stable nixpkgs if you're running the app on a + # stable NixOS install. Mixing EGL library versions doesn't work. + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + utils.url = "github:numtide/flake-utils"; + flake-compat = { + url = github:edolstra/flake-compat; + flake = false; + }; + }; + + outputs = { self, nixpkgs, utils, naersk, ... }: + utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + naersk-lib = pkgs.callPackage naersk { }; + libPath = with pkgs; lib.makeLibraryPath [ + libxkbcommon + wayland + xorg.libX11 + xorg.libXcursor + xorg.libXi + xorg.libXrandr + ]; + in + { + defaultPackage = naersk-lib.buildPackage { + src = ./.; + doCheck = true; + pname = "georgeemu"; + nativeBuildInputs = [ pkgs.makeWrapper ]; + buildInputs = with pkgs; [ + xorg.libxcb + ]; + postInstall = '' + wrapProgram "$out/bin/georgeemu" --prefix LD_LIBRARY_PATH : "${libPath}" + ''; + }; + + defaultApp = utils.lib.mkApp { + drv = self.defaultPackage."${system}"; + }; + + devShell = with pkgs; mkShell { + buildInputs = [ + cargo + cargo-insta + pre-commit + rust-analyzer + rustPackages.clippy + rustc + rustfmt + + xorg.libxcb + ]; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + LD_LIBRARY_PATH = libPath; + }; + }); +}