Skip to content

Commit

Permalink
feat(nix): Add flake and derivation for building gose
Browse files Browse the repository at this point in the history
Signed-off-by: Steffen Vogel <[email protected]>
  • Loading branch information
stv0g committed Nov 5, 2024
1 parent e045075 commit 02a9baf
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: Apache-2.0

<p align="center">
<img style="width: 30%; margin: 4em 0" src="frontend/img/gose-logo.svg" alt="GoSƐ logo" />
<h1 align="center">GoSƐ - A terascale file-uploader</h1>
<h1 align="center">GoSƐ: A terascale file-uploader</h1>
</p>

<!-- [![Codacy coverage](https://img.shields.io/codacy/coverage/27eec133fcfd4459885d78f52d03daa8?style=flat-square)](https://app.codacy.com/gh/stv0g/gose/) -->
Expand Down
11 changes: 11 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2023 Steffen Vogel <[email protected]>
# SPDX-License-Identifier: Apache-2.0
version = 1

[[annotations]]
path = [
"flake.lock",
]
precedence = "override"
SPDX-FileCopyrightText = "2023 Steffen Vogel <[email protected]>"
SPDX-License-Identifier = "Apache-2.0"
44 changes: 44 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# SPDX-FileCopyrightText: 2024 Steffen Vogel <[email protected]>
# SPDX-License-Identifier: Apache-2.0
{ buildGoModule, buildNpmPackage, lib }: let
version = "0.6.0";

frontend = buildNpmPackage {
pname = "gose-frontend";
inherit version;
src = ./frontend;

npmDepsHash = "sha256-p24s2SgCL8E9vUoZEyWSrd15IdkprneAXS7dwb7UbyA=";

installPhase = ''
find ./dist
mkdir $out
cp -r dist/* $out/
'';
};
in buildGoModule {
pname = "gose";
inherit version;
src = ./.;

vendorHash = "sha256-KWt9JWOLO/kDCVuPUkyKgjFbMXuFtd4MVSigV+4z7rc=";

CGO_ENABLED = 0;

postInstall = ''
mv $out/bin/cmd $out/bin/gose
'';

checkFlags = "-skip TestShortener";

prePatch = ''
ln -s ${frontend} frontend/dist
'';

meta = {
description = "GoSƐ: A terascale file-uploader";
homepage = "https://github.com/stv0g/gose";
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.

43 changes: 43 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SPDX-FileCopyrightText: 2024 Steffen Vogel <[email protected]>
# SPDX-License-Identifier: Apache-2.0
{
description = "GoSƐ: A terascale file-uploader";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};

outputs =
{
self,
flake-utils,
nixpkgs,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShell =
pkgs.mkShell {
inputsFrom = [
self.packages.${system}.default
];

packages = with pkgs; [
golangci-lint
reuse
nodejs_22
];
};

packages.default = pkgs.callPackage ./default.nix { };

formatter = pkgs.nixfmt-rfc-style;
}
);
}

0 comments on commit 02a9baf

Please sign in to comment.