diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index cd88e52..b39791e 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -4,11 +4,15 @@ on: push: tags: ["v*"] paths-ignore: - - '**/*.md' + - "**/*.md" + - "**/*.nix" + - "**/*.lock" pull_request: branches: [main] paths-ignore: - - '**/*.md' + - "**/*.md" + - "**/*.nix" + - "**/*.lock" jobs: build: diff --git a/.github/workflows/golang-ci.yml b/.github/workflows/golang-ci.yml index 47b2dfe..24e25fd 100644 --- a/.github/workflows/golang-ci.yml +++ b/.github/workflows/golang-ci.yml @@ -4,10 +4,14 @@ on: tags: [v*] branches: [main] paths-ignore: - - '**/*.md' + - "**/*.md" + - "**/*.nix" + - "**/*.lock" pull_request: paths-ignore: - - '**/*.md' + - "**/*.md" + - "**/*.nix" + - "**/*.lock" jobs: golangci: name: lint diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 1a08f92..f588e2e 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -5,11 +5,15 @@ on: tags: ["v*"] branches: [main] paths-ignore: - - '**/*.md' + - "**/*.md" + - "**/*.nix" + - "**/*.lock" pull_request: branches: [main] paths-ignore: - - '**/*.md' + - "**/*.md" + - "**/*.nix" + - "**/*.lock" jobs: kubernetes-docker: runs-on: macos-11 diff --git a/colima.nix b/colima.nix new file mode 100644 index 0000000..0f7d0a2 --- /dev/null +++ b/colima.nix @@ -0,0 +1,29 @@ +{ pkgs ? import }: + +with pkgs; + +buildGo118Module { + name = "colima"; + pname = "colima"; + src = ./.; + nativeBuildInputs = [ installShellFiles makeWrapper git ]; + vendorSha256 = "sha256-jDzDwK7qA9lKP8CfkKzfooPDrHuHI4OpiLXmX9vOpOg="; + + # `nix-build` has .git folder but `nix build` does not, this caters for both cases + preConfigure = '' + export VERSION="$(git describe --tags --always || echo nix-build-at-"$(date +%s)")" + export REVISION="$(git rev-parse HEAD || echo nix-unknown)" + ldflags="-X github.com/abiosoft/colima/config.appVersion=$VERSION + -X github.com/abiosoft/colima/config.revision=$REVISION" + ''; + + postInstall = '' + wrapProgram $out/bin/colima \ + --prefix PATH : ${lib.makeBinPath [ qemu lima ]} + installShellCompletion --cmd colima \ + --bash <($out/bin/colima completion bash) \ + --fish <($out/bin/colima completion fish) \ + --zsh <($out/bin/colima completion zsh) + ''; +} + diff --git a/default.nix b/default.nix index e0648a0..ed8b674 100644 --- a/default.nix +++ b/default.nix @@ -1,21 +1,2 @@ with import { }; - -buildGo118Module rec { - name = "colima"; - pname = "colima"; - src = ./.; - nativeBuildInputs = [ installShellFiles makeWrapper git ]; - vendorSha256 = "sha256-jDzDwK7qA9lKP8CfkKzfooPDrHuHI4OpiLXmX9vOpOg="; - preConfigure = '' - ldflags="-X github.com/abiosoft/colima/config.appVersion=$(git describe --tags --always) - -X github.com/abiosoft/colima/config.revision=$(git rev-parse HEAD)" - ''; - postInstall = '' - wrapProgram $out/bin/colima \ - --prefix PATH : ${lib.makeBinPath [ qemu lima ]} - installShellCompletion --cmd colima \ - --bash <($out/bin/colima completion bash) \ - --fish <($out/bin/colima completion fish) \ - --zsh <($out/bin/colima completion zsh) - ''; -} +callPackage (import ./colima.nix) { } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d50bde5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1656065134, + "narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c", + "type": "github" + }, + "original": { + "id": "flake-utils", + "type": "indirect" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1656546896, + "narHash": "sha256-WpMqq6OHQinBZjxemh2jthIvUpNoqNwqpYipbZUOsQs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "7fb2acd492c96ea4a1a37ec060edb1e1774eeb5b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..24f0821 --- /dev/null +++ b/flake.nix @@ -0,0 +1,20 @@ +{ + description = "Container runtimes on macOS (and Linux) with minimal setup"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/release-22.05"; + + outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + packages.default = import ./colima.nix { inherit pkgs; }; + devShell = import ./shell.nix { inherit pkgs; }; + apps.default = { + type = "app"; + program = "${self.packages.${system}.default}/bin/colima"; + }; + } + ); +}