Skip to content
Draft
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/release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
".": {
"component": "cli",
"package-name": "hcloud-upload-image",
"extra-files": ["internal/version/version.go"]
"extra-files": ["internal/version/version.go", "hcloud-upload-image.nix"]
},
"hcloudimages": {
"component": "hcloudimages",
Expand Down
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.

27 changes: 27 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # unstable for go 1.22
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
system = system;
};
hcloud-upload-image = pkgs.callPackage ./hcloud-upload-image.nix { };
in
{
packages = {
default = hcloud-upload-image;
};

devShells = {
default = pkgs.mkShell {
packages = [ hcloud-upload-image ];
};
};
}
);
}
44 changes: 44 additions & 0 deletions hcloud-upload-image.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{ config, pkgs, fetchFromGitHub, ... }:

pkgs.buildGo122Module rec {
pname = "hcloud-upload-image";
version = "v0.2.1"; # x-release-please-version
#src = pkgs.fetchFromGitHub {
# owner = "apricote";
# repo = "hcloud-upload-image";
# rev = version;
# sha256 = "KYhmMo/GDiLOWuEtdiY/KDwh1MO3crAFN2SGiL8FFIU=";
#};
src = ./.;

vendorHash = "";
overrideModAttrs = _: {
#outputHash = "sha256-/FluEFTvrX07L4kGPH7jPrcRhwdrCz1p4OVErNegNLw=";
#outputHash = null;
#outputHashAlgo = null;
#outputHashMode = null;
};

nativeBuildInputs = [
pkgs.installShellFiles
];

preBuild = ''
export GOWORK=off
'';

subPackages = [ "." ]; # We only need to CLI, fails with the "hcloudimages" module otherwise
CGO_ENABLED = "0";

ldflags = [
"-X github.com/apricote/hcloud-upload-image/internal/version.version=${version}"
"-X github.com/apricote/hcloud-upload-image/internal/version.versionPrerelease="
];

postInstall = ''
installShellCompletion --cmd hcloud-upload-image \
--bash <($out/bin/hcloud-upload-image completion bash) \
--fish <($out/bin/hcloud-upload-image completion fish) \
--zsh <($out/bin/hcloud-upload-image completion zsh)
'';
}