{ description = "nix_builder nix package builder"; 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) ]; pkgs = (import nixpkgs { inherit system overlays; }).pkgsStatic; 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 < Generate metadata for query!() macros: cargo sqlx prepare EOF ''; }; } ); 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; } ); }; }