-
Notifications
You must be signed in to change notification settings - Fork 784
Add: nix flakes support #2219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
arch-fan
wants to merge
13
commits into
greenbone:main
Choose a base branch
from
arch-fan:feat/nix-flakes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add: nix flakes support #2219
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7873003
Add: nix flakes support
arch-fan af956dd
Removed: unnecesary cmake flags
arch-fan c0a04f2
Removed: unnecesary overcomplicated install fase
arch-fan e2c58a8
Refactor: using version from CMakeLists.txt
arch-fan 74dbb5c
Refactor: simplify version extractor
arch-fan 5a0c82c
Fix: CMakeLists.txt path
arch-fan d7a0041
Refactor: clean openvas build
arch-fan 04e7afc
Fix: remove darwin
arch-fan a3b6ae8
Refactor: use static library linking
arch-fan e4a57ba
Add: /result to .gitignore
arch-fan a570621
Fix: nasl warning
arch-fan 5b6564d
Chore: bump nix flake
arch-fan b24c2ee
Chore: use nixfmt package
arch-fan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,3 +13,4 @@ target/ | |
| *.rsa | ||
| *.pem | ||
| *.snap.new | ||
| /result | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| { | ||
| description = "OpenVAS — Open Vulnerability Assessment Scanner"; | ||
|
|
||
| inputs = { | ||
| nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; | ||
| flake-parts.url = "github:hercules-ci/flake-parts"; | ||
| crane = { | ||
| url = "github:ipetkov/crane"; | ||
| }; | ||
| fenix = { | ||
| url = "github:nix-community/fenix"; | ||
| inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
| }; | ||
|
|
||
| outputs = | ||
| inputs@{ self, flake-parts, ... }: | ||
| flake-parts.lib.mkFlake { inherit inputs; } { | ||
| systems = [ | ||
| "x86_64-linux" | ||
| "aarch64-linux" | ||
| ]; | ||
|
|
||
| perSystem = | ||
| { system, pkgs, ... }: | ||
| let | ||
| rustToolchain = pkgs.fenix.fromToolchainFile { | ||
| dir = self + /rust; | ||
| sha256 = "sha256-gh/xTkxKHL4eiRXzWv8KP7vfjSk61Iq48x47BEDFgfk="; | ||
| }; | ||
|
|
||
| craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain; | ||
| in | ||
| rec { | ||
| formatter = pkgs.nixfmt; | ||
|
|
||
| _module.args.pkgs = import inputs.nixpkgs { | ||
| inherit system; | ||
| overlays = [ inputs.fenix.overlays.default ]; | ||
| }; | ||
|
|
||
| packages = import ./nix/packages { | ||
| inherit pkgs craneLib; | ||
| src = self; | ||
| }; | ||
|
|
||
| apps = | ||
| let | ||
| mkApp = name: { | ||
| type = "app"; | ||
| program = "${packages.${name}}/bin/${name}"; | ||
| }; | ||
| in | ||
| { | ||
| openvasd = mkApp "openvasd"; | ||
| scannerctl = mkApp "scannerctl"; | ||
| feed-filter = mkApp "feed-filter"; | ||
| openvas = mkApp "openvas"; | ||
| }; | ||
|
|
||
| devShells.default = pkgs.mkShell { | ||
| inputsFrom = builtins.attrValues packages; | ||
| buildInputs = with pkgs; [ | ||
| cmake | ||
| gcc | ||
| pkg-config | ||
| bison | ||
| flex | ||
| doxygen | ||
| pandoc | ||
| glib | ||
| json-glib | ||
| libgcrypt | ||
| gpgme | ||
| libpcap | ||
| libssh | ||
| libksba | ||
| gnutls | ||
| curl | ||
| libbsd | ||
| krb5 | ||
| file | ||
| net-snmp | ||
| nmap | ||
| redis | ||
| rustToolchain | ||
| clang-tools | ||
| gdb | ||
| valgrind | ||
| ]; | ||
| }; | ||
| }; | ||
|
|
||
| flake.overlays.default = final: prev: { | ||
| inherit (self.packages.${final.system}) | ||
| gvm-libs | ||
| openvasd | ||
| scannerctl | ||
| feed-filter | ||
| scannerlib | ||
| openvas | ||
| ; | ||
| }; | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| pkgs, | ||
| craneLib, | ||
| src, | ||
| }: | ||
|
|
||
| let | ||
| inherit (pkgs) gvm-libs; | ||
|
|
||
| # Read scanner release version from CMakeLists.txt — upstream releases | ||
| # use this version for both the C scanner and the Rust binaries. | ||
| version = builtins.head ( | ||
| builtins.match ".*project[[:space:]]*\\([^)]*VERSION[[:space:]]+([0-9.]+).*" ( | ||
| builtins.readFile (src + /CMakeLists.txt) | ||
| ) | ||
| ); | ||
|
|
||
| cargoToml = fromTOML (builtins.readFile (src + "/rust/Cargo.toml")); | ||
|
|
||
| # Each binary is its own derivation (buildDepsOnly shared, see scannerlib.nix). | ||
| rustOutputs = pkgs.callPackage ./scannerlib.nix { | ||
| inherit craneLib; | ||
| inherit gvm-libs; | ||
| inherit version; | ||
| pname = cargoToml.package.name; | ||
| src = src + "/rust"; | ||
| repoRoot = src; | ||
| }; | ||
|
|
||
| in | ||
| { | ||
| inherit gvm-libs; | ||
|
|
||
| inherit (rustOutputs) | ||
| openvasd | ||
| scannerctl | ||
| feed-filter | ||
| scannerlib | ||
| ; | ||
|
|
||
| openvas = pkgs.callPackage ./openvas.nix { | ||
| inherit src version; | ||
| inherit gvm-libs; | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we just use the toolchain so that we are not so often surprised by clippy and fmt changes and can do that when we have time. Since we don't validate clippy nor formatting via nix I don't think it is necessary to respect the toolchain definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, toolchain is loaded mainly because of the Rust version, so we can have it fixed. Clippy & formatting are extra tools, but not necessary.
I can remove the toolchain usage but that means that Rust version will be set by fenix's input lock at flakes.