Skip to content
Open
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
33 changes: 0 additions & 33 deletions flake.lock

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

97 changes: 52 additions & 45 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,69 +1,76 @@
# Copyright 2025 The zb Authors
# SPDX-License-Identifier: MIT

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "flake-utils";
};

outputs =
{
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
};
let
inherit (nixpkgs) lib;

inherit (pkgs.lib.attrsets) optionalAttrs;
forEachSystem =
fn: lib.genAttrs lib.systems.flakeExposed (system: fn system nixpkgs.legacyPackages.${system});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per nixpkgs:

This attribute is considered experimental and is subject to change.

I also don't really want to expand to that potential set to what nixpkgs supports: zb is very OS-dependent, and so the exact set of targets is important. Let's use an explicit list of systems.

in
{
devShells = forEachSystem (
_: pkgs: {
default = pkgs.mkShellNoCC {
packages = [
# Go tooling.
(pkgs.delve.override {
buildGoModule = pkgs.buildGo125Module;
})
pkgs.go_1_25
pkgs.gopls

go = pkgs.go_1_25;
buildGoModule = pkgs.buildGo125Module;
# JavaScript tooling.
pkgs.nodejs_22
];

zbPackage = pkgs.callPackage ./package.nix {
inherit buildGoModule;
};
# Since using Go 1.25 from nixpkgs,
# the Go tool seems to try to use cgo for net and os/user,
# even though it is not necessary.
# We disable cgo forcibly for consistency.
CGO_ENABLED = "0";

installerPackage = pkgs.callPackage ./installer {};
in
{
devShells.default = pkgs.mkShellNoCC {
packages = [
# Go tooling.
(pkgs.delve.override {
inherit buildGoModule;
})
go
pkgs.gopls
hardeningDisable = [ "fortify" ];
};
}
);

# JavaScript tooling.
pkgs.nodejs_22
];
packages = forEachSystem (
system: pkgs:
let
buildGoModule = pkgs.buildGo125Module;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that this is separated from the Go up above and I'm worried it's going to get out of sync. Can we restructure this so that it is a top-level for-each like what's in main?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we restructure this so that it is a top-level for-each like what's in main?

Then aren't we just trying to re-create flake-utils, which isnt really ideal imo.

I'll try to unify the behavior here.


# Since using Go 1.25 from nixpkgs,
# the Go tool seems to try to use cgo for net and os/user,
# even though it is not necessary.
# We disable cgo forcibly for consistency.
CGO_ENABLED = "0";
zbPackage = pkgs.callPackage ./package.nix {
inherit buildGoModule;
};

hardeningDisable = [ "fortify" ];
};
installerPackage = pkgs.callPackage ./installer { };
in
(
{
default = zbPackage;
}
// lib.optionalAttrs (builtins.elem system installerPackage.meta.platforms) {
installer = installerPackage;
}
)
);

packages = {
default = zbPackage;
} // optionalAttrs (builtins.elem system installerPackage.meta.platforms) {
installer = installerPackage;
};
}
)
// {
nixosModules.default = {pkgs, lib, ... }:
nixosModules.default =
{
pkgs,
lib,
...
}:
let
# Slightly higher than option defaults (1500),
# but lower than lib.mkDefault (1000).
Expand Down