Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Commit 1944bfb

Browse files
authored
nix: Add Nix Package (#31)
1 parent a564684 commit 1944bfb

3 files changed

Lines changed: 96 additions & 0 deletions

File tree

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
description = "IncusScripts CLI";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
6+
};
7+
8+
outputs = {
9+
self,
10+
nixpkgs,
11+
}: let
12+
supportedSystems = [
13+
"aarch64-linux"
14+
"x86_64-linux"
15+
];
16+
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
17+
in {
18+
packages = forAllSystems (
19+
system: let
20+
pkgs = nixpkgs.legacyPackages.${system};
21+
in {
22+
scripts-cli = pkgs.callPackage ./nix/package.nix {};
23+
default = self.packages.${system}.scripts-cli;
24+
}
25+
);
26+
};
27+
}

nix/package.nix

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
lib,
3+
buildGo123Module,
4+
installShellFiles,
5+
}:
6+
buildGo123Module rec {
7+
pname = "scripts-cli";
8+
version = "latest";
9+
10+
src = ./../cli;
11+
12+
vendorHash = "sha256-iPxabKi33tJH8xQ9gPr9XmT0LcBwxtonnXJlJMnYxjw=";
13+
subPackages = ["." "./cmd"];
14+
15+
nativeBuildInputs = [
16+
installShellFiles
17+
];
18+
19+
postInstall = ''
20+
# Rename the binary from cli to scripts-cli
21+
mv $out/bin/cmd $out/bin/scripts-cli
22+
23+
installShellCompletion --cmd scripts-cli \
24+
--bash <($out/bin/scripts-cli completion bash) \
25+
--fish <($out/bin/scripts-cli completion fish) \
26+
--zsh <($out/bin/scripts-cli completion zsh)
27+
'';
28+
29+
env.CGO_ENABLED = 0;
30+
31+
ldflags = [
32+
"-X github.com/bketelsen/IncusScripts/cli/cmd/main.commit=${version}"
33+
];
34+
35+
meta = {
36+
description = "Incus Helper-Scripts";
37+
homepage = "https://github.com/bketelsen/IncusScripts";
38+
license = lib.licenses.mit;
39+
mainProgram = "scripts-cli";
40+
platforms = lib.platforms.linux;
41+
};
42+
}

0 commit comments

Comments
 (0)