Files
coder/flake.nix
T
Phorcys 🐾 5bde0ea6ab fix(flake): update Linux Chrome download (#30899)
The Linux development shell downloads Chrome 143.0.7499.169 from a
Google URL that now returns HTTP 404, preventing `nix develop` from
realizing the environment.

Override Linux Chrome to 155.0.8059.84 with its verified download hash,
without updating the nixpkgs inputs. Remove the pinned recipe's
ANGLE-library patch step because this Chrome release no longer bundles
those libraries. Darwin Chrome and the existing aarch64-linux exclusion
are unchanged.

Verified the complete x86_64-linux development shell and a headless
browser smoke test using Nix 2.35.3 in an isolated Docker container.
Evaluated, but did not execute, the other three platforms.

<details>
<summary>Validation evidence</summary>

```text
$ sha256sum google-chrome.deb
8fbd2ae69cdf7ee98b7513c3396a7b5e06f974f8625fdd590df3091dd0c3e9de  google-chrome.deb

$ nix develop --no-write-lock-file --max-jobs 2 --cores 2 --command true
# Exit status: 0; full environment realized.

$ nix develop --no-write-lock-file --command google-chrome-stable --version
Google Chrome 155.0.8059.84

$ google-chrome-stable --headless --no-sandbox --disable-dev-shm-usage --disable-gpu --dump-dom about:blank
<html><head></head><body></body></html>
# Exit status: 0. --no-sandbox was used only for the root-run container smoke test.
```

Platform evaluation selected Chrome 155.0.8059.84 on x86_64-linux, no
Chrome on aarch64-linux, and the existing Chrome 143.0.7499.170 on both
Darwin platforms. Darwin evaluation retains existing SDK deprecation
warnings.

`git diff --check` passed. The new override matches the
repository-pinned nixfmt output; pre-existing formatting elsewhere in
the flake was left unchanged.

</details>

AI-assisted implementation and validation using Xum. The model
identifier was not exposed to this session.
2026-10-16 15:57:13 +02:00

453 lines
15 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
description = "Development environments on your infrastructure";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-pinned.url = "github:nixos/nixpkgs/5deee6281831847857720668867729617629ef1f";
flake-utils.url = "github:numtide/flake-utils";
pnpm2nix = {
url = "github:ThomasK33/pnpm2nix-nzbr";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
drpc = {
url = "github:storj/drpc/v0.0.34";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
{
self,
nixpkgs,
nixpkgs-pinned,
nixpkgs-unstable,
flake-utils,
drpc,
pnpm2nix,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
# Workaround for: google-chrome has an unfree license (‘unfree’), refusing to evaluate.
config.allowUnfree = true;
};
# pinnedPkgs is used to pin packages that need to stay in sync with CI.
# Everything else uses unstable.
pinnedPkgs = import nixpkgs-pinned {
inherit system;
};
unstablePkgs = import nixpkgs-unstable {
inherit system;
# Workaround for: terraform has an unfree license (‘bsl11’), refusing to evaluate.
config.allowUnfreePredicate =
pkg:
builtins.elem (pkgs.lib.getName pkg) [
"terraform"
];
};
formatter = pkgs.nixfmt-rfc-style;
nodejs = unstablePkgs.nodejs_22;
pnpm = pkgs.pnpm_10.override {
inherit nodejs; # Ensure it points to the above nodejs version
};
mise = pkgs.stdenvNoCC.mkDerivation rec {
pname = "mise";
version = "2026.5.12";
target = {
x86_64-linux = "linux-x64";
aarch64-linux = "linux-arm64";
x86_64-darwin = "macos-x64";
aarch64-darwin = "macos-arm64";
}.${system};
src = pkgs.fetchurl {
url = "https://github.com/jdx/mise/releases/download/v${version}/mise-v${version}-${target}";
hash = {
x86_64-linux = "sha256-ojiXKjFi1xC4WyjDJDculspOS0hsgf54aVAA2fvHfEg=";
aarch64-linux = "sha256-/S1SJ6itCx41nHBSeoNFqa2nIHf43LtVk3FlPD2VRk8=";
x86_64-darwin = "sha256-3lfo3IK72ICmnJvIruBrncxXgYSz5c+G/O+AY11qkLQ=";
aarch64-darwin = "sha256-53cHBUD/4iz4srn4iu2ItGHQiH2UDE8cGpc1lGPN5uE=";
}.${system};
};
dontUnpack = true;
installPhase = ''
install -Dm755 "$src" "$out/bin/mise"
'';
};
# Check in https://search.nixos.org/packages to find new packages.
# Use `nix --extra-experimental-features nix-command --extra-experimental-features flakes flake update`
# to update the lock file if packages are out-of-date.
# From https://nixos.wiki/wiki/Google_Cloud_SDK
gdk = pkgs.google-cloud-sdk.withExtraComponents [
pkgs.google-cloud-sdk.components.gke-gcloud-auth-plugin
];
proto_gen_go_1_30 = pkgs.buildGoModule rec {
name = "protoc-gen-go";
owner = "protocolbuffers";
repo = "protobuf-go";
rev = "v1.30.0";
src = pkgs.fetchFromGitHub {
inherit owner repo rev;
# Updated with ./scripts/update-flake.sh`.
sha256 = "sha256-GTZQ40uoi62Im2F4YvlZWiSNNJ4fEAkRojYa0EYz9HU=";
};
subPackages = [ "cmd/protoc-gen-go" ];
vendorHash = null;
};
# Keep protoc aligned with mise.toml so local Nix shells use
# the same codegen tool version as CI and release workflows,
# regardless of nixpkgs channel defaults.
protobuf_23_4 =
let
releases = {
x86_64-linux = {
platform = "linux-x86_64";
hash = "sha256-BQLyhqye2GC2KaeWWhRSex8t0THkKD+iPC1/GEZyqpo=";
};
aarch64-linux = {
platform = "linux-aarch_64";
hash = "sha256-HHdQtuA4MFtaf8PQzaHr798Qak8wp4e/gm7S/EfDln0=";
};
aarch64-darwin = {
platform = "osx-aarch_64";
hash = "sha256-jHr66GJraBHntYl9FtlAwtv1Cx4TXtlYoB22VmvdpyY=";
};
x86_64-darwin = {
platform = "osx-x86_64";
hash = "sha256-B+X9zxsHCNM2fcXm640TXefkB9dTFskxVc/YqzYu7IA=";
};
};
target = releases.${system} or null;
in
if target != null then
pkgs.runCommand "protobuf-23.4" {
nativeBuildInputs = [ pkgs.unzip ];
src = pkgs.fetchurl {
url = "https://github.com/protocolbuffers/protobuf/releases/download/v23.4/protoc-23.4-${target.platform}.zip";
hash = target.hash;
};
} ''
mkdir -p "$out"
cd "$out"
unzip "$src"
chmod +x "$out/bin/protoc"
''
else
throw "protobuf 23.4 is not defined for ${system}";
# Custom sqlc build from coder/sqlc fork to fix ambiguous column bug, see:
# - https://github.com/coder/sqlc/pull/1
# - https://github.com/sqlc-dev/sqlc/pull/4159
#
# To update hashes:
# 1. Run: `nix --extra-experimental-features 'nix-command flakes' build .#devShells.x86_64-linux.default`
# 2. Nix will fail with the correct sha256 hash for src
# 3. Update the sha256 and run again
# 4. Nix will fail with the correct vendorHash
# 5. Update the vendorHash
sqlc-custom = unstablePkgs.buildGo126Module {
pname = "sqlc";
version = "coder-fork-337309bfb9524f38466a5090e310040fc7af0203";
src = pkgs.fetchFromGitHub {
owner = "coder";
repo = "sqlc";
rev = "337309bfb9524f38466a5090e310040fc7af0203";
sha256 = "sha256-i8hZaaMlNJyW0hUWYcuNqUcwRdQU747055OknZsJ9Es=";
};
subPackages = [ "cmd/sqlc" ];
vendorHash = "sha256-4Cb15MhKyhRvYVKfMqBwuC3WBBIJE6AinJt02+TSMVY=";
};
paralleltestctx = unstablePkgs.buildGo126Module {
pname = "paralleltestctx";
version = "0.0.2";
src = pkgs.fetchFromGitHub {
owner = "coder";
repo = "paralleltestctx";
rev = "v0.0.2";
sha256 = "sha256-qFQ4LZR2IwqscypD0URSZKXTlhUcz/axDb8NTH5CxLw=";
};
subPackages = [ "cmd/paralleltestctx" ];
vendorHash = "sha256-OuQWmZmofdJKq1hvk43RPkILQwAuFzqhmB22Xf6Z3lA=";
};
# Keep this pin aligned with mise.toml when updating Terraform.
terraform_1_15_5 =
let
releases = {
x86_64-linux = {
platform = "linux_amd64";
hash = "sha256-OANLONAwljmaehJkoUVhqAKbK0lv0fFpRSZW5Tlo8bc=";
};
aarch64-linux = {
platform = "linux_arm64";
hash = "sha256-p1C1oRA48WWEayZYxAyIzXBwqmemG6tDGhS6J5KOqeo=";
};
aarch64-darwin = {
platform = "darwin_arm64";
hash = "sha256-heG8eKtFvcX4KnusOSnjfQcoNKWE0iWDokmNxnu2JM0=";
};
x86_64-darwin = {
platform = "darwin_amd64";
hash = "sha256-eUo2w/fr9sWPIInCJgaKU50XBbo1ilZ5tRZxyNx+vHs=";
};
};
target = releases.${system} or null;
in
if target != null then
pkgs.runCommand "terraform-1.16.6" {
nativeBuildInputs = [ pkgs.unzip ];
src = pkgs.fetchurl {
url = "https://releases.hashicorp.com/terraform/1.16.6/terraform_1.16.6_${target.platform}.zip";
hash = target.hash;
};
} ''
mkdir -p "$out/bin"
unzip -p "$src" terraform > "$out/bin/terraform"
chmod +x "$out/bin/terraform"
''
else
unstablePkgs.terraform;
# Packages required to build the frontend
frontendPackages =
with pkgs;
[
cairo
pango
pixman
libpng
libjpeg
giflib
librsvg
python312Packages.setuptools # Needed for node-gyp
]
++ (lib.optionals stdenv.targetPlatform.isDarwin [
darwin.apple_sdk_12_3.frameworks.Foundation
xcbuild
]);
migrate = pkgs.go-migrate.overrideAttrs (_oldAttrs: {
# Coder only needs migrate for migration creation and local Postgres
# migrations. The nixpkgs default build includes every database
# driver and is broken by a bad Go and driver combination, so rebuild
# only with the driver we need.
tags = [ "postgres" ];
});
googleChrome =
if pkgs.stdenv.isLinux then
pkgs.google-chrome.overrideAttrs (
finalAttrs: oldAttrs: {
version = "155.0.8059.84";
src = pkgs.fetchurl {
url = "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${finalAttrs.version}-1_amd64.deb";
hash = "sha256-j70q5pzffumLdRPDOWp7Xgb5dPhiX91ZDfMJHdDD6d4=";
};
# Chrome no longer ships standalone ANGLE libraries.
installPhase =
builtins.replaceStrings
[
''
# Make sure that libGL and libvulkan are found by ANGLE libGLESv2.so
patchelf --set-rpath $rpath $out/share/google/$appname/lib*GL*
''
]
[ "" ]
oldAttrs.installPhase;
}
)
else
pkgs.google-chrome;
# The minimal set of packages to build Coder.
devShellPackages =
with pkgs;
[
# google-chrome is not available on aarch64 linux
(lib.optionalDrvAttr (!stdenv.isLinux || !stdenv.isAarch64) googleChrome)
# strace is not available on OSX
(lib.optionalDrvAttr (!pkgs.stdenv.isDarwin) strace)
bat
cairo
curl
cosign
delve
dive
drpc.defaultPackage.${system}
formatter
fzf
gawk
gcc13
gdk
getopt
gh
git
git-lfs
(lib.optionalDrvAttr stdenv.isLinux glibcLocales)
gnumake
gnused
gnugrep
gnutar
unstablePkgs.go_1_26
gofumpt
migrate
(pinnedPkgs.golangci-lint)
gopls
gotestsum
hadolint
jq
kubectl
kubectx
kubernetes-helm
lazydocker
lazygit
less
mise
unstablePkgs.mockgen
moreutils
nfpm
nix-prefetch-git
nodejs
openssh
openssl
paralleltestctx
pango
pixman
pkg-config
pnpm
postgresql_16
proto_gen_go_1_30
protobuf_23_4
ripgrep
rsync
shellcheck
(pinnedPkgs.shfmt)
# sqlc
sqlc-custom
syft
terraform_1_15_5
typos
which
# Needed for many LD system libs!
(lib.optional stdenv.isLinux util-linux)
vim
wget
yq-go
zip
zsh
zstd
]
++ frontendPackages;
# buildSite packages the site directory.
buildSite = pnpm2nix.packages.${system}.mkPnpmPackage {
inherit nodejs pnpm;
src = ./site/.;
# Required for the `canvas` package!
extraBuildInputs = frontendPackages;
installInPlace = true;
distDir = "out";
};
version = "v0.0.0-nix-${self.shortRev or self.dirtyShortRev}";
# To make faster subsequent builds, you could extract the `.zst`
# slim bundle into it's own derivation.
buildFat =
osArch:
unstablePkgs.buildGo126Module {
name = "coder-${osArch}";
# Updated with ./scripts/update-flake.sh`.
# This should be updated whenever go.mod changes!
vendorHash = "sha256-6sdvX0Wglj0CZiig2VD45JzuTcxwg7yrGoPPQUYvuqU=";
proxyVendor = true;
src = ./.;
nativeBuildInputs = with pkgs; [
getopt
openssl
zstd
];
preBuild = ''
# Replaces /usr/bin/env with an absolute path to the interpreter.
patchShebangs ./scripts
'';
buildPhase = ''
runHook preBuild
# Unpack the site contents.
mkdir -p ./site/out ./site/node_modules/
cp -r ${buildSite.out}/* ./site/out
touch ./site/node_modules/.installed
# Build and copy the binary!
export CODER_FORCE_VERSION=${version}
# Flagging 'site/node_modules/.installed' as an old file,
# as we do not want to trigger codegen during a build.
make -j -o 'site/node_modules/.installed' build/coder_${osArch}
'';
installPhase = ''
mkdir -p $out/bin
cp -r ./build/coder_${osArch} $out/bin/coder
'';
};
in
rec {
inherit formatter;
devShells = {
default =
(pkgs.mkShell.override (
pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
stdenv = pkgs.overrideSDK pkgs.stdenv "12.3";
}
))
{
buildInputs = devShellPackages;
LOCALE_ARCHIVE =
with pkgs;
lib.optionalDrvAttr stdenv.isLinux "${glibcLocales}/lib/locale/locale-archive";
NODE_OPTIONS = "--max-old-space-size=8192";
GOPRIVATE = "coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder";
};
};
packages = {
default = packages.${system};
proto_gen_go = proto_gen_go_1_30;
site = buildSite;
# Copying `OS_ARCHES` from the Makefile.
x86_64-linux = buildFat "linux_amd64";
aarch64-linux = buildFat "linux_arm64";
x86_64-darwin = buildFat "darwin_amd64";
aarch64-darwin = buildFat "darwin_arm64";
x86_64-windows = buildFat "windows_amd64.exe";
aarch64-windows = buildFat "windows_arm64.exe";
};
}
);
}