Skip to content

Commit

Permalink
Change cache name and use different builders for each version
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella committed Nov 1, 2023
1 parent 829a729 commit fa64306
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: cachix/install-nix-action@v22
- uses: cachix/cachix-action@v12
with:
name: stackbuilders
name: nixpkgs-terraform
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- run: nix flake check --impure
env:
Expand Down
29 changes: 23 additions & 6 deletions flake.lock

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

35 changes: 22 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,39 @@
description = "TODO";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
flake-utils.inputs.systems.follows = "systems";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nixpkgs-23_05.url = "github:nixos/nixpkgs/nixos-23.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
systems.url = "github:nix-systems/default";
};

outputs = { self, flake-utils, nixpkgs, ... }:
outputs = { self, flake-utils, nixpkgs-23_05, nixpkgs-unstable, ... }:
let
mkPackageName = version: "terraform-${builtins.concatStringsSep "_" (builtins.splitVersion version)}";
in
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
pkgs-23_05 = nixpkgs-23_05.legacyPackages.${system};
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
versions = builtins.fromJSON (builtins.readFile ./versions.json);
# https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/applications/networking/cluster/terraform/default.nix
mkTerraform = { version, hash, vendorHash }: pkgs.mkTerraform {
inherit version hash vendorHash;
patches = [ "${nixpkgs}/pkgs/applications/networking/cluster/terraform/provider-path-0_15.patch" ];
};
mkTerraform = { version, hash, vendorHash }:
# https://www.hashicorp.com/blog/hashicorp-adopts-business-source-license
if builtins.compareVersions version "1.6.0" >= 0
then
# https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/applications/networking/cluster/terraform/default.nix
pkgs-unstable.mkTerraform
{
inherit version hash vendorHash;
patches = [ "${nixpkgs-unstable}/pkgs/applications/networking/cluster/terraform/provider-path-0_15.patch" ];
}
else
# https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/applications/networking/cluster/terraform/default.nix
pkgs-23_05.mkTerraform {
inherit version hash vendorHash;
patches = [ "${nixpkgs-23_05}/pkgs/applications/networking/cluster/terraform/provider-path-0_15.patch" ];
};
in
{
# https://github.com/NixOS/nix/issues/7165
Expand All @@ -36,10 +49,6 @@
};
})
(builtins.attrNames versions));
# templates.default = {
# description = "TODO";
# path = ./templates/default;
# };
}) // {
lib.packageFromVersion = { system, version }: self.packages.${system}.${mkPackageName version};
};
Expand Down

0 comments on commit fa64306

Please sign in to comment.