Skip to content

Commit

Permalink
Add nix support
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnauta committed Jul 17, 2024
1 parent 15bc38b commit 057bf5e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ jobs:
- name: Run tests
run: go test

- name: Set up Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Build Nix Package
run: bash nix-test.sh

- name: Run GoReleaser
if: startsWith(github.ref, 'refs/tags/')
uses: goreleaser/goreleaser-action@v4
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,17 @@ Finally, follow the instructions to generate your first generated file.
```
tf-generator generate
```

### Nix Usage

To use this library with [nix](https://nixos.org/), import the repository as an overlay.

```
let
tf-generator-overlay = import (builtins.fetchTarball https://github.com/jpnauta/tf-generator/archive/development.tar.gz);
pkgs = import <nixpkgs> { overlays = [ tf-generator-overlay ]; };
in
pkgs.mkShellNoCC {
buildInputs = with pkgs; [ tf-generator ];
}
```
17 changes: 17 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
final: prev:
{
tf-generator = prev.buildGoModule {
name = "tf-generator";

src = ./.;

vendorHash = "sha256-TIDg83EHqgzL9QOOsgGPm6f50qvnFbZPHwVo6pBaPQQ=";

meta = {
description = "Simple generator for Terraform/OpenTofu";
homepage = "https://github.com/jpnauta/tf-generator";
license = prev.lib.licenses.mit;
maintainers = with prev.lib.maintainers; [ jpnauta ];
};
};
}
4 changes: 4 additions & 0 deletions nix-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e

nix-build -E 'let tf-generator-overlay = import ./.; pkgs = import <nixpkgs> { overlays = [ tf-generator-overlay ]; }; in pkgs.mkShellNoCC { buildInputs = with pkgs; [ tf-generator ]; }' --dry-run

0 comments on commit 057bf5e

Please sign in to comment.