init: Prove the concept of reproducible builds
This commit is contained in:
commit
b957af3edb
9 changed files with 2075 additions and 0 deletions
81
flake.nix
Normal file
81
flake.nix
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
{
|
||||
description = "Hello World Rust application with neofetch and banner";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
|
||||
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
||||
extensions = [ "rust-src" ];
|
||||
};
|
||||
|
||||
# Build the Rust application
|
||||
rustApp = pkgs.rustPlatform.buildRustPackage {
|
||||
pname = "hello-world";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
nativeBuildInputs = [ rustToolchain ];
|
||||
buildInputs = [
|
||||
pkgs.xorg.libxcb
|
||||
];
|
||||
};
|
||||
|
||||
# Create a Docker image with the app and dependencies
|
||||
dockerImage = pkgs.dockerTools.buildLayeredImage {
|
||||
name = "hello-world";
|
||||
tag = "latest";
|
||||
|
||||
contents = [
|
||||
rustApp
|
||||
pkgs.bashInteractive
|
||||
pkgs.coreutils
|
||||
];
|
||||
|
||||
config = {
|
||||
Cmd = [ "${rustApp}/bin/hello-world" ];
|
||||
Env = [
|
||||
"PATH=/bin"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
default = rustApp;
|
||||
app = rustApp;
|
||||
docker = dockerImage;
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
rustToolchain
|
||||
pkgs.rust-analyzer
|
||||
pkgs.docker
|
||||
pkgs.xorg.libxcb
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "Rust development environment loaded!"
|
||||
echo "Rust version: $(rustc --version)"
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue