default.nix: init, flake.nix: add app

This commit is contained in:
Oystein Kristoffer Tveit 2024-08-04 04:08:34 +02:00
parent a89cb24c86
commit e9190f7879
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
3 changed files with 55 additions and 2 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target
result

34
default.nix Normal file
View File

@ -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";
};
}

View File

@ -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 { };
});
};
}