Skip to content

chore: change to flake nix #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions default.nix

This file was deleted.

27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
description = "Flake for terraform-aws-meshplatform";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05";
};

outputs = { self, nixpkgs }:

let
# These tools are pre-installed in github actions, so we can save the time for installing them.
github_actions_preinstalled = pkgs:
with pkgs;
[
awscli2
(azure-cli.withExtensions [ azure-cli.extensions.account ])
nodejs
];

# core packages required in CI and not preinstalled in github actions
core_packages = pkgs:
let
tofu_terraform =
pkgs.stdenv.mkDerivation {
name = "tofu-terraform";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p $out/bin
echo '#!/usr/bin/env sh' > $out/bin/terraform
echo 'tofu "$@"' >> $out/bin/terraform
chmod +x $out/bin/terraform
'';
};
in
with pkgs;
[
opentofu
terragrunt
tflint
tfupdate
terraform-docs
tofu_terraform
pre-commit
];

importNixpkgs = system: import nixpkgs { inherit system; };

defaultShellForSystem = system:
let
pkgs = importNixpkgs system;
in {
default = pkgs.mkShell {
name = "terraform-aws-meshplatform";
packages = (github_actions_preinstalled pkgs) ++ (core_packages pkgs);
};
};

in {
devShells = {
aarch64-darwin = defaultShellForSystem "aarch64-darwin";
x86_64-darwin = defaultShellForSystem "x86_64-darwin";
x86_64-linux = defaultShellForSystem "x86_64-linux" // {
github_actions =
let
pkgs = importNixpkgs "x86_64-linux";
in
pkgs.mkShell {
name = "terraform-aws-meshplatform";
packages = (core_packages pkgs);
};
};
};
};
}


Loading