Skip to content

Instantly share code, notes, and snippets.

@ymatsiuk
Last active June 14, 2024 07:06
Show Gist options
  • Save ymatsiuk/99a1d23423df7fec08f8cafbd4df40c6 to your computer and use it in GitHub Desktop.
Save ymatsiuk/99a1d23423df7fec08f8cafbd4df40c6 to your computer and use it in GitHub Desktop.
Nix develop example
# Run me:
# ❯ nix develop .#work -c vault --version
# mysql Ver 15.1 Distrib 10.11.6-MariaDB, for Linux (x86_64) using readline 5.1
# ❯ nix develop .#fun -c mysql --version
# Vault v1.15.6 (615cf6f1dce9aa91bc2035ce33b9f689952218f0), built 2024-02-28T17:07:34Z
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
let
makeOpinionatedNixpkgs = system: overlays:
import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = overlays;
};
in
{
overlays = {
wrk = final: prev: {
vault = prev.vault-bin;
terragrunt = prev.terragrunt.override {
buildGoModule = args: final.buildGoModule (args // rec {
pname = "terragrunt";
version = "0.52.3";
src = prev.fetchFromGitHub {
owner = "gruntwork-io";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-o/4L7TBdFFHuPOKAO/wP0IBixQtZHGr1GSNlsEpq710=";
};
vendorHash = "sha256-RmzSKt5qt9Qb4GDrfs4dJEhGQW/jFbXPn+AOLzEyo6c=";
doCheck = false;
ldflags = [
"-s"
"-w"
"-X github.com/gruntwork-io/go-commons/version.Version=v${version}"
];
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/terragrunt --help
$out/bin/terragrunt --version | grep "v${version}"
runHook postInstallCheck
'';
});
};
terraform = prev.mkTerraform {
version = "1.5.7";
hash = "sha256-pIhwJfa71/gW7lw/KRFBO4Q5Z5YMcTt3r9kD25k8cqM=";
vendorHash = "sha256-lQgWNMBf+ioNxzAV7tnTQSIS840XdI9fg9duuwoK+U4=";
};
};
};
} //
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = makeOpinionatedNixpkgs system [ self.overlays.wrk ];
in
{
devShells = {
work = pkgs.mkShell {
buildInputs = with pkgs; [
terragrunt
terraform
vault
];
};
fun = pkgs.mkShell {
buildInputs = with pkgs; [ mysql ];
};
};
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment