diff --git a/.gitignore b/.gitignore index ea8c4bf..07c12f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +result diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..03a14cb --- /dev/null +++ b/default.nix @@ -0,0 +1,34 @@ +{ + lib +, fetchFromGitHub +, rustPlatform +, makeWrapper +, mpv +}: + +rustPlatform.buildRustPackage rec { + pname = "greg-ng"; + version = "0.1.0"; + src = lib.cleanSource ./.; + + nativeBuildInputs = [ makeWrapper ]; + + cargoLock = { + lockFile = ./Cargo.lock; + outputHashes = { + "mpvipc-async-0.1.0" = "sha256-2TQ2d4q9/DTxTZe9kOAoKBhsmegRZw32x3G2hbluS6U="; + }; + }; + + postInstall = '' + wrapProgram $out/bin/greg-ng \ + --prefix PATH : '${lib.makeBinPath [ mpv ]}' + ''; + + meta = with lib; { + license = licenses.mit; + maintainers = with maintainers; [ h7x4 ]; + platforms = platforms.linux ++ platforms.darwin; + mainProgram = "greg-ng"; + }; +} diff --git a/flake.nix b/flake.nix index 5207955..227c897 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,8 @@ outputs = { self, nixpkgs, rust-overlay }: let + inherit (nixpkgs) lib; + systems = [ "x86_64-linux" "aarch64-linux" @@ -15,7 +17,8 @@ "aarch64-darwin" "armv7l-linux" ]; - forAllSystems = f: nixpkgs.lib.genAttrs systems (system: let + + forAllSystems = f: lib.genAttrs systems (system: let pkgs = import nixpkgs { inherit system; overlays = [ @@ -27,6 +30,16 @@ toolchain = rust-bin.stable.latest.default; in f system pkgs toolchain); in { + apps = forAllSystems (system: pkgs: _: { + default = self.apps.${system}.greg-ng; + greg-ng = let + package = self.packages.${system}.greg-ng; + in { + type = "app"; + program = lib.getExe package; + }; + }); + devShells = forAllSystems (system: pkgs: toolchain: { default = pkgs.mkShell { nativeBuildInputs = [ @@ -37,5 +50,10 @@ RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; }; }); + + packages = forAllSystems (system: pkgs: _: { + default = self.packages.${system}.greg-ng; + greg-ng = pkgs.callPackage ./default.nix { }; + }); }; -} \ No newline at end of file +}