chore(nix): nix flake shell + rust-toolchain.toml setup (#14)

* 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
This commit is contained in:
Vitalii Lukyanov 2024-11-11 22:37:21 +01:00 committed by GitHub
parent b1fe0182f8
commit 65bb26ec84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 191 additions and 3 deletions

3
.envrc Normal file
View File

@ -0,0 +1,3 @@
watch_file flake.nix
use flake .

2
.gitignore vendored
View File

@ -18,3 +18,5 @@ Cargo.lock
.data/*.log
# Direnv (Nix Shell)
.direnv/

View File

@ -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]
@ -38,6 +44,7 @@ categories = [
]
include = ["LICENSE", "README.md", "crates/television/**/*.rs", "build.rs"]
rust-version = "1.80.0"
readme = "README.md"
[[bin]]
@ -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

109
flake.lock generated Normal file
View File

@ -0,0 +1,109 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1726560853,
"narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1721727458,
"narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
"owner": "nix-community",
"repo": "naersk",
"rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 0,
"narHash": "sha256-30FKRgiiFsMdSSkujzQCK97NuY1JeMS4L5hQWlHAQ0c=",
"path": "/nix/store/6bml58svmvrhn1bnb1ag49rqfr2gmdv3-source",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs-mozilla": {
"flake": false,
"locked": {
"lastModified": 1704373101,
"narHash": "sha256-+gi59LRWRQmwROrmE1E2b3mtocwueCQqZ60CwLG+gbg=",
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "9b11a87c0cc54e308fa83aac5b4ee1816d5418a2",
"type": "github"
},
"original": {
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1730958623,
"narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "85f7e662eda4fa3a995556527c87b2524b691933",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"nixpkgs-mozilla": "nixpkgs-mozilla"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

66
flake.nix Normal file
View File

@ -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
rust-toolchain.toml Normal file
View File

@ -0,0 +1,3 @@
[toolchain]
channel = "1.80.0"
components = ["rustfmt", "clippy", "rust-analyzer"]