Skip to content
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

chore: upgrade nix shell to using a nix flake #294

Merged
merged 1 commit into from
Aug 27, 2024
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
20 changes: 10 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ jobs:
needs: artifacts
steps:
- uses: actions/checkout@v4

- name: install dependencies
# We use the cloud CLIs github packages in their [default runner images](https://github.com/actions/runner-images).
# The runner images miss terraform, so we use chocolatey to install those quickly here.
uses: crazy-max/ghaction-chocolatey@v3
# note: all other dependencies are installed in the image already
with:
args: install --force terraform terragrunt terraform-docs
- name: install collie
Expand All @@ -91,9 +93,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: install dependencies
# note: we forego default.nix and to be as close to a realistic user experience as possible.
# unfortunately ubuntu doesn't package terraform and related tools very well, so we use nix for those.
# All the other dependencies are already present on the runner images, so we use those.
# note: we forego using the flake.nix development environment and try to be as close to a realistic user experience as possible.
# This means that we use the cloud CLIs github packages in their [default runner images](https://github.com/actions/runner-images).
# The runner images miss terraform and unfortunately ubuntu doesn't package it and related tools very well,
# so we abuse nix to install those quickly here.
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
Expand All @@ -116,12 +119,9 @@ jobs:
needs: artifacts
steps:
- uses: actions/checkout@v4
# note: we forego default.nix and to be as close to a realistic user experience as possible
# all the other dependencies are already present on the runner images, so we use those
# and just install the missing ones via nix, as these are not available in standard uubunt
# note: we forego default.nix and to be as close to a realistic user experience as possible
# and just install the missing ones via brew as many of our users would do
# all the other dependencies are already present on the runner images, so we use those
# note: we forego using the flake.nix development environment and try to be as close to a realistic user experience as possible.
# This means that we use the cloud CLIs github packages in their [default runner images](https://github.com/actions/runner-images).
# The runner images miss terraform so we use a standard brew command to install them here
- name: install dependencies
run: brew install terraform terragrunt terraform-docs
- name: run test
Expand Down
15 changes: 8 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

## Development

### nix-shell

You can use the provided `default.nix` file to stand up a
[nix-shell](https://nixos.org/manual/nix/stable/command-ref/nix-shell.html)
containing all dependencies required for developing collie, including the cloud
CLIs (aws, az, gcloud). Using the nix-shell is _optional_, you can of course use
it as a recipe for installing depencies with your package manager of choice.
### nix develop shell

You can use the provided `flake.nix` file to stand up a
[nix-develop](https://nix.dev/manual/nix/2.18/command-ref/new-cli/nix3-develop)
shell containing all dependencies required for developing collie, including the
cloud CLIs (aws, az, gcloud). Using the nix develop shell is _optional_, you can
of course use it as a recipe for installing depencies with your package manager
of choice.

### Git Hooks

Expand Down
34 changes: 0 additions & 34 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.

53 changes: 53 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
description = "Flake for collie-cli";

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


outputs = { self, nixpkgs }:

let
shellsForSystem = system:
let
pkgs = import nixpkgs { inherit system; config.allowUnfree = false; };
in
{
default = pkgs.mkShell {
name = "collie-cli";
packages = with pkgs;
[
deno

# used for build scripts
unzip
gnused

# cloud provider clis
awscli2
azure-cli
google-cloud-sdk

# terraform
opentofu
terragrunt
tflint
terraform-docs

# for collie foundation docs
nodejs
];
};
};


in
{
devShells = {
aarch64-darwin = (shellsForSystem "aarch64-darwin");
x86_64-darwin = (shellsForSystem "x86_64-darwin");
x86_64-linux = (shellsForSystem "x86_64-linux");
};
};
}
Loading