feat: adding nix flake and rust toolchain

This commit is contained in:
Andrew Rioux 2025-01-15 16:51:55 -05:00
commit 8c4c6674a1
Signed by: andrew.rioux
GPG Key ID: 9B8BAC47C17ABB94
3 changed files with 270 additions and 0 deletions

185
flake.lock generated Normal file
View File

@ -0,0 +1,185 @@
{
"nodes": {
"crane": {
"locked": {
"lastModified": 1736898272,
"narHash": "sha256-D10wlrU/HCpSRcb3a7yk+bU3ggpMD1kGbseKtO+7teo=",
"owner": "ipetkov",
"repo": "crane",
"rev": "6a589f034202a7c6e10bce6c5d1d392d7bc0f340",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1736836313,
"narHash": "sha256-zdZ7/T6yG0/hzoVOiNpDiR/sW3zR6oSMrfIFJK2BrrE=",
"owner": "nix-community",
"repo": "fenix",
"rev": "056c9393c821a4df356df6ce7f14c722dc8717ec",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"libnl": {
"flake": false,
"locked": {
"lastModified": 1736681776,
"narHash": "sha256-8j5x5+2Bo+GHn3CQUcrX59nE2zrD6zoEERJAnuuK3vk=",
"ref": "refs/heads/main",
"rev": "b3822aa3b605b2dc5f01f9aee8ee224fc23e23a0",
"revCount": 2135,
"type": "git",
"url": "https://github.com/thom311/libnl"
},
"original": {
"type": "git",
"url": "https://github.com/thom311/libnl"
}
},
"libpcap-src": {
"flake": false,
"locked": {
"lastModified": 1736964815,
"narHash": "sha256-qXgILw6Br5kanQzTmPC5P0JBZFyO7jSdKKyl4UdtD4Q=",
"ref": "refs/heads/master",
"rev": "515022131fa902b2641bcf3bf40f323b0dd726f7",
"revCount": 6396,
"type": "git",
"url": "https://github.com/the-tcpdump-group/libpcap"
},
"original": {
"type": "git",
"url": "https://github.com/the-tcpdump-group/libpcap"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1736867362,
"narHash": "sha256-i/UJ5I7HoqmFMwZEH6vAvBxOrjjOJNU739lnZnhUln8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "9c6b49aeac36e2ed73a8c472f1546f6d9cf1addc",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"crane": "crane",
"fenix": "fenix",
"flake-utils": "flake-utils",
"libnl": "libnl",
"libpcap-src": "libpcap-src",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
"winpcap": "winpcap"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1736690231,
"narHash": "sha256-g9gyxX+F6CrkT5gRIMKPnCPom0o9ZDzYnzzeNF86D6Q=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "8364ef299790cb6ec22b9e09e873c97dbe9f2cb5",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1736907983,
"narHash": "sha256-fw55wVwpJW36Md2HZBKuxX3YHGeqsGsspPLtCMVr1Y8=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "eaa365c911441e07e387ff6acc596619fc50b156",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"winpcap": {
"flake": false,
"locked": {
"lastModified": 1277475020,
"narHash": "sha256-lea+6c9obTpxWosi2xRXUxV4+whsCTWMJ7wxZNASRz8=",
"type": "tarball",
"url": "https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip"
},
"original": {
"type": "tarball",
"url": "https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip"
}
}
},
"root": "root",
"version": 7
}

80
flake.nix Normal file
View File

@ -0,0 +1,80 @@
{
description = "Sparse C2 framework";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
libpcap-src = {
url = "git+https://github.com/the-tcpdump-group/libpcap";
flake = false;
};
libnl = {
url = "git+https://github.com/thom311/libnl";
flake = false;
};
winpcap = {
url = "https://www.winpcap.org/install/bin/WpdPack_4_1_2.zip";
flake = false;
};
#freebsd = {
# url =
# "https://download.freebsd.org/releases/ISO-IMAGES/14.1/FreeBSD-14.1-RELEASE-amd64-dvd1.iso";
# flake = false;
#};
};
outputs = { self, nixpkgs, flake-utils, crane, fenix, rust-overlay
, libpcap-src, libnl, winpcap }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) fenix.overlays.default ];
config.allowUnfree = true;
};
linuxBuildTools = with pkgs; [
autoconf
automake
bison
cmake
flex
libtool
libpcap
musl
pkg-config
];
windowsBuildTools = linuxBuildTools ++ (with pkgs; [
pkgsCross.mingwW64.stdenv.cc
pkgsCross.mingwW64.windows.pthreads
]);
toolchain =
pkgs.pkgsMusl.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
in {
devShells.default = craneLib.devShell {
name = "sparse";
buildInputs = windowsBuildTools
++ (with pkgs; [ rust-analyzer packer ]);
SPARSE_BUILD_WINPCAP = "${winpcap}/Lib";
SPARSE_BUILD_LIBPCAP = "${libpcap-src}";
SPARSE_BUILD_LIBNL = "${libnl}";
};
});
}

5
toolchain.toml Normal file
View File

@ -0,0 +1,5 @@
[toolchain]
channel = "stable"
components = []
targets = [ "x86_64-pc-windows-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-freebsd", "aarch64-apple-darwin" ]
profile = "minimal"