diff --git a/.envrc b/.envrc index 41dc922..0557568 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,3 @@ -use nix +use flake . --accept-flake-config; source .envrc-local \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3c29b88..8e2b7b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ /target .DS_Store */.DS_Store -.envrc-local \ No newline at end of file +.envrc-local +/.vscode +/.direnv +/result \ No newline at end of file diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..960ffe0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,54 @@ +{ + description = "PlanetSide 2 Metagame Harvesting Service"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + nixConfig = { + extra-substituters = [ + "https://nix-community.cachix.org" + ]; + + extra-trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + + outputs = inputs: inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "x86_64-linux" "aarch64-linux" ]; + perSystem = { config, self', pkgs, lib, system, ... }: let + fenix = inputs.fenix.packages.${system}.minimal; + cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); + + buildDeps = [ + pkgs.openssl + ]; + + devDeps = [ + fenix.toolchain + ]; + PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; + in { + packages.default = (pkgs.makeRustPlatform { + cargo = fenix.toolchain; + rustc = fenix.toolchain; + }).buildRustPackage { + inherit (cargoToml.package) name version; + cargoLock.lockFile = ./Cargo.lock; + src = ./.; + nativeBuildInputs = [ pkgs.pkg-config ]; + buildInputs = buildDeps ++ devDeps; + }; + + devShells.default = pkgs.mkShell { + nativeBuildInputs = buildDeps ++ devDeps; + }; + }; + }; +} \ No newline at end of file diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 25e0f7a..0000000 --- a/shell.nix +++ /dev/null @@ -1,12 +0,0 @@ -let - moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz); - nixpkgs = import { overlays = [ moz_overlay ]; }; -in - with nixpkgs; - stdenv.mkDerivation { - name = "moz_overlay_shell"; - buildInputs = [ - nixpkgs.latest.rustChannels.nightly.rust - nixpkgs.rust-analyzer - ]; - } \ No newline at end of file