Skip to content

Commit

Permalink
chore(nix): nix flake shell + rust-toolchain.toml setup (#14)
Browse files Browse the repository at this point in the history
* nix flake shell + rust-toolchain.toml setup

* migrated to naersk + nixpkgs-mozilla, it works for this workspace setup, updated Cargo.toml by autoformatting with taplo and adding reame to workspace.package to make `nix build` work
  • Loading branch information
tukanoidd authored Nov 11, 2024
1 parent b1fe018 commit 65bb26e
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
watch_file flake.nix

use flake .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ Cargo.lock

.data/*.log

# Direnv (Nix Shell)
.direnv/
11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ categories = [
"concurrency",
"development-tools",
]
include = ["LICENSE", "README.md", "crates/television/**/*.rs", "build.rs", ".config/config.toml"]
include = [
"LICENSE",
"README.md",
"crates/television/**/*.rs",
"build.rs",
".config/config.toml",
]
rust-version = "1.80.0"

[workspace]
Expand All @@ -38,6 +44,7 @@ categories = [
]
include = ["LICENSE", "README.md", "crates/television/**/*.rs", "build.rs"]
rust-version = "1.80.0"
readme = "README.md"


[[bin]]
Expand Down Expand Up @@ -106,8 +113,6 @@ vergen-gix = { version = "1.0.0", features = ["build", "cargo", "rustc"] }
crossterm = { version = "0.28.1", features = ["serde", "use-dev-tty"] }




[profile.staging]
inherits = "dev"
opt-level = 3
Expand Down
109 changes: 109 additions & 0 deletions flake.lock

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

66 changes: 66 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

nixpkgs-mozilla = {
url = "github:mozilla/nixpkgs-mozilla";
flake = false;
};

flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
};

outputs = {
self,
flake-utils,
naersk,
nixpkgs,
nixpkgs-mozilla,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = (import nixpkgs) {
inherit system;

overlays = [
(import nixpkgs-mozilla)
];
};

toolchain =
(
pkgs.rustChannelOf
{
rustToolchain = ./rust-toolchain.toml;
sha256 = "6eN/GKzjVSjEhGO9FhWObkRFaE1Jf+uqMSdQnb8lcB4=";
}
)
.rust;

naersk' = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
};
in {
packages.default = naersk'.buildPackage {
src = ./.;
};
apps = {
default = flake-utils.lib.mkApp {
drv = self.packages.${system}.default;
exePath = "/bin/tv";
};
};

devShell = pkgs.mkShell {
nativeBuildInputs = [toolchain];
packages = with pkgs; [
rustfmt
clippy
rust-analyzer
];
};
}
);
}
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.80.0"
components = ["rustfmt", "clippy", "rust-analyzer"]

0 comments on commit 65bb26e

Please sign in to comment.