From b78133a5c46035deada775cb58a6ce801d850eea Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 22 Dec 2024 18:44:11 +0300 Subject: [PATCH] nix: init tooling --- .envrc | 1 + flake.lock | 26 ++++++++++++++++++++++++++ flake.nix | 23 +++++++++++++++++++++++ nix/package.nix | 12 ++++++++++++ nix/shell.nix | 27 +++++++++++++++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/package.nix create mode 100644 nix/shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..9c87edac --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1734880952, + "narHash": "sha256-ZTt3x0DN55JGjdYv8TEDC/YDxcYfpFDLApYvKFMnxNM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "578baae41df4920fb34db92ae3a312c23ea90b89", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..5c3eedc0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,23 @@ +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + + outputs = { + self, + nixpkgs, + }: let + systems = ["x86_64-linux" "aarch64-linux"]; + forEachSystem = nixpkgs.lib.genAttrs systems; + + pkgsForEach = nixpkgs.legacyPackages; + in rec { + packages = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./nix/package.nix {}; + }); + + devShells = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./nix/shell.nix {}; + }); + + hydraJobs = packages; + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 00000000..a9d4e2e5 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,12 @@ +{rustPlatform}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "mrc"; + version = "0.0.1"; + src = ./.; + + cargoLock.lockFile = finalAttrs.src + /Cargo.lock; + meta = { + description = "MPV IPC wrapper"; + mainProgram = "mrc"; + }; +}) diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 00000000..65df8894 --- /dev/null +++ b/nix/shell.nix @@ -0,0 +1,27 @@ +{ + mkShell, + rust-analyzer, + rustfmt, + clippy, + cargo, + gcc, + openssl, + pkg-config, + rustc, +}: +mkShell { + name = "mrc"; + packages = [ + rust-analyzer + rustfmt + clippy + cargo + cargo + gcc + clippy + rustfmt + openssl + pkg-config + rustc + ]; +}