nix: initial tooling setup

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Ia510d6575a3796118a14dbc834af1ba16a6a6964
This commit is contained in:
raf 2026-01-29 21:12:51 +03:00
commit 563ff2b187
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
5 changed files with 125 additions and 0 deletions

2
.envrc Normal file
View file

@ -0,0 +1,2 @@
use flake

27
flake.lock generated Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1769461804,
"narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "bfc1b8a4574108ceef22f02bafcf6611380c100d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

22
flake.nix Normal file
View file

@ -0,0 +1,22 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
outputs = {
self,
nixpkgs,
}: let
systems = ["x86_64-linux"];
forEachSystem = nixpkgs.lib.genAttrs systems;
pkgsForEach = nixpkgs.legacyPackages;
in {
packages = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./nix/package.nix {};
});
devShells = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {};
});
hydraJobs = self.packages;
};
}

29
nix/package.nix Normal file
View file

@ -0,0 +1,29 @@
{
lib,
rustPlatform,
}:
rustPlatform.buildRustPackage (finalAttrs: {
pname = "sample-rust";
version = "0.1.0";
src = let
fs = lib.fileset;
s = ../.;
in
fs.toSource {
root = s;
fileset = fs.unions [
(fs.fileFilter (file: builtins.any file.hasExt ["rs"]) (s + /src))
(s + /Cargo.lock)
(s + /Cargo.toml)
];
};
cargoLock.lockFile = "${finalAttrs.src}/Cargo.lock";
enableParallelBuilding = true;
meta = {
description = "Sample Rust project";
maintainers = with lib.maintainers; [NotAShelf];
};
})

45
nix/shell.nix Normal file
View file

@ -0,0 +1,45 @@
{
mkShell,
rustc,
cargo,
lld,
rust-analyzer-unwrapped,
rustfmt,
clippy,
taplo,
cargo-nextest,
rustPlatform,
# Build deps
openssl,
pkg-config,
}:
mkShell {
name = "rust";
strictDeps = true;
packages = [
rustc
cargo
lld
# Tools
(rustfmt.override {asNightly = true;})
clippy
cargo
taplo
rust-analyzer-unwrapped
# Additional Cargo tooling
cargo-nextest
];
buildInputs = [
openssl
];
nativeBuildInputs = [
pkg-config
];
env.RUST_SRC_PATH = "${rustPlatform.rustLibSrc}";
}