Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8226db4

Browse files
committed
feat(flake.nix): switch dogfood dev image to buildNixShellImage from dockerTools
Change-Id: I4e011fe3a19d9a1375fbfd5223c910e59d66a5d9Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent923ef56 commit8226db4

File tree

7 files changed

+105
-88
lines changed

7 files changed

+105
-88
lines changed

‎.github/workflows/dogfood.yaml

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ jobs:
3434
-name:Checkout
3535
uses:actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871# v4.2.1
3636

37+
-name:Setup Nix
38+
uses:DeterminateSystems/nix-installer-action@e50d5f73bfe71c2dd0aa4218de8f4afa59f8f81d# v16
39+
-name:Setup GHA Nix cache
40+
uses:DeterminateSystems/magic-nix-cache-action@6221693898146dc97e38ad0e013488a16477a4c4# v9
41+
3742
-name:Get branch name
3843
id:branch-name
3944
uses:tj-actions/branch-names@6871f53176ad61624f978536bbf089c574dc19a2# v8.0.1
@@ -72,17 +77,23 @@ jobs:
7277
tags:"codercom/oss-dogfood:${{ steps.docker-tag-name.outputs.tag }},codercom/oss-dogfood:latest"
7378

7479
-name:Build and push Nix image
75-
uses:depot/build-push-action@636daae76684e38c301daa0c5eca1c095b24e780# v1.14.0
76-
with:
77-
project:b4q6ltmpzh
78-
token:${{ secrets.DEPOT_TOKEN }}
79-
buildx-fallback:true
80-
context:"."
81-
file:"dogfood/contents/Dockerfile.nix"
82-
pull:true
83-
save:true
84-
push:${{ github.ref == 'refs/heads/main' }}
85-
tags:"codercom/oss-dogfood-nix:${{ steps.docker-tag-name.outputs.tag }},codercom/oss-dogfood-nix:latest"
80+
run:|
81+
nix build .#dev_image
82+
83+
# If github.ref is not refs/head/main then exit here early
84+
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
85+
exit 0
86+
fi
87+
88+
docker load -i result
89+
90+
CURRENT_SYSTEM=$(nix eval --impure --raw --expr 'builtins.currentSystem')
91+
92+
docker image tag codercom/oss-dogfood-nix:latest-$CURRENT_SYSTEM codercom/oss-dogfood-nix:${{ steps.docker-tag-name.outputs.tag }}
93+
docker image push codercom/oss-dogfood-nix:${{ steps.docker-tag-name.outputs.tag }}
94+
95+
docker image tag codercom/oss-dogfood-nix:latest-$CURRENT_SYSTEM codercom/oss-dogfood-nix:latest
96+
docker image push codercom/oss-dogfood-nix:latest
8697
8798
deploy_template:
8899
needs:build_image

‎Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,3 +952,6 @@ else
952952
pnpm playwright:test
953953
endif
954954
.PHONY: test-e2e
955+
956+
dogfood/contents/nix.hash: flake.nix flake.lock
957+
sha256sum flake.nix flake.lock>./dogfood/contents/nix.hash

‎dogfood/contents/Dockerfile.nix

Lines changed: 0 additions & 42 deletions
This file was deleted.

‎dogfood/contents/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ resource "docker_image" "dogfood" {
344344
data.docker_registry_image.dogfood.sha256_digest,
345345
sha1(join("", [forfinfileset(path.module,"files/*"):filesha1(f)])),
346346
filesha1("Dockerfile"),
347-
filesha1("Dockerfile.nix"),
347+
filesha1("nix.hash"),
348348
]
349349
keep_locally=true
350350
}

‎dogfood/contents/nix.hash

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
7f76642cfe331925935c526e068788c30213e36df85b20214d517d1a2fdf3954 flake.nix
2+
2358e758b2369c744a3f38d5b6cd3a71e79fcb99bdbb3bdeb8d3a520cf46f19f flake.lock

‎flake.nix

Lines changed: 75 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@
1717
};
1818
};
1919

20-
outputs={self,nixpkgs,nixpkgs-pinned,flake-utils,drpc,pnpm2nix}:
21-
flake-utils.lib.eachDefaultSystem(system:
20+
outputs=
21+
{
22+
self,
23+
nixpkgs,
24+
nixpkgs-pinned,
25+
flake-utils,
26+
drpc,
27+
pnpm2nix,
28+
}:
29+
flake-utils.lib.eachDefaultSystem(
30+
system:
2231
let
2332
pkgs=importnixpkgs{
2433
inheritsystem;
@@ -32,17 +41,21 @@
3241
inheritsystem;
3342
};
3443

44+
formatter=pkgs.nixfmt-rfc-style;
45+
3546
nodejs=pkgs.nodejs_20;
3647
pnpm=pkgs.pnpm_9.override{
37-
inheritnodejs;# Ensure it points to the above nodejs version
48+
inheritnodejs;# Ensure it points to the above nodejs version
3849
};
3950

4051
# Check in https://search.nixos.org/packages to find new packages.
4152
# Use `nix --extra-experimental-features nix-command --extra-experimental-features flakes flake update`
4253
# to update the lock file if packages are out-of-date.
4354

4455
# From https://nixos.wiki/wiki/Google_Cloud_SDK
45-
gdk=pkgs.google-cloud-sdk.withExtraComponents([pkgs.google-cloud-sdk.components.gke-gcloud-auth-plugin]);
56+
gdk=pkgs.google-cloud-sdk.withExtraComponents[
57+
pkgs.google-cloud-sdk.components.gke-gcloud-auth-plugin
58+
];
4659

4760
proto_gen_go_1_30=pkgs.buildGoModulerec{
4861
name="protoc-gen-go";
@@ -63,14 +76,16 @@
6376
# The minimal set of packages to build Coder.
6477
devShellPackages=withpkgs;[
6578
# google-chrome is not available on aarch64 linux
66-
(lib.optionalDrvAttr(!stdenv.isLinux||!stdenv.isAarch64)google-chrome)
79+
(lib.optionalDrvAttr(!stdenv.isLinux||!stdenv.isAarch64)google-chrome)
6780
# strace is not available on OSX
68-
(lib.optionalDrvAttr(!pkgs.stdenv.isDarwin)strace)
81+
(lib.optionalDrvAttr(!pkgs.stdenv.isDarwin)strace)
6982
bat
7083
cairo
7184
curl
7285
delve
86+
dive
7387
drpc.defaultPackage.${system}
88+
formatter
7489
fzf
7590
gcc
7691
gdk
@@ -129,13 +144,22 @@
129144

130145
src=./site/.;
131146
# Required for the `canvas` package!
132-
extraBuildInputs=withpkgs;[
133-
cairo
134-
pango
135-
pixman
136-
libpnglibjpeggifliblibrsvg
137-
python312Packages.setuptools
138-
]++(lib.optionalsstdenv.targetPlatform.isDarwin[darwin.apple_sdk.frameworks.Foundationxcbuild]);
147+
extraBuildInputs=
148+
withpkgs;
149+
[
150+
cairo
151+
pango
152+
pixman
153+
libpng
154+
libjpeg
155+
giflib
156+
librsvg
157+
python312Packages.setuptools
158+
]
159+
++(lib.optionalsstdenv.targetPlatform.isDarwin[
160+
darwin.apple_sdk.frameworks.Foundation
161+
xcbuild
162+
]);
139163
installInPlace=true;
140164
distDir="out";
141165
};
@@ -144,15 +168,20 @@
144168

145169
# To make faster subsequent builds, you could extract the `.zst`
146170
# slim bundle into it's own derivation.
147-
buildFat=osArch:
171+
buildFat=
172+
osArch:
148173
pkgs.buildGo122Module{
149174
name="coder-${osArch}";
150175
# Updated with ./scripts/update-flake.sh`.
151176
# This should be updated whenever go.mod changes!
152-
vendorHash="sha256-DNQ3UPQoiiWEatMPj6B7QGGy9qOSvOmjADsrr+drCBY=";
177+
vendorHash="sha256-31GuIzqa3kuVIKQ7Fy6Xm/lHLlBRv7VOKpWSQoelnos=";
153178
proxyVendor=true;
154179
src=./.;
155-
nativeBuildInputs=withpkgs;[getoptopensslzstd];
180+
nativeBuildInputs=withpkgs;[
181+
getopt
182+
openssl
183+
zstd
184+
];
156185
preBuild=''
157186
# Replaces /usr/bin/env with an absolute path to the interpreter.
158187
patchShebangs ./scripts
@@ -177,7 +206,9 @@
177206
'';
178207
};
179208
in
180-
{
209+
rec{
210+
inheritformatter;
211+
181212
devShells={
182213
default=pkgs.mkShell{
183214
buildInputs=devShellPackages;
@@ -186,26 +217,36 @@
186217
export PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS=true
187218
'';
188219

189-
LOCALE_ARCHIVE=withpkgs;lib.optionalDrvAttrstdenv.isLinux"${glibcLocales}/lib/locale/locale-archive";
220+
LOCALE_ARCHIVE=
221+
withpkgs;
222+
lib.optionalDrvAttrstdenv.isLinux"${glibcLocales}/lib/locale/locale-archive";
190223
};
191224
};
192225

193-
packages={
194-
proto_gen_go=proto_gen_go_1_30;
195-
all=pkgs.buildEnv{
196-
name="all-packages";
197-
paths=devShellPackages;
198-
};
199-
site=buildSite;
200-
201-
# Copying `OS_ARCHES` from the Makefile.
202-
linux_amd64=buildFat"linux_amd64";
203-
linux_arm64=buildFat"linux_arm64";
204-
darwin_amd64=buildFat"darwin_amd64";
205-
darwin_arm64=buildFat"darwin_arm64";
206-
windows_amd64=buildFat"windows_amd64.exe";
207-
windows_arm64=buildFat"windows_arm64.exe";
208-
};
226+
packages=
227+
{
228+
default=packages.${system};
229+
230+
site=buildSite;
231+
232+
# Copying `OS_ARCHES` from the Makefile.
233+
x86_64-linux=buildFat"linux_amd64";
234+
aarch64-linux=buildFat"linux_arm64";
235+
x86_64-darwin=buildFat"darwin_amd64";
236+
aarch64-darwin=buildFat"darwin_arm64";
237+
x86_64-windows=buildFat"windows_amd64.exe";
238+
aarch64-windows=buildFat"windows_arm64.exe";
239+
}
240+
//(pkgs.lib.optionalAttrspkgs.stdenv.isLinux{
241+
dev_image=pkgs.dockerTools.buildNixShellImage{
242+
name="codercom/oss-dogfood-nix";
243+
tag="latest-${system}";
244+
245+
drv=devShells.default.overrideAttrs(oldAttrs:{
246+
buildInputs=oldAttrs.buildInputs++[pkgs.nix];
247+
});
248+
};
249+
});
209250
}
210251
);
211252
}

‎scripts/update-flake.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ echo "protoc-gen-go version: $PROTOC_GEN_GO_REV"
3737
PROTOC_GEN_GO_SHA256=$(nix-prefetch-git https://github.com/protocolbuffers/protobuf-go --rev"$PROTOC_GEN_GO_REV"| jq -r .hash)
3838
sed -i"s#\(sha256 =\"\)[^\"]*#\1${PROTOC_GEN_GO_SHA256}#" ./flake.nix
3939
40+
make dogfood/contents/nix.hash
41+
4042
echo"Flake updated successfully!"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp