Skip to content
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

nix: Add Flake #158

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.0
version: v1.59.0
2 changes: 1 addition & 1 deletion .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Upstream-Name: go-rosenpass
Upstream-Contact: Steffen Vogel <post@steffenvogel.de>
Source: https://github.com/cunicu/go-rosenpass

Files: go.sum .renovaterc.json testdata/**
Files: flake.lock go.sum .renovaterc.json testdata/**
Copyright: 2023 Steffen Vogel <post@steffenvogel.de>
License: CC0-1.0
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"encaps",
"epki",
"eski",
"Fncs",
"pidi",
"Preshared",
"scti",
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ go-rosenpass:
lint:
golangci-lint run ./...

.PHONY: lint all go-rosenpass
reuse:
reuse lint

check: lint reuse

.PHONY: lint reuse check all go-rosenpass
4 changes: 2 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
Short: "Rosenpass is a formally verified, post-quantum secure VPN that uses WireGuard to transport the actual data.",
SilenceUsage: true,
SilenceErrors: true,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
PersistentPreRun: func(_ *cobra.Command, _ []string) {
setupLogging(verbose)
},
}
Expand All @@ -38,7 +38,7 @@ var (
Use: "man",
Short: "Show the go-rosenpass manpage",
Args: cobra.ArbitraryArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
page := strings.Join(append([]string{"go-rosenpass"}, args...), genManOpts.CommandSeparator)
c := exec.Command("man", "1", page)
c.Stdout = os.Stdout
Expand Down
31 changes: 31 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-FileCopyrightText: 2023-2024 Steffen Vogel <post@steffenvogel.de>
# SPDX-License-Identifier: Apache-2.0
{
buildGoModule,
lib,
rosenpass,
...
}:
buildGoModule {
pname = "go-rosenpass";
version = "0.4.0";
src = ./.;
vendorHash = "sha256-lklY0LhALjzVC41Jhc8mFkGGdGbfSmDQ0koYYOdENA0=";

subPackages = [ "cmd" ];

CGO_ENABLED = 0;

nativeCheckInputs = [ rosenpass ];

postInstall = ''
mv $out/bin/cmd $out/bin/go-rosenpass
'';

meta = {
description = "A port of Rosenpass post-quantum key-exchange protocol to Go.";
homepage = "https://github.com/cunicu/go-rosenpass";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ stv0g ];
};
}
61 changes: 61 additions & 0 deletions flake.lock

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

40 changes: 40 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# SPDX-FileCopyrightText: 2023-2024 Steffen Vogel <post@steffenvogel.de>
# SPDX-License-Identifier: Apache-2.0
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
overlay = final: prev: { go-rosenpass = final.callPackage ./default.nix { }; };

pkgs = import nixpkgs {
inherit system;
overlays = [ overlay ];
};
in
{
packages.default = pkgs.go-rosenpass;
overlays.default = overlay;

devShell = pkgs.mkShell {
inputsFrom = with pkgs; [ go-rosenpass ];

buildInputs = with pkgs; [
golangci-lint
reuse
];
};

formatter = nixpkgs.nixfmt-rfc-style;
}
);
}
2 changes: 1 addition & 1 deletion messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestMessages(t *testing.T) {

func FuzzEnvelope(f *testing.F) {
f.Add([]byte{})
f.Fuzz(func(t *testing.T, b []byte) {
f.Fuzz(func(_ *testing.T, b []byte) {
var e envelope
e.UnmarshalBinary(b) //nolint:errcheck
})
Expand Down
Loading