From e4d397ac9cfee05bce61ab655716c558db6e4e53 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 1 May 2025 05:04:43 +0300 Subject: [PATCH] nix: init tooling --- .envrc | 2 ++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 21 +++++++++++++++++++++ nix/package.nix | 37 +++++++++++++++++++++++++++++++++++++ nix/shell.nix | 28 ++++++++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/package.nix create mode 100644 nix/shell.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..e3fecb3 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +use flake + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8372b45 --- /dev/null +++ b/flake.lock @@ -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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d93446b --- /dev/null +++ b/flake.nix @@ -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 {}; + }); + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..b9de5b4 --- /dev/null +++ b/nix/package.nix @@ -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"; + }; + } diff --git a/nix/shell.nix b/nix/shell.nix new file mode 100644 index 0000000..5df9c82 --- /dev/null +++ b/nix/shell.nix @@ -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 + ]; +}