Skip to content

Commit

Permalink
Merge pull request #2 from olafklingt/nix
Browse files Browse the repository at this point in the history
Nix
  • Loading branch information
alisomay authored Nov 21, 2023
2 parents 9730bfd + 515d9b0 commit c8b54d0
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 0 deletions.
95 changes: 95 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
# Define the inputs required for this flake.
inputs = {
# The version of nixpkgs we're using. We need a newer rustc that is available on the unstable banch.
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

# The flake-utils provide helpful utilities for managing flakes.
utils.url = "github:numtide/flake-utils";

# naersk is used for building Rust projects with Nix.
naersk.url = "github:nix-community/naersk/master";
};

# Define the outputs of the flake, which depend on the inputs and the current flake.
outputs = { self, nixpkgs, utils, naersk }:
# Use flake-utils to generate outputs for each system supported by default.
utils.lib.eachDefaultSystem (system:
let
# Import the nixpkgs for the given system.
pkgs = import nixpkgs { inherit system; };

# Instantiate naersk with the current package set.
naerskLib = pkgs.callPackage naersk { };

# Name of the Rust project.
name = "smrec";

# Build-time dependencies.
nativeBuildInputs = with pkgs; [
cargo # Cargo, the Rust package manager.
rustc # The Rust compiler.
pkg-config # Helper tool used when compiling applications and libraries.
];

# Runtime dependencies.
buildInputs = with pkgs; [
alsa-lib # ALSA library for audio.
jack2 # JACK Audio Connection Kit.
];
in
{
# Define a development shell for this project.
devShells.default = pkgs.mkShell
{
# Pass both build-time and runtime dependencies to the shell environment.
inherit buildInputs nativeBuildInputs;
};

# Define the Rust package.
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = name; # Package name.
version = "0.2.1"; # Version of the package.
inherit buildInputs nativeBuildInputs;
src = ./.; # Source directory for the Rust project.
cargoLock = {
lockFile = ./Cargo.lock; # Path to the Cargo.lock file.
# Specific output hashes for dependencies, required for reproducibility.
outputHashes = {
"asio-sys-0.2.1" = "sha256-MPknKFVyxTDI7r4xC860RSOa9zmB/iQsCZeAlvE8cdk=";
};
};
};

# Define the application produced by this project.
apps.default = {
type = "app"; # Type is an application.
# The path to the executable that will run the app.
program = "${self.packages.${system}.default}/bin/${name}";
};
});
}

0 comments on commit c8b54d0

Please sign in to comment.