DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

7ef8d371a6f24be63db5f73b5fcd7de5e09c93e9 — Jonni Liljamo 1 year, 9 months ago ab031c2
feat(client): add flake.nix for easy development
3 files changed, 218 insertions(+), 0 deletions(-)

A client/Cargo.lock
A client/flake.lock
A client/flake.nix
A client/Cargo.lock => client/Cargo.lock +1 -0
@@ 0,0 1,1 @@
../Cargo.lock
\ No newline at end of file

A client/flake.lock => client/flake.lock +145 -0
@@ 0,0 1,145 @@
{
  "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": 1676283394,
        "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "flake-utils_2": {
      "locked": {
        "lastModified": 1659877975,
        "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
        "owner": "numtide",
        "repo": "flake-utils",
        "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
        "type": "github"
      },
      "original": {
        "owner": "numtide",
        "repo": "flake-utils",
        "type": "github"
      }
    },
    "naersk": {
      "inputs": {
        "nixpkgs": "nixpkgs"
      },
      "locked": {
        "lastModified": 1671096816,
        "narHash": "sha256-ezQCsNgmpUHdZANDCILm3RvtO1xH8uujk/+EqNvzIOg=",
        "owner": "nix-community",
        "repo": "naersk",
        "rev": "d998160d6a076cfe8f9741e56aeec7e267e3e114",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "ref": "master",
        "repo": "naersk",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1678237502,
        "narHash": "sha256-J4cAbmC9RK+Jus3U88WaxkTsnNlZSroE2xZ9A0rSxL4=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "1eeea1f1922fb79a36008ba744310ccbf96130e2",
        "type": "github"
      },
      "original": {
        "id": "nixpkgs",
        "type": "indirect"
      }
    },
    "nixpkgs_2": {
      "locked": {
        "lastModified": 1678137616,
        "narHash": "sha256-T+lWTRdcYaOnZQW+Ehdlg+YldC2l9cq2GXJFPq22Nxc=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "7edcdf7b169c33cd3eef9aba50521ce93ee666b8",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-22.11",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "nixpkgs_3": {
      "locked": {
        "lastModified": 1665296151,
        "narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
        "owner": "NixOS",
        "repo": "nixpkgs",
        "rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
        "type": "github"
      },
      "original": {
        "owner": "NixOS",
        "ref": "nixpkgs-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "flake-compat": "flake-compat",
        "flake-utils": "flake-utils",
        "naersk": "naersk",
        "nixpkgs": "nixpkgs_2",
        "rust-overlay": "rust-overlay"
      }
    },
    "rust-overlay": {
      "inputs": {
        "flake-utils": "flake-utils_2",
        "nixpkgs": "nixpkgs_3"
      },
      "locked": {
        "lastModified": 1678242776,
        "narHash": "sha256-36K1Rg2vM+NLqORSBL4e3aZHmgkb6aS9upHsuG4Akns=",
        "owner": "oxalica",
        "repo": "rust-overlay",
        "rev": "ea311f10a5d51e7588799281bab0556b4e978d00",
        "type": "github"
      },
      "original": {
        "owner": "oxalica",
        "repo": "rust-overlay",
        "type": "github"
      }
    }
  },
  "root": "root",
  "version": 7
}

A client/flake.nix => client/flake.nix +72 -0
@@ 0,0 1,72 @@
{
  description = "Laurelin Client";

  inputs = {
    naersk.url = "github:nix-community/naersk/master";
    nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
    flake-utils.url = "github:numtide/flake-utils";
    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };
    rust-overlay.url = "github:oxalica/rust-overlay";
  };

  outputs = inputs@{ self, nixpkgs, flake-utils, naersk, rust-overlay, ... }:
  flake-utils.lib.eachDefaultSystem (system: 
  let
    overlays = [ (import rust-overlay) ];
    pkgs = import nixpkgs { inherit system overlays; };
    rustVersion = "1.67.1";
    rust = pkgs.rust-bin.stable.${rustVersion}.default.override {
      extensions = [
        "rust-src"
      ];
    };
    naersk-lib = pkgs.callPackage naersk { };
    libPath = with pkgs; lib.makeLibraryPath [
      alsa-lib
      libxkbcommon
      openssl
      udev
      vulkan-loader
      wayland
    ];
    in {
      defaultPackage = naersk-lib.buildPackage {
        src = ./.;
        doCheck = true;
        pname = "client";
        nativeBuildInputs = [ pkgs.makeWrapper ];
        buildInputs = with pkgs; [
          
        ];
        postInstall = ''
          wrapProgram "$out/bin/client" --prefix LD_LIBRARY_PATH : "${libPath}"
        '';
      };

      apps.default = flake-utils.lib.mkApp {
        drv = self.defaultPackage."${system}";
      };


      devShell = with pkgs; pkgs.mkShell {
        buildInputs = [
          rust

          pkg-config
          clang
          mold

          alsa-lib
          libxkbcommon
          openssl
          udev
          wayland
        ];
        RUST_SRC_PATH = rustPlatform.rustLibSrc;
        LD_LIBRARY_PATH = libPath;
      };
    });
}