Skip to content

Commit 5285c12

Browse files
authored
chore: update terraform to 1.11.1 in nix image (coder#16880)
Followup PR to coder#16781, update the terraform version in our Nix devshell. Additionally: 1. Switches from DeterminateSystems/nix-installer-action to nixbuild/nix-quick-install-action -- quicker installer, reduces actions time from ~60 seconds to ~1 seconds. 2. Adds nix-community/cache-nix-action for better caching with garbage collection -- avoids unnecessary rebuilding on subsequent runs, reduces nix image build time from ~6 minutes to <4 minutes. 3. Adds nixpkgs-unstable input to use Terraform 1.11.1 Change-Id: I05d6dfd3f3cf1af48cf8a2d9e61b396bcd2b7191 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 09dd69a commit 5285c12

File tree

4 files changed

+58
-9
lines changed

4 files changed

+58
-9
lines changed

.github/workflows/dogfood.yaml

+20-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,26 @@ jobs:
3535
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3636

3737
- name: Setup Nix
38-
uses: DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d # v16
38+
uses: nixbuild/nix-quick-install-action@5bb6a3b3abe66fd09bbf250dce8ada94f856a703 # v30
39+
40+
- uses: nix-community/cache-nix-action@aee88ae5efbbeb38ac5d9862ecbebdb404a19e69 # v6.1.1
41+
with:
42+
# restore and save a cache using this key
43+
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
44+
# if there's no cache hit, restore a cache by this prefix
45+
restore-prefixes-first-match: nix-${{ runner.os }}-
46+
# collect garbage until Nix store size (in bytes) is at most this number
47+
# before trying to save a new cache
48+
# 1G = 1073741824
49+
gc-max-store-size-linux: 5G
50+
# do purge caches
51+
purge: true
52+
# purge all versions of the cache
53+
purge-prefixes: nix-${{ runner.os }}-
54+
# created more than this number of seconds ago relative to the start of the `Post Restore` phase
55+
purge-created: 0
56+
# except the version with the `primary-key`, if it exists
57+
purge-primary-key: never
3958

4059
- name: Get branch name
4160
id: branch-name

dogfood/coder/nix.hash

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
f41c80bd08bfef063a9cfe907d0ea1f377974ebe011751f64008a3a07a6b152a flake.nix
2-
32c441011f1f3054a688c036a85eac5e4c3dbef0f8cfa4ab85acd82da577dc35 flake.lock
1+
f09cd2cbbcdf00f5e855c6ddecab6008d11d871dc4ca5e1bc90aa14d4e3a2cfd flake.nix
2+
0d2489a26d149dade9c57ba33acfdb309b38100ac253ed0c67a2eca04a187e37 flake.lock

flake.lock

+20-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
inputs = {
55
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
6+
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
67
nixpkgs-pinned.url = "github:nixos/nixpkgs/5deee6281831847857720668867729617629ef1f";
78
flake-utils.url = "github:numtide/flake-utils";
89
pnpm2nix = {
@@ -22,6 +23,7 @@
2223
self,
2324
nixpkgs,
2425
nixpkgs-pinned,
26+
nixpkgs-unstable,
2527
flake-utils,
2628
drpc,
2729
pnpm2nix,
@@ -31,7 +33,7 @@
3133
let
3234
pkgs = import nixpkgs {
3335
inherit system;
34-
# Workaround for: terraform has an unfree license (‘bsl11’), refusing to evaluate.
36+
# Workaround for: google-chrome has an unfree license (‘unfree’), refusing to evaluate.
3537
config.allowUnfree = true;
3638
};
3739

@@ -41,6 +43,17 @@
4143
inherit system;
4244
};
4345

46+
unstablePkgs = import nixpkgs-unstable {
47+
inherit system;
48+
49+
# Workaround for: terraform has an unfree license (‘bsl11’), refusing to evaluate.
50+
config.allowUnfreePredicate =
51+
pkg:
52+
builtins.elem (pkgs.lib.getName pkg) [
53+
"terraform"
54+
];
55+
};
56+
4457
formatter = pkgs.nixfmt-rfc-style;
4558

4659
nodejs = pkgs.nodejs_20;
@@ -148,7 +161,7 @@
148161
shellcheck
149162
(pinnedPkgs.shfmt)
150163
sqlc
151-
terraform
164+
unstablePkgs.terraform
152165
typos
153166
which
154167
# Needed for many LD system libs!
@@ -185,7 +198,7 @@
185198
name = "coder-${osArch}";
186199
# Updated with ./scripts/update-flake.sh`.
187200
# This should be updated whenever go.mod changes!
188-
vendorHash = "sha256-QjqF+QZ5JKMnqkpNh6ZjrJU2QcSqiT4Dip1KoicwLYc=";
201+
vendorHash = "sha256-6sdvX0Wglj0CZiig2VD45JzuTcxwg7yrGoPPQUYvuqU=";
189202
proxyVendor = true;
190203
src = ./.;
191204
nativeBuildInputs = with pkgs; [

0 commit comments

Comments
 (0)