Set up nix building.

This commit is contained in:
Tom Alexander
2026-07-04 20:36:25 -04:00
parent b61f0e0364
commit b2e2ef2b24
3 changed files with 71 additions and 5 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
/work
/example_logs
TODO.org
/result

View File

@@ -27,7 +27,7 @@ url = { version = "2.5.8", default-features = false, features = ["std"] }
primal = { version = "0.3.3", default-features = false, features = [] }
# Optimized build for any sort of release.
[profile.release-lto]
[profile.lto]
inherits = "release"
lto = true
strip = "symbols"

View File

@@ -1,5 +1,5 @@
{
description = "nix_builder development environment";
description = "nix_builder nix package builder";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
@@ -33,9 +33,10 @@
system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
pkgs =
(import nixpkgs {
inherit system overlays;
}).pkgsStatic;
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
{
@@ -62,5 +63,69 @@
};
}
);
packages = forAllSystems (
system:
let
overlays = [ (import rust-overlay) ];
pkgs =
(import nixpkgs {
inherit system overlays;
}).pkgsStatic;
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;
}
);
};
}