nix: init tooling

This commit is contained in:
raf 2025-05-01 05:04:43 +03:00
commit e4d397ac9c
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
5 changed files with 115 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": 1745930157,
"narHash": "sha256-y3h3NLnzRSiUkYpnfvnS669zWZLoqqI6NprtLQ+5dck=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "46e634be05ce9dc6d4db8e664515ba10b78151ae",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

21
flake.nix Normal file
View file

@ -0,0 +1,21 @@
{
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: {
eris = pkgsForEach.${system}.callPackage ./nix/package.nix {};
default = self.packages.${system}.eris;
});
devShells = forEachSystem (system: {
default = pkgsForEach.${system}.callPackage ./nix/shell.nix {};
});
};
}

37
nix/package.nix Normal file
View file

@ -0,0 +1,37 @@
{
lib,
rustPlatform,
}: let
fs = lib.fileset;
lockfile = ../Cargo.lock;
cargoToml = ../Cargo.toml;
in
rustPlatform.buildRustPackage {
pname = "eris";
version = "0.0.1";
src = let
s = ../.;
in
fs.toSource {
root = s;
fileset = fs.unions [
(fs.fileFilter (file: builtins.any file.hasExt ["rs"]) s + /src)
lockfile
cargoToml
];
};
postInstall = ''
mkdir -p $out/share
install -Dm755 ${../contrib} $out/share/contrib
'';
cargoLock.lockFile = lockfile;
meta = {
description = "Sophisticated HTTP tarpit and honeypot stream";
mainProgram = "eris";
};
}

28
nix/shell.nix Normal file
View file

@ -0,0 +1,28 @@
{
mkShell,
rust-analyzer,
rustfmt,
clippy,
cargo,
gcc,
openssl,
pkg-config,
rustc,
}:
mkShell {
name = "eris";
packages = [
rust-analyzer
rustfmt
clippy
cargo
gcc
clippy
rustfmt
rustc
# For TLS and friends
openssl
pkg-config
];
}