Skip to content

Commit 8bb1101

Browse files
authored
chore: update nix files (#360)
* ci: ignore nix files * chore: add nix flake
1 parent 2864461 commit 8bb1101

File tree

7 files changed

+110
-26
lines changed

7 files changed

+110
-26
lines changed

.github/workflows/go.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ on:
44
push:
55
tags: ["v*"]
66
paths-ignore:
7-
- '**/*.md'
7+
- "**/*.md"
8+
- "**/*.nix"
9+
- "**/*.lock"
810
pull_request:
911
branches: [main]
1012
paths-ignore:
11-
- '**/*.md'
13+
- "**/*.md"
14+
- "**/*.nix"
15+
- "**/*.lock"
1216

1317
jobs:
1418
build:

.github/workflows/golang-ci.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ on:
44
tags: [v*]
55
branches: [main]
66
paths-ignore:
7-
- '**/*.md'
7+
- "**/*.md"
8+
- "**/*.nix"
9+
- "**/*.lock"
810
pull_request:
911
paths-ignore:
10-
- '**/*.md'
12+
- "**/*.md"
13+
- "**/*.nix"
14+
- "**/*.lock"
1115
jobs:
1216
golangci:
1317
name: lint

.github/workflows/integration.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ on:
55
tags: ["v*"]
66
branches: [main]
77
paths-ignore:
8-
- '**/*.md'
8+
- "**/*.md"
9+
- "**/*.nix"
10+
- "**/*.lock"
911
pull_request:
1012
branches: [main]
1113
paths-ignore:
12-
- '**/*.md'
14+
- "**/*.md"
15+
- "**/*.nix"
16+
- "**/*.lock"
1317
jobs:
1418
kubernetes-docker:
1519
runs-on: macos-11

colima.nix

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{ pkgs ? import <nixpkgs> }:
2+
3+
with pkgs;
4+
5+
buildGo118Module {
6+
name = "colima";
7+
pname = "colima";
8+
src = ./.;
9+
nativeBuildInputs = [ installShellFiles makeWrapper git ];
10+
vendorSha256 = "sha256-jDzDwK7qA9lKP8CfkKzfooPDrHuHI4OpiLXmX9vOpOg=";
11+
12+
# `nix-build` has .git folder but `nix build` does not, this caters for both cases
13+
preConfigure = ''
14+
export VERSION="$(git describe --tags --always || echo nix-build-at-"$(date +%s)")"
15+
export REVISION="$(git rev-parse HEAD || echo nix-unknown)"
16+
ldflags="-X github.com/abiosoft/colima/config.appVersion=$VERSION
17+
-X github.com/abiosoft/colima/config.revision=$REVISION"
18+
'';
19+
20+
postInstall = ''
21+
wrapProgram $out/bin/colima \
22+
--prefix PATH : ${lib.makeBinPath [ qemu lima ]}
23+
installShellCompletion --cmd colima \
24+
--bash <($out/bin/colima completion bash) \
25+
--fish <($out/bin/colima completion fish) \
26+
--zsh <($out/bin/colima completion zsh)
27+
'';
28+
}
29+

default.nix

+1-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
11
with import <nixpkgs> { };
2-
3-
buildGo118Module rec {
4-
name = "colima";
5-
pname = "colima";
6-
src = ./.;
7-
nativeBuildInputs = [ installShellFiles makeWrapper git ];
8-
vendorSha256 = "sha256-jDzDwK7qA9lKP8CfkKzfooPDrHuHI4OpiLXmX9vOpOg=";
9-
preConfigure = ''
10-
ldflags="-X github.com/abiosoft/colima/config.appVersion=$(git describe --tags --always)
11-
-X github.com/abiosoft/colima/config.revision=$(git rev-parse HEAD)"
12-
'';
13-
postInstall = ''
14-
wrapProgram $out/bin/colima \
15-
--prefix PATH : ${lib.makeBinPath [ qemu lima ]}
16-
installShellCompletion --cmd colima \
17-
--bash <($out/bin/colima completion bash) \
18-
--fish <($out/bin/colima completion fish) \
19-
--zsh <($out/bin/colima completion zsh)
20-
'';
21-
}
2+
callPackage (import ./colima.nix) { }

flake.lock

+42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
description = "Container runtimes on macOS (and Linux) with minimal setup";
3+
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-22.05";
5+
6+
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem
7+
(system:
8+
let
9+
pkgs = nixpkgs.legacyPackages.${system};
10+
in
11+
{
12+
packages.default = import ./colima.nix { inherit pkgs; };
13+
devShell = import ./shell.nix { inherit pkgs; };
14+
apps.default = {
15+
type = "app";
16+
program = "${self.packages.${system}.default}/bin/colima";
17+
};
18+
}
19+
);
20+
}

0 commit comments

Comments
 (0)