mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
templates/rust-app: init
This commit is contained in:
parent
738c7a5004
commit
1d7ff0fcc5
@ -18,6 +18,10 @@
|
||||
path = ../../templates/basic-overlay-flake;
|
||||
description = "Basic overlay as a flake";
|
||||
};
|
||||
rust-app = {
|
||||
path = ../../templates/rust-app;
|
||||
description = "Rust app scaffolding";
|
||||
};
|
||||
sample-nixos-template = {
|
||||
path = ../../templates/sample-nixos-template;
|
||||
description = "Simple sample Nix flake with NixOS and home-manager";
|
||||
|
8
templates/rust-app/Cargo.toml
Normal file
8
templates/rust-app/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "rust-app"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
37
templates/rust-app/default.nix
Normal file
37
templates/rust-app/default.nix
Normal file
@ -0,0 +1,37 @@
|
||||
{ lib
|
||||
, rustPlatform
|
||||
, meson
|
||||
, ninja
|
||||
, pkg-config
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "app";
|
||||
version = "VERSION";
|
||||
|
||||
src = lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = lib.fs.unions [
|
||||
./Cargo.lock
|
||||
./Cargo.toml
|
||||
./LICENSE
|
||||
./meson.build
|
||||
./meson_options.txt
|
||||
./src
|
||||
];
|
||||
};
|
||||
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Rust app";
|
||||
mainProgram = "app";
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
42
templates/rust-app/flake.nix
Normal file
42
templates/rust-app/flake.nix
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, ... }@inputs:
|
||||
let
|
||||
inherit (nixpkgs) lib;
|
||||
systems = [ "x86_64-linux" ];
|
||||
forAllSystems = f: lib.genAttrs systems (system: f system);
|
||||
in
|
||||
{
|
||||
devShells = forAllSystems
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.rust-overlay.overlays.default
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
default = import ./shell.nix { inherit pkgs; };
|
||||
});
|
||||
|
||||
packages = forAllSystems
|
||||
(system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.rust-overlay.overlays.default
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
default = pkgs.callPackage ./. { };
|
||||
});
|
||||
};
|
||||
}
|
5
templates/rust-app/meson.build
Normal file
5
templates/rust-app/meson.build
Normal file
@ -0,0 +1,5 @@
|
||||
project('rust-app', 'rust',
|
||||
version: '0.1.0',
|
||||
meson_version: '>=1.0.0')
|
||||
|
||||
subdir('src')
|
13
templates/rust-app/shell.nix
Normal file
13
templates/rust-app/shell.nix
Normal file
@ -0,0 +1,13 @@
|
||||
{ pkgs }:
|
||||
|
||||
let
|
||||
app = pkgs.callPackage ./. { };
|
||||
in
|
||||
pkgs.mkShell {
|
||||
inputsFrom = [ app ];
|
||||
|
||||
packages = with pkgs; [
|
||||
treefmt
|
||||
rust-analyzer
|
||||
];
|
||||
}
|
3
templates/rust-app/src/main.rs
Normal file
3
templates/rust-app/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
6
templates/rust-app/src/meson.build
Normal file
6
templates/rust-app/src/meson.build
Normal file
@ -0,0 +1,6 @@
|
||||
srcs = [
|
||||
'main.rs'
|
||||
]
|
||||
|
||||
executable('app',
|
||||
srcs)
|
Loading…
Reference in New Issue
Block a user