Skip to content

Commit

Permalink
refactor(nix): just use default nix flake for now
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnwriter committed Sep 9, 2024
1 parent 43fdc8e commit 541fa0f
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 79 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
.direnv
39 changes: 0 additions & 39 deletions default.nix

This file was deleted.

12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 76 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,89 @@
{
description = "Web app pentesting suite written in rust";
description = "kanha";

inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};

outputs =
{ self, nixpkgs }:
{ self, nixpkgs, ... }:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

forAllSystems =
function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
] (system: function nixpkgs.legacyPackages.${system});

darwinDeps =
pkgs: with pkgs; [
darwin.apple_sdk.frameworks.SystemConfiguration
libiconv
];
in
{
packages = forAllSystems (pkgs: {
default = pkgs.callPackage ./default.nix { };
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
name = "bwatch";
packages =
(with pkgs; [
# cargo
# cargo-edit
# clippy
# rustc
])
++ (pkgs.lib.optional pkgs.stdenvNoCC.isDarwin (darwinDeps pkgs));
};
});
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
packages = forAllSystems (pkgs: {
bwatch =
with pkgs;
let
fs = lib.fileset;
sourceFiles = fs.unions [
./Cargo.lock
./Cargo.toml
./src
];

devShells = forAllSystems (pkgs: {
default = pkgs.callPackage ./shell.nix { };
cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml));
pname = cargoToml.package.name;
version = cargoToml.package.version;
cargoLock.lockFile = ./Cargo.lock;
darwinBuildInputs = (darwinDeps pkgs);
in
pkgs.rustPlatform.buildRustPackage {
inherit pname version cargoLock;
src = fs.toSource {
root = ./.;
fileset = sourceFiles;
};
nativeBuildInputs = [
clippy
rustfmt
openssl
];
buildInputs = [ ] ++ lib.optionals stdenv.isDarwin darwinBuildInputs;
preBuildPhases = [ "cargoFmt" ];
cargoFmt = ''
cargo fmt --manifest-path ./Cargo.toml --all --check
'';
# right after checkPhase (tests)
preInstallPhases = [ "clippy" ];
clippy = ''
cargo clippy -- --deny warnings
'';
};
default = self.packages.${pkgs.system}.bwatch;
});
apps = forAllSystems (pkgs: {
default = {
type = "app";
program = "${self.packages.${pkgs.system}.bwatch}/bin/bwatch";
};
});
};
}
19 changes: 0 additions & 19 deletions shell.nix

This file was deleted.

0 comments on commit 541fa0f

Please sign in to comment.