Files
nix_builder/flake.nix

130 lines
3.4 KiB
Nix
Raw Normal View History

2026-02-14 22:15:09 -05:00
{
2026-07-04 20:36:25 -04:00
description = "nix_builder nix package builder";
2026-02-14 22:15:09 -05:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};
outputs =
{
self,
nixpkgs,
rust-overlay,
}:
let
forAllSystems =
func:
builtins.listToAttrs (
map (system: {
name = system;
value = func system;
}) nixpkgs.lib.systems.flakeExposed
);
in
{
devShells = forAllSystems (
system:
let
overlays = [ (import rust-overlay) ];
2026-07-05 15:02:51 -04:00
pkgs = import nixpkgs {
inherit system overlays;
};
2026-02-14 22:15:09 -05:00
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
{
default = pkgs.mkShell {
nativeBuildInputs = [
pkgs.pkg-config
rustToolchain
];
buildInputs = with pkgs; [
sqlx-cli # For sqlx CLI to manage migrations
sqlite # To access the database (sqlite is bundled into the nix_builder binary but this is for manually accessing the db).
];
shellHook = ''
cat <<EOF
nix_builder dev shell
Create new migrations with:
sqlx migrate add -r <name>
Generate metadata for query!() macros:
cargo sqlx prepare
EOF
'';
};
}
);
2026-07-04 20:36:25 -04:00
packages = forAllSystems (
system:
let
overlays = [ (import rust-overlay) ];
2026-07-05 15:02:51 -04:00
pkgs = import nixpkgs {
inherit system overlays;
};
2026-07-04 20:36:25 -04:00
cargoToml = (pkgs.lib.importTOML ./Cargo.toml);
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
in
rec {
app = rustPlatform.buildRustPackage {
pname = "nix_builder";
version = cargoToml.package.version;
src = pkgs.lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
buildType = "lto";
# RUSTFLAGS = "-C target-cpu=x86-64-v3";
meta = with pkgs.lib; {
description = "A builder of nix configs for a build server.";
homepage = "https://code.fizz.buzz/talexander/nix_builder";
license = licenses.bsd0;
maintainers = [ ];
};
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
wrapProgram $out/bin/nix-builder --prefix PATH : ${
pkgs.lib.makeBinPath [
pkgs.git
pkgs.nix
pkgs.nixos-rebuild
]
}
'';
# nativeBuildInputs = [
# pkgs.pkg-config
# ];
# buildInputs = [
# pkgs.openssl
# ];
};
docker_env = pkgs.buildEnv {
name = "nix_builder";
paths = with pkgs; [
app
# bash
# uutils-coreutils-noprefix
# toybox # Smaller than uutils-coreutils?
];
};
default = app;
}
);
2026-02-14 22:15:09 -05:00
};
}