Compare commits

..

7 Commits

Author SHA1 Message Date
63e8db100b Modernise CI (#9)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Co-authored-by: Smaug123 <3138005+Smaug123@users.noreply.github.com>
Reviewed-on: #9
2025-09-08 22:59:08 +00:00
338a6fd1ad Rearrange conditions in pipeline (#8)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #8
2023-08-26 12:40:38 +00:00
6f6bb6d92e Fix syntax error in pipeline (#7)
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #7
2023-08-03 20:06:33 +00:00
1f95f68c4d Upgrade to Woodpecker v1 (#6)
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #6
2023-08-01 22:01:16 +00:00
e2a53a72ef Fix condition in pipeline (#5)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #5
2023-07-23 22:47:13 +00:00
ec8fd7e2a7 Add badge to README (#2)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #2
2023-07-20 19:42:59 +00:00
45226e18ce Woodpecker pipelines (#1)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful
Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #1
2023-07-20 18:58:32 +00:00
22 changed files with 266 additions and 241 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake

View File

@@ -71,7 +71,7 @@ jobs:
# ] # ]
# } # }
alejandra: format:
{ {
"name": "Nix formatting", "name": "Nix formatting",
"runs-on": "ubuntu-latest", "runs-on": "ubuntu-latest",
@@ -86,8 +86,8 @@ jobs:
"with": { "extra_nix_config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" } "with": { "extra_nix_config": "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" }
}, },
{ {
"name": "Run Alejandra", "name": "Run nixpkgs-fmt",
"run": "nix develop .#ci --command alejandra -- --check ." "run": "nix develop .#ci --command nixpkgs-fmt -- --check ."
} }
] ]
} }

2
.gitignore vendored
View File

@@ -4,3 +4,5 @@ target/
.vscode/ .vscode/
.profile* .profile*
.DS_Store .DS_Store
.direnv/
result

View File

@@ -1,10 +1,10 @@
pipeline: steps:
nix: echo:
image: alpine image: alpine
commands: commands:
- echo "All required checks complete" - echo "All required checks complete"
depends_on: depends_on:
- run
- build - build
- ci-specific
skip_clone: true

22
.woodpecker/build.yaml Normal file
View File

@@ -0,0 +1,22 @@
steps:
build:
image: nixos/nix
commands:
- echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf
# Run through Nix
- nix build
- nix run
- nix flake check
# Lint
- nix develop --command cargo -- fmt --all -- --check
- nix develop --command cargo -- clippy -- -D warnings -W clippy::must_use_candidate
- nix develop .#ci --command nixpkgs-fmt --check .
- nix develop .#ci --command markdown-link-check README.md
# Test
- nix develop --command cargo test --verbose --release
- nix develop --command cargo test --verbose
when:
- event: "push"
evaluate: 'CI_COMMIT_BRANCH == CI_REPO_DEFAULT_BRANCH'
- event: "pull_request"

View File

@@ -1,11 +0,0 @@
pipeline:
build:
image: nixos/nix
commands:
- nix develop --command cargo test --verbose --release
- nix develop --command cargo test --verbose
lint:
image: nixos/nix
commands:
- nix develop --command cargo -- fmt --all -- --check
- nix develop --command cargo -- clippy -- -D warnings -W clippy::must_use_candidate

View File

@@ -1,7 +0,0 @@
pipeline:
alejandra:
image: nixos/nix
commands:
- nix develop .#ci --command alejandra -- --check .
- nix develop .#ci --command markdown-link-check README.md

View File

@@ -1,6 +0,0 @@
pipeline:
nix:
image: nixos/nix
commands:
- nix build
- nix run

124
Cargo.lock generated
View File

@@ -1,18 +1,18 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 4
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.7.2" version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.1.0" version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
[[package]] [[package]]
name = "bitvec" name = "bitvec"
@@ -28,15 +28,15 @@ dependencies = [
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
[[package]] [[package]]
name = "csv" name = "csv"
version = "1.2.2" version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "626ae34994d3d8d668f4269922248239db4ae42d538b14c398b74a52208e8086" checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf"
dependencies = [ dependencies = [
"csv-core", "csv-core",
"itoa", "itoa",
@@ -46,9 +46,9 @@ dependencies = [
[[package]] [[package]]
name = "csv-core" name = "csv-core"
version = "0.1.10" version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" checksum = "7d02f3b0da4c6504f86e9cd789d8dbafab48c2321be74e9987593de5a894d93d"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
@@ -61,9 +61,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.9" version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
@@ -83,15 +83,15 @@ dependencies = [
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.6" version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.142" version = "0.2.175"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
[[package]] [[package]]
name = "little_learner" name = "little_learner"
@@ -115,24 +115,24 @@ dependencies = [
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.5.0" version = "2.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0"
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.15" version = "0.2.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
[[package]] [[package]]
name = "ordered-float" name = "ordered-float"
version = "3.6.0" version = "3.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13a384337e997e6860ffbaa83708b2ef329fd8c54cb67a5f64d421e0f943254f" checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc"
dependencies = [ dependencies = [
"num-traits", "num-traits",
] ]
@@ -155,29 +155,32 @@ checksum = "9cd6706dfe50d53e0f6aa09e12c034c44faacd23e966ae5a209e8bdb8f179f98"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 1.0.109",
] ]
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.17" version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
"zerocopy",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.56" version = "1.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.26" version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@@ -220,15 +223,29 @@ dependencies = [
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.13" version = "1.0.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.164" version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.219"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.106",
]
[[package]] [[package]]
name = "syn" name = "syn"
@@ -241,6 +258,17 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "syn"
version = "2.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]] [[package]]
name = "tap" name = "tap"
version = "1.0.1" version = "1.0.1"
@@ -249,15 +277,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.8" version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]] [[package]]
name = "wyz" name = "wyz"
@@ -267,3 +295,23 @@ checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
dependencies = [ dependencies = [
"tap", "tap",
] ]
[[package]]
name = "zerocopy"
version = "0.8.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.106",
]

View File

@@ -3,3 +3,11 @@ members = [
"little_learner", "little_learner",
"little_learner_app" "little_learner_app"
] ]
resolver = "3"
[workspace.package]
version = "0.1.0"
edition = "2024"
[workspace.metadata.crane]
name = "little_learner"

View File

@@ -1,5 +1,6 @@
# The Little Learner, in Rust # The Little Learner, in Rust
[![Rust](https://github.com/Smaug123/little_learner/actions/workflows/rust.yml/badge.svg)](https://github.com/Smaug123/little_learner/actions/workflows/rust.yml) [![Rust](https://github.com/Smaug123/little_learner/actions/workflows/rust.yml/badge.svg)](https://github.com/Smaug123/little_learner/actions/workflows/rust.yml)
[![CI](https://woodpecker.patrickstevens.co.uk/api/badges/patrick/little_learner/status.svg)](https://woodpecker.patrickstevens.co.uk/api/badges/patrick/little_learner/status.svg)
Me running through [The Little Learner](https://www.thelittlelearner.com/), but in Rust instead of Scheme. Me running through [The Little Learner](https://www.thelittlelearner.com/), but in Rust instead of Scheme.

98
flake.lock generated
View File

@@ -1,44 +1,30 @@
{ {
"nodes": { "nodes": {
"crate2nix": { "crane": {
"flake": false,
"locked": { "locked": {
"lastModified": 1678820090, "lastModified": 1757183466,
"narHash": "sha256-4FFeonajXNqiSP0PqUlC1wmTyPC8SX6SthEvgRjMupw=", "narHash": "sha256-kTdCCMuRE+/HNHES5JYsbRHmgtr+l9mOtf5dpcMppVc=",
"owner": "kolloch", "owner": "ipetkov",
"repo": "crate2nix", "repo": "crane",
"rev": "4fd826e37bec90dfe26ca16cb6e632c617cc7c0d", "rev": "d599ae4847e7f87603e7082d73ca673aa93c916d",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "kolloch", "owner": "ipetkov",
"repo": "crate2nix", "repo": "crane",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1731533236,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -49,11 +35,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1679705136, "lastModified": 1757068644,
"narHash": "sha256-MDlZUR7wJ3PlPtqwwoGQr3euNOe0vdSSteVVOef7tBY=", "narHash": "sha256-NOrUtIhTkIIumj1E/Rsv1J37Yi3xGStISEo8tZm3KW4=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "8f40f2f90b9c9032d1b824442cfbbe0dbabd0dbd", "rev": "8eb28adfa3dc4de28e792e3bf49fcf9007ca8ac9",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -63,42 +49,26 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_2": {
"locked": {
"lastModified": 1679734080,
"narHash": "sha256-z846xfGLlon6t9lqUzlNtBOmsgQLQIZvR6Lt2dImk1M=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "dbf5322e93bcc6cfc52268367a8ad21c09d76fea",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"crate2nix": "crate2nix", "crane": "crane",
"flake-compat": "flake-compat", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay", "rust-overlay": "rust-overlay"
"utils": "utils"
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "nixpkgs": [
"nixpkgs": "nixpkgs_2" "nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1679106165, "lastModified": 1757298987,
"narHash": "sha256-03Opt2yu4E/AIFjvlgib0/nhMn6B4B/t/nvwS2bzOGw=", "narHash": "sha256-yuFSw6fpfjPtVMmym51ozHYpJQ7SzVOTkk7tUv2JA0U=",
"owner": "oxalica", "owner": "oxalica",
"repo": "rust-overlay", "repo": "rust-overlay",
"rev": "7313c06ac334d6262ddfe30a38b3abc3da6bd565", "rev": "cfd63776bde44438ff2936f0c9194c79dd407a5f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -107,18 +77,18 @@
"type": "github" "type": "github"
} }
}, },
"utils": { "systems": {
"locked": { "locked": {
"lastModified": 1678901627, "lastModified": 1681028828,
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "numtide", "owner": "nix-systems",
"repo": "flake-utils", "repo": "default",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "nix-systems",
"repo": "flake-utils", "repo": "default",
"type": "github" "type": "github"
} }
} }

180
flake.nix
View File

@@ -3,109 +3,111 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay = {
crate2nix = { url = "github:oxalica/rust-overlay";
url = "github:kolloch/crate2nix"; inputs.nixpkgs.follows = "nixpkgs";
flake = false;
}; };
flake-compat = { crane = {
url = "github:edolstra/flake-compat"; url = "github:ipetkov/crane";
flake = false;
}; };
}; };
outputs = { outputs = { self, nixpkgs, flake-utils, rust-overlay, crane }:
self, flake-utils.lib.eachDefaultSystem (system:
nixpkgs, let
utils,
rust-overlay,
crate2nix,
...
}: let
name = "little_learner_app";
in
utils.lib.eachDefaultSystem
(
system: let
# Imports
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ overlays = [ (import rust-overlay) ];
rust-overlay.overlays.default };
(self: super: {
# Because rust-overlay bundles multiple rust packages into one rustToolchain = pkgs.rust-bin.nightly.latest.default;
# derivation, specify that mega-bundle here, so that crate2nix
# will use them automatically. craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
rustc = self.rust-bin.nightly.latest.default;
cargo = self.rust-bin.nightly.latest.default; # Common build inputs for all derivations
}) commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = ./.;
name = "source";
filter = path: type: (builtins.match ".*csv$" path != null || craneLib.filterCargoSources path type);
};
strictDeps = true;
buildInputs = with pkgs; [
openssl
];
nativeBuildInputs = with pkgs; [
pkg-config
]; ];
}; };
inherit
(import "${crate2nix}/tools.nix" {inherit pkgs;})
generatedCargoNix
;
# Create the cargo2nix project # Build just the cargo dependencies
project = cargoArtifacts = craneLib.buildDepsOnly commonArgs;
pkgs.callPackage
(generatedCargoNix { # Build the actual package
inherit name; little_learner_app = craneLib.buildPackage (commonArgs // {
src = ./.; inherit cargoArtifacts;
}) });
{ in
# Individual crate overrides go here {
# Example: https://github.com/balsoft/simple-osd-daemons/blob/6f85144934c0c1382c7a4d3a2bbb80106776e270/flake.nix#L28-L50 packages = {
defaultCrateOverrides = default = little_learner_app;
pkgs.defaultCrateOverrides little_learner_app = little_learner_app;
// { };
# The app crate itself is overriden here. Typically we
# configure non-Rust dependencies (see below) here. apps.default = flake-utils.lib.mkApp {
${name} = oldAttrs: drv = little_learner_app;
{ exePath = "/bin/little_learner_app";
inherit buildInputs nativeBuildInputs; };
}
// buildEnvVars; devShells = {
}; default = craneLib.devShell {
# Inherit the build inputs from commonArgs
buildInputs = commonArgs.buildInputs;
nativeBuildInputs = commonArgs.nativeBuildInputs;
# Additional dev tools
packages = [
rustToolchain
pkgs.rust-analyzer
];
RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
}; };
# Configuration for the non-Rust dependencies ci = pkgs.mkShell {
buildInputs = with pkgs; [openssl.dev]; buildInputs = commonArgs.buildInputs ++ [
nativeBuildInputs = with pkgs; [rustc cargo pkgconfig]; pkgs.nodePackages.markdown-link-check
buildEnvVars = { pkgs.nixpkgs-fmt
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig"; rustToolchain
}; ];
in rec {
packages.${name} = project.workspaceMembers.${name}.build;
# `nix build` nativeBuildInputs = commonArgs.nativeBuildInputs;
defaultPackage = packages.${name};
# `nix run` RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
apps.${name} = utils.lib.mkApp { };
inherit name;
drv = packages.${name};
}; };
defaultApp = apps.${name};
# `nix develop` checks = {
devShells = { inherit little_learner_app;
ci =
pkgs.mkShell { # Run cargo fmt check
inherit nativeBuildInputs; fmt = craneLib.cargoFmt {
buildInputs = [pkgs.nodePackages.markdown-link-check pkgs.alejandra] ++ buildInputs; inherit (commonArgs) src;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; };
}
// buildEnvVars; # Run clippy
default = clippy = craneLib.cargoClippy (commonArgs // {
pkgs.mkShell inherit cargoArtifacts;
{ cargoClippyExtraArgs = "--all-targets -- --deny warnings";
inherit buildInputs nativeBuildInputs; });
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
} # Run tests
// buildEnvVars; tests = craneLib.cargoTest (commonArgs // {
inherit cargoArtifacts;
});
}; };
} });
);
} }

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "little_learner" name = "little_learner"
version = "0.1.0" version.workspace = true
edition = "2021" edition.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -727,10 +727,10 @@ impl<A, Tag, const RANK: usize> RankedDifferentiableTagged<A, Tag, RANK> {
} }
} }
pub fn map2_tagged<'a, 'b, B, C, Tag2, Tag3, F>( pub fn map2_tagged<'a, B, C, Tag2, Tag3, F>(
self: &'a RankedDifferentiableTagged<A, Tag, RANK>, self: &'a RankedDifferentiableTagged<A, Tag, RANK>,
other: &'a RankedDifferentiableTagged<B, Tag2, RANK>, other: &'a RankedDifferentiableTagged<B, Tag2, RANK>,
f: &'b mut F, f: &mut F,
) -> RankedDifferentiableTagged<C, Tag3, RANK> ) -> RankedDifferentiableTagged<C, Tag3, RANK>
where where
F: FnMut(&Scalar<A>, Tag, &Scalar<B>, Tag2) -> (Scalar<C>, Tag3), F: FnMut(&Scalar<A>, Tag, &Scalar<B>, Tag2) -> (Scalar<C>, Tag3),
@@ -843,8 +843,7 @@ where
F: FnMut( F: FnMut(
&[DifferentiableTagged<A, Tag>; PARAM_RANK], &[DifferentiableTagged<A, Tag>; PARAM_RANK],
) -> RankedDifferentiableTagged<A, Tag, RANK>, ) -> RankedDifferentiableTagged<A, Tag, RANK>,
A: ?Sized A: Clone
+ Clone
+ Hash + Hash
+ AddAssign + AddAssign
+ Add<Output = A> + Add<Output = A>

View File

@@ -32,6 +32,7 @@ where
} }
#[must_use] #[must_use]
#[expect(clippy::type_complexity)]
pub fn dense<'b, A, Tag>( pub fn dense<'b, A, Tag>(
input_len: usize, input_len: usize,
neuron_count: usize, neuron_count: usize,

View File

@@ -7,11 +7,7 @@ pub(crate) fn rectify<A>(x: A) -> A
where where
A: Zero + PartialOrd, A: Zero + PartialOrd,
{ {
if x < A::zero() { if x < A::zero() { A::zero() } else { x }
A::zero()
} else {
x
}
} }
fn linear<A, Tag1, Tag2>( fn linear<A, Tag1, Tag2>(

View File

@@ -1,4 +1,4 @@
use crate::auto_diff::{grad, Differentiable, RankedDifferentiable}; use crate::auto_diff::{Differentiable, RankedDifferentiable, grad};
use crate::hyper; use crate::hyper;
use crate::loss::l2_loss_2; use crate::loss::l2_loss_2;
use crate::predictor::Predictor; use crate::predictor::Predictor;
@@ -139,8 +139,8 @@ mod tests {
use crate::scalar::Scalar; use crate::scalar::Scalar;
use crate::traits::Zero; use crate::traits::Zero;
use ordered_float::NotNan; use ordered_float::NotNan;
use rand::rngs::StdRng;
use rand::SeedableRng; use rand::SeedableRng;
use rand::rngs::StdRng;
#[test] #[test]
fn test_iterate() { fn test_iterate() {

View File

@@ -1,6 +1,5 @@
#![allow(incomplete_features)] #![allow(incomplete_features)]
#![feature(generic_const_exprs)] #![feature(generic_const_exprs)]
#![feature(array_methods)]
#![feature(closure_lifetime_binder)] #![feature(closure_lifetime_binder)]
pub mod auto_diff; pub mod auto_diff;

View File

@@ -2,7 +2,7 @@ use crate::traits::{Exp, One, Sqrt, Zero};
use core::hash::Hash; use core::hash::Hash;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::{ use std::{
collections::{hash_map::Entry, HashMap}, collections::{HashMap, hash_map::Entry},
fmt::Display, fmt::Display,
iter::Sum, iter::Sum,
ops::{Add, AddAssign, Div, Mul, Neg, Sub}, ops::{Add, AddAssign, Div, Mul, Neg, Sub},
@@ -356,7 +356,7 @@ where
#[cfg(test)] #[cfg(test)]
mod test_loss { mod test_loss {
use crate::auto_diff::{grad, Differentiable, RankedDifferentiable}; use crate::auto_diff::{Differentiable, RankedDifferentiable, grad};
use crate::scalar::Scalar; use crate::scalar::Scalar;
use crate::traits::Sqrt; use crate::traits::Sqrt;
use ordered_float::NotNan; use ordered_float::NotNan;

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "little_learner_app" name = "little_learner_app"
version = "0.1.0" version.workspace = true
edition = "2021" edition.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -92,7 +92,7 @@ impl<A> Iris<A> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::iris::{import, Iris, IrisType}; use crate::iris::{Iris, IrisType, import};
const EXPECTED_FIRST: Iris<f32> = Iris { const EXPECTED_FIRST: Iris<f32> = Iris {
class: IrisType::Setosa, class: IrisType::Setosa,