Skip to content

Commit 541fa0f

Browse files
committed
refactor(nix): just use default nix flake for now
1 parent 43fdc8e commit 541fa0f

File tree

6 files changed

+84
-79
lines changed

6 files changed

+84
-79
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
.direnv

default.nix

-39
This file was deleted.

flake.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+76-15
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,89 @@
11
{
2-
description = "Web app pentesting suite written in rust";
2+
description = "kanha";
33

4-
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
};
57

68
outputs =
7-
{ self, nixpkgs }:
9+
{ self, nixpkgs, ... }:
810
let
9-
systems = [
10-
"x86_64-linux"
11-
"aarch64-linux"
12-
"x86_64-darwin"
13-
"aarch64-darwin"
14-
];
15-
1611
forAllSystems =
17-
function: nixpkgs.lib.genAttrs systems (system: function nixpkgs.legacyPackages.${system});
12+
function:
13+
nixpkgs.lib.genAttrs [
14+
"x86_64-linux"
15+
"aarch64-linux"
16+
"x86_64-darwin"
17+
"aarch64-darwin"
18+
] (system: function nixpkgs.legacyPackages.${system});
19+
20+
darwinDeps =
21+
pkgs: with pkgs; [
22+
darwin.apple_sdk.frameworks.SystemConfiguration
23+
libiconv
24+
];
1825
in
1926
{
20-
packages = forAllSystems (pkgs: {
21-
default = pkgs.callPackage ./default.nix { };
27+
devShells = forAllSystems (pkgs: {
28+
default = pkgs.mkShell {
29+
name = "bwatch";
30+
packages =
31+
(with pkgs; [
32+
# cargo
33+
# cargo-edit
34+
# clippy
35+
# rustc
36+
])
37+
++ (pkgs.lib.optional pkgs.stdenvNoCC.isDarwin (darwinDeps pkgs));
38+
};
2239
});
40+
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
41+
packages = forAllSystems (pkgs: {
42+
bwatch =
43+
with pkgs;
44+
let
45+
fs = lib.fileset;
46+
sourceFiles = fs.unions [
47+
./Cargo.lock
48+
./Cargo.toml
49+
./src
50+
];
2351

24-
devShells = forAllSystems (pkgs: {
25-
default = pkgs.callPackage ./shell.nix { };
52+
cargoToml = with builtins; (fromTOML (readFile ./Cargo.toml));
53+
pname = cargoToml.package.name;
54+
version = cargoToml.package.version;
55+
cargoLock.lockFile = ./Cargo.lock;
56+
darwinBuildInputs = (darwinDeps pkgs);
57+
in
58+
pkgs.rustPlatform.buildRustPackage {
59+
inherit pname version cargoLock;
60+
src = fs.toSource {
61+
root = ./.;
62+
fileset = sourceFiles;
63+
};
64+
nativeBuildInputs = [
65+
clippy
66+
rustfmt
67+
openssl
68+
];
69+
buildInputs = [ ] ++ lib.optionals stdenv.isDarwin darwinBuildInputs;
70+
preBuildPhases = [ "cargoFmt" ];
71+
cargoFmt = ''
72+
cargo fmt --manifest-path ./Cargo.toml --all --check
73+
'';
74+
# right after checkPhase (tests)
75+
preInstallPhases = [ "clippy" ];
76+
clippy = ''
77+
cargo clippy -- --deny warnings
78+
'';
79+
};
80+
default = self.packages.${pkgs.system}.bwatch;
81+
});
82+
apps = forAllSystems (pkgs: {
83+
default = {
84+
type = "app";
85+
program = "${self.packages.${pkgs.system}.bwatch}/bin/bwatch";
86+
};
2687
});
2788
};
2889
}

shell.nix

-19
This file was deleted.

0 commit comments

Comments
 (0)