Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Velnbur committed Jan 20, 2024
0 parents commit dcdeeff
Show file tree
Hide file tree
Showing 15 changed files with 455 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use nix
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake.lock linguist-generated=true
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI

on:
push:
branches: ["master"]
pull_request:
branches: ["develop"]

workflow_dispatch:

jobs:
build:
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v4
- name: Run the Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v2
- name: Build
run: |
nix build .#
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/result-bin
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions Cargo.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This file was @generated by cargo2nix 0.11.0.
# It is not intended to be manually edited.

args@{
release ? true,
rootFeatures ? [
"utils/default"
"cli/default"
],
rustPackages,
buildRustPackages,
hostPlatform,
hostPlatformCpu ? null,
hostPlatformFeatures ? [],
target ? null,
codegenOpts ? null,
profileOpts ? null,
cargoUnstableFlags ? null,
rustcLinkFlags ? null,
rustcBuildFlags ? null,
mkRustCrate,
rustLib,
lib,
workspaceSrc,
ignoreLockHash,
}:
let
nixifiedLockHash = "e1174dd2490db7bebb5095bd9a33dae53aa22730bb5a9f6514c4cebc093fd14e";
workspaceSrc = if args.workspaceSrc == null then ./. else args.workspaceSrc;
currentLockHash = builtins.hashFile "sha256" (workspaceSrc + /Cargo.lock);
lockHashIgnored = if ignoreLockHash
then builtins.trace "Ignoring lock hash" ignoreLockHash
else ignoreLockHash;
in if !lockHashIgnored && (nixifiedLockHash != currentLockHash) then
throw ("Cargo.nix ${nixifiedLockHash} is out of sync with Cargo.lock ${currentLockHash}")
else let
inherit (rustLib) fetchCratesIo fetchCrateLocal fetchCrateGit fetchCrateAlternativeRegistry expandFeatures decideProfile genDrvsByProfile;
profilesByName = {
};
rootFeatures' = expandFeatures rootFeatures;
overridableMkRustCrate = f:
let
drvs = genDrvsByProfile profilesByName ({ profile, profileName }: mkRustCrate ({ inherit release profile hostPlatformCpu hostPlatformFeatures target profileOpts codegenOpts cargoUnstableFlags rustcLinkFlags rustcBuildFlags; } // (f profileName)));
in { compileMode ? null, profileName ? decideProfile compileMode release }:
let drv = drvs.${profileName}; in if compileMode == null then drv else drv.override { inherit compileMode; };
in
{
cargo2nixVersion = "0.11.0";
workspace = {
utils = rustPackages.unknown.utils."0.1.0";
cli = rustPackages.unknown.cli."0.1.0";
};
"unknown".cli."0.1.0" = overridableMkRustCrate (profileName: rec {
name = "cli";
version = "0.1.0";
registry = "unknown";
src = fetchCrateLocal workspaceSrc;
dependencies = {
utils = (rustPackages."unknown".utils."0.1.0" { inherit profileName; }).out;
};
});

"unknown".utils."0.1.0" = overridableMkRustCrate (profileName: rec {
name = "utils";
version = "0.1.0";
registry = "unknown";
src = fetchCrateLocal workspaceSrc;
});

}
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = [
"crates/utils",
"apps/cli",
]
Empty file added README.md
Empty file.
9 changes: 9 additions & 0 deletions apps/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "cli"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
utils = { path = "../../crates/utils" }
5 changes: 5 additions & 0 deletions apps/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use utils::add;

fn main() {
println!("Hello, world! {}", add(1, 2));
}
8 changes: 8 additions & 0 deletions crates/utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "utils"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
14 changes: 14 additions & 0 deletions crates/utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
230 changes: 230 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dcdeeff

Please sign in to comment.