diff options
-rw-r--r-- | .envrc | 1 | ||||
-rw-r--r-- | .gitignore | 5 | ||||
-rw-r--r-- | 01/Cargo.toml | 11 | ||||
-rw-r--r-- | 01/input | 200 | ||||
-rw-r--r-- | 01/src/main.rs | 68 | ||||
-rw-r--r-- | 01/tests/main.rs | 17 | ||||
-rw-r--r-- | Cargo.lock | 576 | ||||
-rw-r--r-- | Cargo.nix | 2008 | ||||
-rw-r--r-- | Cargo.toml | 5 | ||||
-rw-r--r-- | LICENSE.md | 21 | ||||
-rw-r--r-- | default.nix | 14 | ||||
-rw-r--r-- | lib/Cargo.toml | 11 | ||||
-rw-r--r-- | lib/src/error.rs | 52 | ||||
-rw-r--r-- | lib/src/lib.rs | 86 | ||||
-rw-r--r-- | lib/src/prelude.rs | 4 | ||||
-rw-r--r-- | rust-nightly.nix | 106 | ||||
-rw-r--r-- | shell.nix | 37 |
17 files changed, 3222 insertions, 0 deletions
diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..be81fed --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +eval "$(lorri direnv)" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..31158d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/target +/result +/result-* +**/*.rs.bk +*.swp diff --git a/01/Cargo.toml b/01/Cargo.toml new file mode 100644 index 0000000..4534ef6 --- /dev/null +++ b/01/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "advent_01" +version = "0.1.0" +authors = ["Irene Knapp <ireneista@gmail.com>"] +edition = "2018" + +[dependencies] +advent_lib = { path = "../lib" } + +[dev-dependencies] +assert_cmd = "0.10" diff --git a/01/input b/01/input new file mode 100644 index 0000000..0cf9a7b --- /dev/null +++ b/01/input @@ -0,0 +1,200 @@ +1130 +1897 +1850 +1218 +1198 +1761 +1082 +1742 +1821 +1464 +1834 +1413 +1917 +1746 +1954 +1942 +1560 +1227 +1852 +1976 +1773 +1404 +1824 +1011 +1532 +1306 +1819 +1739 +1540 +1973 +1436 +1196 +1176 +1856 +1332 +1617 +1895 +1749 +1718 +1536 +1811 +113 +1008 +1908 +1799 +1914 +1603 +1782 +1980 +1228 +1838 +2006 +1953 +1846 +1903 +1470 +1774 +1599 +1446 +1324 +1054 +1952 +1928 +1997 +1764 +1943 +1932 +1615 +1428 +1036 +721 +1097 +1998 +1033 +1892 +1904 +1803 +1825 +1370 +1836 +1853 +1963 +1469 +1385 +246 +1987 +1153 +178 +1790 +1927 +1139 +1865 +1804 +1974 +1235 +1681 +1185 +2009 +1894 +1141 +1203 +1808 +1867 +1274 +1891 +1779 +1342 +1920 +851 +1994 +1975 +1979 +1880 +1647 +1365 +448 +1119 +1256 +1212 +1268 +1878 +1805 +1889 +1870 +1906 +1959 +1898 +1305 +1559 +1088 +1845 +1783 +1841 +1864 +1961 +1267 +1437 +1823 +801 +1579 +1538 +1745 +1972 +1259 +1899 +1517 +1940 +1543 +1882 +1933 +1240 +1608 +1263 +1429 +1197 +1508 +1631 +1988 +1350 +1638 +1800 +1999 +1822 +1776 +1896 +1610 +1831 +1921 +1535 +1526 +1491 +1876 +1476 +1945 +1702 +1900 +1814 +1289 +1992 +1859 +1967 +1966 +1283 +2002 +1195 +1066 +1924 +1968 +1835 +1971 +1977 +1430 +1844 +1465 +1595 +1957 +1472 +219 +1851 +1955 diff --git a/01/src/main.rs b/01/src/main.rs new file mode 100644 index 0000000..b7cdbbf --- /dev/null +++ b/01/src/main.rs @@ -0,0 +1,68 @@ +use advent_lib::prelude::*; + +use std::collections::BTreeSet; + + +fn main() -> Result<()> { + let mut args = std::env::args(); + if args.len() != 2 { + eprintln!("Usage: advent input"); + } + let _ = args.next(); + let filename = args.next().unwrap(); + + let mut input = advent_lib::read_int_file(&filename)?; + + input.sort(); + + let mut input_set = BTreeSet::new(); + for item in &input { + input_set.insert(item); + } + + for i in 0 .. input.len() { + let a = input[i]; + if a > 2020 { + break; + } + + let b = 2020 - a; + if input_set.contains(&b) { + let product = a * b; + println!("a: {:?}, b: {:?}, a*b: {:?}", a, b, product); + break; + } + } + + let mut done = false; + for i in 0 .. input.len() { + if done { + break; + } + + let a = input[i]; + if a > 2020 { + break; + } + + for j in i+1 .. input.len() { + let b = input[j]; + + if a + b > 2020 { + break; + } + + let c = 2020 - a - b; + if input_set.contains(&c) { + let product = a * b * c; + println!("a: {:?}, b: {:?}, c: {:?}, a*b*c: {:?}", a, b, c, product); + + done = true; + break; + } + } + } + + Ok(()) +} + diff --git a/01/tests/main.rs b/01/tests/main.rs new file mode 100644 index 0000000..b3d3cec --- /dev/null +++ b/01/tests/main.rs @@ -0,0 +1,17 @@ +use assert_cmd::prelude::*; +//use predicates::prelude::*; +use std::process::Command; + + +#[test] +fn personal_input() -> Result<(), Box<dyn std::error::Error>> { + let mut command = Command::cargo_bin("advent_01")?; + + command.arg("input"); + command.assert().success().stdout( + "a: 246, b: 1774, a*b: 436404\n\ + a: 448, b: 721, c: 851, a*b*c: 274879808\n"); + + Ok(()) +} + diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..adab73f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,576 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "advent_01" +version = "0.1.0" +dependencies = [ + "advent_lib", + "assert_cmd", +] + +[[package]] +name = "advent_lib" +version = "0.1.0" +dependencies = [ + "lalrpop", + "lalrpop-util", +] + +[[package]] +name = "aho-corasick" +version = "0.7.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +dependencies = [ + "memchr", +] + +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + +[[package]] +name = "assert_cmd" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7ac5c260f75e4e4ba87b7342be6edcecbcb3eb6741a0507fda7ad115845cc65" +dependencies = [ + "escargot", + "predicates", + "predicates-core", + "predicates-tree", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bit-set" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "diff" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" + +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "ena" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" +dependencies = [ + "log", +] + +[[package]] +name = "escargot" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19db1f7e74438642a5018cdf263bb1325b2e792f02dd0a3ca6d6c0f0d7b1d5a5" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "fixedbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "lalrpop" +version = "0.19.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15174f1c529af5bf1283c3bc0058266b483a67156f79589fab2a25e23cf8988" +dependencies = [ + "ascii-canvas", + "atty", + "bit-set", + "diff", + "ena", + "itertools", + "lalrpop-util", + "petgraph", + "pico-args", + "regex", + "regex-syntax", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "lalrpop-util" +version = "0.19.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e58cce361efcc90ba8a0a5f982c741ff86b603495bb15a998412e957dcd278" +dependencies = [ + "regex", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119" + +[[package]] +name = "lock_api" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "phf_shared" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c00cf8b9eafe68dde5e9eaa2cef8ee84a9336a47d566ec55ca16589633b65af7" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pico-args" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "predicates" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f49cfaf7fdaa3bfacc6fa3e7054e65148878354a5cfddcf661df4c851f8021df" +dependencies = [ + "difference", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" + +[[package]] +name = "predicates-tree" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "proc-macro2" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +dependencies = [ + "getrandom", + "redox_syscall", +] + +[[package]] +name = "regex" +version = "1.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "rustversion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" + +[[package]] +name = "ryu" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.130" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "siphasher" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" + +[[package]] +name = "smallvec" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" + +[[package]] +name = "string_cache" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "923f0f39b6267d37d23ce71ae7235602134b250ace715dd2c90421998ddac0c6" +dependencies = [ + "lazy_static", + "new_debug_unreachable", + "parking_lot", + "phf_shared", + "precomputed-hash", +] + +[[package]] +name = "syn" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "termtree" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16" + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.nix b/Cargo.nix new file mode 100644 index 0000000..35f5a3c --- /dev/null +++ b/Cargo.nix @@ -0,0 +1,2008 @@ + +# This file was @generated by crate2nix 0.8.0 with the command: +# "generate" +# See https://github.com/kolloch/crate2nix for more info. + +{ nixpkgs ? <nixpkgs> +, pkgs ? import nixpkgs { config = {}; } +, lib ? pkgs.lib +, stdenv ? pkgs.stdenv +, buildRustCrate ? pkgs.buildRustCrate + # This is used as the `crateOverrides` argument for `buildRustCrate`. +, defaultCrateOverrides ? pkgs.defaultCrateOverrides + # The features to enable for the root_crate or the workspace_members. +, rootFeatures ? [ "default" ] + # If true, throw errors instead of issueing deprecation warnings. +, strictDeprecation ? false + # Whether to perform release builds: longer compile times, faster binaries. +, release ? true +}: + +rec { + # + # "public" attributes that we attempt to keep stable with new versions of crate2nix. + # + + + # Refer your crate build derivation by name here. + # You can override the features with + # workspaceMembers."${crateName}".build.override { features = [ "default" "feature1" ... ]; }. + workspaceMembers = { + "advent_01" = rec { + packageId = "advent_01"; + build = internal.buildRustCrateWithFeatures { + packageId = "advent_01"; + }; + + # Debug support which might change between releases. + # File a bug if you depend on any for non-debug work! + debug = internal.debugCrate { inherit packageId; }; + }; + "advent_lib" = rec { + packageId = "advent_lib"; + build = internal.buildRustCrateWithFeatures { + packageId = "advent_lib"; + }; + + # Debug support which might change between releases. + # File a bug if you depend on any for non-debug work! + debug = internal.debugCrate { inherit packageId; }; + }; + }; + workspace_members = + internal.deprecationWarning + "workspace_members is deprecated in crate2nix 0.4. Please use workspaceMembers instead." + lib.mapAttrs (n: v: v.build) workspaceMembers; + + # + # "internal" ("private") attributes that may change in every new version of crate2nix. + # + + internal = rec { + # Build and dependency information for crates. + # Many of the fields are passed one-to-one to buildRustCrate. + # + # Noteworthy: + # * `dependencies`/`buildDependencies`: similar to the corresponding fields for buildRustCrate. + # but with additional information which is used during dependency/feature resolution. + # * `resolvedDependencies`: the selected default features reported by cargo - only included for debugging. + # * `devDependencies` as of now not used by `buildRustCrate` but used to + # inject test dependencies into the build + + crates = { + "advent_01" = rec { + crateName = "advent_01"; + version = "0.1.0"; + edition = "2018"; + crateBin = [ + { name = "advent_01"; path = "src/main.rs"; } + ]; + src = (builtins.filterSource sourceFilter ./01); + authors = [ + "Irene Knapp <ireneista@gmail.com>" + ]; + dependencies = [ + { + name = "advent_lib"; + packageId = "advent_lib"; + } + ]; + devDependencies = [ + { + name = "assert_cmd"; + packageId = "assert_cmd"; + } + ]; + + }; + "advent_lib" = rec { + crateName = "advent_lib"; + version = "0.1.0"; + edition = "2018"; + src = (builtins.filterSource sourceFilter ./lib); + authors = [ + "Irene Knapp <ireneista@gmail.com>" + ]; + dependencies = [ + { + name = "lalrpop-util"; + packageId = "lalrpop-util"; + } + ]; + buildDependencies = [ + { + name = "lalrpop"; + packageId = "lalrpop"; + features = [ "lexer" ]; + } + ]; + + }; + "aho-corasick" = rec { + crateName = "aho-corasick"; + version = "0.7.18"; + edition = "2018"; + sha256 = "0vv50b3nvkhyy7x7ip19qnsq11bqlnffkmj2yx2xlyk5wzawydqy"; + libName = "aho_corasick"; + authors = [ + "Andrew Gallant <jamslam@gmail.com>" + ]; + dependencies = [ + { + name = "memchr"; + packageId = "memchr"; + usesDefaultFeatures = false; + } + ]; + features = { + "default" = [ "std" ]; + "std" = [ "memchr/std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; + "ascii-canvas" = rec { + crateName = "ascii-canvas"; + version = "3.0.0"; + edition = "2018"; + sha256 = "1in38ziqn4kh9sw89ys4naaqzvvjscfs0m4djqbfq7455v5fq948"; + authors = [ + "Niko Matsakis <niko@alum.mit.edu>" + ]; + dependencies = [ + { + name = "term"; + packageId = "term"; + } + ]; + + }; + "assert_cmd" = rec { + crateName = "assert_cmd"; + version = "0.10.2"; + edition = "2015"; + crateBin = []; + sha256 = "0rfc8mc13bd7zl3ha6klnqzcpjyfxpk2nd5phyxf9r3m1wk5rb5p"; + authors = [ + "Pascal Hertleif <killercup@gmail.com>" + "Ed Page <eopage@gmail.com>" + ]; + dependencies = [ + { + name = "escargot"; + packageId = "escargot"; + } + { + name = "predicates"; + packageId = "predicates"; + usesDefaultFeatures = false; + features = [ "difference" ]; + } + { + name = "predicates-core"; + packageId = "predicates-core"; + } + { + name = "predicates-tree"; + packageId = "predicates-tree"; + } + ]; + + }; + "atty" = rec { + crateName = "atty"; + version = "0.2.14"; + edition = "2015"; + sha256 = "1s7yslcs6a28c5vz7jwj63lkfgyx8mx99fdirlhi9lbhhzhrpcyr"; + authors = [ + "softprops <d.tangren@gmail.com>" + ]; + dependencies = [ + { + name = "hermit-abi"; + packageId = "hermit-abi"; + target = { target, features }: (target."os" == "hermit"); + } + { + name = "libc"; + packageId = "libc"; + usesDefaultFeatures = false; + target = { target, features }: target."unix"; + } + { + name = "winapi"; + packageId = "winapi"; + target = { target, features }: target."windows"; + features = [ "consoleapi" "processenv" "minwinbase" "minwindef" "winbase" ]; + } + ]; + + }; + "autocfg" = rec { + crateName = "autocfg"; + version = "1.0.1"; + edition = "2015"; + sha256 = "0jj6i9zn4gjl03kjvziqdji6rwx8ykz8zk2ngpc331z2g3fk3c6d"; + authors = [ + "Josh Stone <cuviper@gmail.com>" + ]; + + }; + "bit-set" = rec { + crateName = "bit-set"; + version = "0.5.2"; + edition = "2015"; + sha256 = "1pjrmpsnad5ipwjsv8ppi0qrhqvgpyn3wfbvk7jy8dga6mhf24bf"; + authors = [ + "Alexis Beingessner <a.beingessner@gmail.com>" + ]; + dependencies = [ + { + name = "bit-vec"; + packageId = "bit-vec"; + usesDefaultFeatures = false; + } + ]; + features = { + "default" = [ "std" ]; + "std" = [ "bit-vec/std" ]; + }; + }; + "bit-vec" = rec { + crateName = "bit-vec"; + version = "0.6.3"; + edition = "2015"; + sha256 = "1ywqjnv60cdh1slhz67psnp422md6jdliji6alq0gmly2xm9p7rl"; + authors = [ + "Alexis Beingessner <a.beingessner@gmail.com>" + ]; + features = { + "default" = [ "std" ]; + "serde_no_std" = [ "serde/alloc" ]; + "serde_std" = [ "std" "serde/std" ]; + }; + }; + "bitflags" = rec { + crateName = "bitflags"; + version = "1.3.2"; + edition = "2018"; + sha256 = "12ki6w8gn1ldq7yz9y680llwk5gmrhrzszaa17g1sbrw2r2qvwxy"; + authors = [ + "The Rust Project Developers" + ]; + features = { + "rustc-dep-of-std" = [ "core" "compiler_builtins" ]; + }; + resolvedDefaultFeatures = [ "default" ]; + }; + "cfg-if" = rec { + crateName = "cfg-if"; + version = "1.0.0"; + edition = "2018"; + sha256 = "1za0vb97n4brpzpv8lsbnzmq5r8f2b0cpqqr0sy8h5bn751xxwds"; + authors = [ + "Alex Crichton <alex@alexcrichton.com>" + ]; + features = { + "rustc-dep-of-std" = [ "core" "compiler_builtins" ]; + }; + }; + "crunchy" = rec { + crateName = "crunchy"; + version = "0.2.2"; + edition = "2015"; + sha256 = "1dx9mypwd5mpfbbajm78xcrg5lirqk7934ik980mmaffg3hdm0bs"; + authors = [ + "Vurich <jackefransham@hotmail.co.uk>" + ]; + features = { + "default" = [ "limit_128" ]; + }; + resolvedDefaultFeatures = [ "default" "limit_128" ]; + }; + "diff" = rec { + crateName = "diff"; + version = "0.1.12"; + edition = "2015"; + sha256 = "16b40bhsa2qgvgvxs983l625pkxyp6m0mzmpwg2605cvj53yl98f"; + authors = [ + "Utkarsh Kukreti <utkarshkukreti@gmail.com>" + ]; + + }; + "difference" = rec { + crateName = "difference"; + version = "2.0.0"; + edition = "2015"; + crateBin = []; + sha256 = "1621wx4k8h452p6xzmzzvm7mz87kxh4yqz0kzxfjj9xmjxlbyk2j"; + authors = [ + "Johann Hofmann <mail@johann-hofmann.com>" + ]; + features = { + "bin" = [ "getopts" ]; + }; + resolvedDefaultFeatures = [ "default" ]; + }; + "dirs-next" = rec { + crateName = "dirs-next"; + version = "2.0.0"; + edition = "2018"; + sha256 = "1q9kr151h9681wwp6is18750ssghz6j9j7qm7qi1ngcwy7mzi35r"; + authors = [ + "The @xdg-rs members" + ]; + dependencies = [ + { + name = "cfg-if"; + packageId = "cfg-if"; + } + { + name = "dirs-sys-next"; + packageId = "dirs-sys-next"; + } + ]; + + }; + "dirs-sys-next" = rec { + crateName = "dirs-sys-next"; + version = "0.1.2"; + edition = "2018"; + sha256 = "0kavhavdxv4phzj4l0psvh55hszwnr0rcz8sxbvx20pyqi2a3gaf"; + authors = [ + "The @xdg-rs members" + ]; + dependencies = [ + { + name = "libc"; + packageId = "libc"; + target = { target, features }: target."unix"; + } + { + name = "redox_users"; + packageId = "redox_users"; + usesDefaultFeatures = false; + target = { target, features }: (target."os" == "redox"); + } + { + name = "winapi"; + packageId = "winapi"; + target = { target, features }: target."windows"; + features = [ "knownfolders" "objbase" "shlobj" "winbase" "winerror" ]; + } + ]; + + }; + "either" = rec { + crateName = "either"; + version = "1.6.1"; + edition = "2015"; + sha256 = "0mwl9vngqf5jvrhmhn9x60kr5hivxyjxbmby2pybncxfqhf4z3g7"; + authors = [ + "bluss" + ]; + features = { + "default" = [ "use_std" ]; + }; + }; + "ena" = rec { + crateName = "ena"; + version = "0.14.0"; + edition = "2015"; + sha256 = "1hrnkx2swbczn0jzpscxxipx7jcxhg6sf9vk911ff91wm6a2nh6p"; + authors = [ + "Niko Matsakis <niko@alum.mit.edu>" + ]; + dependencies = [ + { + name = "log"; + packageId = "log"; + } + ]; + features = { + "congruence-closure" = [ "petgraph" ]; + "persistent" = [ "dogged" ]; + }; + }; + "escargot" = rec { + crateName = "escargot"; + version = "0.3.1"; + edition = "2015"; + crateBin = []; + sha256 = "19fmn7bz1h6nlqy0mp825xwjwnrjn4xjdpwc06jl51j3fiz1znqr"; + authors = [ + "Ed Page <eopage@gmail.com>" + ]; + dependencies = [ + { + name = "serde"; + packageId = "serde"; + features = [ "derive" ]; + } + { + name = "serde_json"; + packageId = "serde_json"; + } + ]; + + }; + "fixedbitset" = rec { + crateName = "fixedbitset"; + version = "0.2.0"; + edition = "2015"; + sha256 = "0kg03p777wc0dajd9pvlcnsyrwa8dhqwf0sd9r4dw0p82rs39arp"; + authors = [ + "bluss" + ]; + features = { + "default" = [ "std" ]; + }; + }; + "getrandom" = rec { + crateName = "getrandom"; + version = "0.2.3"; + edition = "2018"; + sha256 = "0lr7mnkvnzdh1xxmwmhhbm4gwg29k3m2rzhpjmjm4k2jcfa9kkbz"; + authors = [ + "The Rand Project Developers" + ]; + dependencies = [ + { + name = "cfg-if"; + packageId = "cfg-if"; + } + { + name = "libc"; + packageId = "libc"; + usesDefaultFeatures = false; + target = { target, features }: target."unix"; + } + { + name = "wasi"; + packageId = "wasi"; + target = { target, features }: (target."os" == "wasi"); + } + ]; + features = { + "js" = [ "wasm-bindgen" "js-sys" ]; + "rustc-dep-of-std" = [ "compiler_builtins" "core" "libc/rustc-dep-of-std" "wasi/rustc-dep-of-std" ]; + }; + resolvedDefaultFeatures = [ "std" ]; + }; + "hashbrown" = rec { + crateName = "hashbrown"; + version = "0.11.2"; + edition = "2018"; + sha256 = "0vkjsf5nzs7qcia5ya79j9sq2p1caz4crrncr1675wwyj3ag0pmb"; + authors = [ + "Amanieu d'Antras <amanieu@gmail.com>" + ]; + features = { + "ahash-compile-time-rng" = [ "ahash/compile-time-rng" ]; + "default" = [ "ahash" "inline-more" ]; + "rustc-dep-of-std" = [ "nightly" "core" "compiler_builtins" "alloc" "rustc-internal-api" ]; + }; + resolvedDefaultFeatures = [ "raw" ]; + }; + "hermit-abi" = rec { + crateName = "hermit-abi"; + version = "0.1.19"; + edition = "2018"; + sha256 = "0cxcm8093nf5fyn114w8vxbrbcyvv91d4015rdnlgfll7cs6gd32"; + authors = [ + "Stefan Lankes" + ]; + dependencies = [ + { + name = "libc"; + packageId = "libc"; + usesDefaultFeatures = false; + } + ]; + features = { + "rustc-dep-of-std" = [ "core" "compiler_builtins/rustc-dep-of-std" "libc/rustc-dep-of-std" ]; + }; + resolvedDefaultFeatures = [ "default" ]; + }; + "indexmap" = rec { + crateName = "indexmap"; + version = "1.7.0"; + edition = "2018"; + sha256 = "19b2zwfajhsfcgny0clv8y4jppy704znfhv8nv2dw9a18l2kcqxw"; + authors = [ + "bluss" + "Josh Stone <cuviper@gmail.com>" + ]; + dependencies = [ + { + name = "hashbrown"; + packageId = "hashbrown"; + usesDefaultFeatures = false; + features = [ "raw" ]; + } + ]; + buildDependencies = [ + { + name = "autocfg"; + packageId = "autocfg"; + } + ]; + features = { + "serde-1" = [ "serde" ]; + }; + }; + "instant" = rec { + crateName = "instant"; + version = "0.1.12"; + edition = "2018"; + sha256 = "0b2bx5qdlwayriidhrag8vhy10kdfimfhmb3jnjmsz2h9j1bwnvs"; + authors = [ + "sebcrozet <developer@crozet.re>" + ]; + dependencies = [ + { + name = "cfg-if"; + packageId = "cfg-if"; + } + ]; + features = { + "wasm-bindgen" = [ "js-sys" "wasm-bindgen_rs" "web-sys" ]; + }; + }; + "itertools" = rec { + crateName = "itertools"; + version = "0.10.1"; + edition = "2018"; + sha256 = "1bsyxnm20x05rwc5qskrqy4cfswrcadzlwc26dkqml6hz64vipb9"; + authors = [ + "bluss" + ]; + dependencies = [ + { + name = "either"; + packageId = "either"; + usesDefaultFeatures = false; + } + ]; + features = { + "default" = [ "use_std" ]; + "use_std" = [ "use_alloc" ]; + }; + resolvedDefaultFeatures = [ "use_alloc" "use_std" ]; + }; + "itoa" = rec { + crateName = "itoa"; + version = "0.4.8"; + edition = "2015"; + sha256 = "1m1dairwyx8kfxi7ab3b5jc71z1vigh9w4shnhiajji9avzr26dp"; + authors = [ + "David Tolnay <dtolnay@gmail.com>" + ]; + features = { + "default" = [ "std" ]; + }; + }; + "lalrpop" = rec { + crateName = "lalrpop"; + version = "0.19.6"; + edition = "2015"; + crateBin = []; + sha256 = "1249rwimx8mjza4rbxsnf6k87d36h82w0frw53qmpbr9qpqp8ldi"; + authors = [ + "Niko Matsakis <niko@alum.mit.edu>" + ]; + dependencies = [ + { + name = "ascii-canvas"; + packageId = "ascii-canvas"; + usesDefaultFeatures = false; + } + { + name = "atty"; + packageId = "atty"; + usesDefaultFeatures = false; + } + { + name = "bit-set"; + packageId = "bit-set"; + usesDefaultFeatures = false; + } + { + name = "diff"; + packageId = "diff"; + usesDefaultFeatures = false; + } + { + name = "ena"; + packageId = "ena"; + usesDefaultFeatures = false; + } + { + name = "itertools"; + packageId = "itertools"; + usesDefaultFeatures = false; + features = [ "use_std" ]; + } + { + name = "lalrpop-util"; + packageId = "lalrpop-util"; + } + { + name = "petgraph"; + packageId = "petgraph"; + usesDefaultFeatures = false; + } + { + name = "pico-args"; + packageId = "pico-args"; + optional = true; + usesDefaultFeatures = false; + } + { + name = "regex"; + packageId = "regex"; + usesDefaultFeatures = false; + features = [ "std" ]; + } + { + name = "regex-syntax"; + packageId = "regex-syntax"; + usesDefaultFeatures = false; + } + { + name = "string_cache"; + packageId = "string_cache"; + usesDefaultFeatures = false; + } + { + name = "term"; + packageId = "term"; + usesDefaultFeatures = false; + } + { + name = "tiny-keccak"; + packageId = "tiny-keccak"; + features = [ "sha3" ]; + } + { + name = "unicode-xid"; + packageId = "unicode-xid"; + usesDefaultFeatures = false; + } + ]; + features = { + "default" = [ "lexer" "pico-args" ]; + "lexer" = [ "lalrpop-util/lexer" ]; + }; + resolvedDefaultFeatures = [ "default" "lexer" "pico-args" ]; + }; + "lalrpop-util" = rec { + crateName = "lalrpop-util"; + version = "0.19.6"; + edition = "2018"; + sha256 = "0y6jvibyj4l4k5db2ns90fv8dzs1qy1gk9d0m05wkz0y6v78rrfk"; + authors = [ + "Niko Matsakis <niko@alum.mit.edu>" + ]; + dependencies = [ + { + name = "regex"; + packageId = "regex"; + optional = true; + } + ]; + features = { + "default" = [ "std" ]; + "lexer" = [ "regex" ]; + }; + resolvedDefaultFeatures = [ "default" "lexer" "regex" "std" ]; + }; + "lazy_static" = rec { + crateName = "lazy_static"; + version = "1.4.0"; + edition = "2015"; + sha256 = "0in6ikhw8mgl33wjv6q6xfrb5b9jr16q8ygjy803fay4zcisvaz2"; + authors = [ + "Marvin Löbel <loebel.marvin@gmail.com>" + ]; + features = { + "spin_no_std" = [ "spin" ]; + }; + }; + "libc" = rec { + crateName = "libc"; + version = "0.2.108"; + edition = "2015"; + sha256 = "06finl0p44lvqyw7s0qgc7bgmdz771gfg6bmmxlyrcbngsss28c5"; + authors = [ + "The Rust Project Developers" + ]; + features = { + "default" = [ "std" ]; + "rustc-dep-of-std" = [ "align" "rustc-std-workspace-core" ]; + "use_std" = [ "std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; + "lock_api" = rec { + crateName = "lock_api"; + version = "0.4.5"; + edition = "2018"; + sha256 = "028izfyraynijd9h9x5miv1vmg6sjnw1v95wgm7f4xlr7h4lsaki"; + authors = [ + "Amanieu d'Antras <amanieu@gmail.com>" + ]; + dependencies = [ + { + name = "scopeguard"; + packageId = "scopeguard"; + usesDefaultFeatures = false; + } + ]; + features = { + }; + }; + "log" = rec { + crateName = "log"; + version = "0.4.14"; + edition = "2015"; + sha256 = "04175hv0v62shd82qydq58a48k3bjijmk54v38zgqlbxqkkbpfai"; + authors = [ + "The Rust Project Developers" + ]; + dependencies = [ + { + name = "cfg-if"; + packageId = "cfg-if"; + } + ]; + features = { + "kv_unstable" = [ "value-bag" ]; + "kv_unstable_serde" = [ "kv_unstable_std" "value-bag/serde" "serde" ]; + "kv_unstable_std" = [ "std" "kv_unstable" "value-bag/error" ]; + "kv_unstable_sval" = [ "kv_unstable" "value-bag/sval" "sval" ]; + }; + }; + "memchr" = rec { + crateName = "memchr"; + version = "2.4.1"; + edition = "2018"; + sha256 = "0smq8xzd40njqpfzv5mghigj91fzlfrfg842iz8x0wqvw2dw731h"; + authors = [ + "Andrew Gallant <jamslam@gmail.com>" + "bluss" + ]; + features = { + "default" = [ "std" ]; + "rustc-dep-of-std" = [ "core" "compiler_builtins" ]; + "use_std" = [ "std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; + "new_debug_unreachable" = rec { + crateName = "new_debug_unreachable"; + version = "1.0.4"; + edition = "2018"; + sha256 = "0m1bg3wz3nvxdryg78x4i8hh9fys4wp2bi0zg821dhvf44v4g8p4"; + libName = "debug_unreachable"; + authors = [ + "Matt Brubeck <mbrubeck@limpet.net>" + "Jonathan Reem <jonathan.reem@gmail.com>" + ]; + + }; + "parking_lot" = rec { + crateName = "parking_lot"; + version = "0.11.2"; + edition = "2018"; + sha256 = "16gzf41bxmm10x82bla8d6wfppy9ym3fxsmdjyvn61m66s0bf5vx"; + authors = [ + "Amanieu d'Antras <amanieu@gmail.com>" + ]; + dependencies = [ + { + name = "instant"; + packageId = "instant"; + } + { + name = "lock_api"; + packageId = "lock_api"; + } + { + name = "parking_lot_core"; + packageId = "parking_lot_core"; + } + ]; + features = { + "arc_lock" = [ "lock_api/arc_lock" ]; + "deadlock_detection" = [ "parking_lot_core/deadlock_detection" ]; + "nightly" = [ "parking_lot_core/nightly" "lock_api/nightly" ]; + "owning_ref" = [ "lock_api/owning_ref" ]; + "serde" = [ "lock_api/serde" ]; + "stdweb" = [ "instant/stdweb" ]; + "wasm-bindgen" = [ "instant/wasm-bindgen" ]; + }; + resolvedDefaultFeatures = [ "default" ]; + }; + "parking_lot_core" = rec { + crateName = "parking_lot_core"; + version = "0.8.5"; + edition = "2018"; + sha256 = "05ij4zxsylx99srbq8qd1k2wiwaq8krkf9y4cqkhvb5wjca8wvnp"; + authors = [ + "Amanieu d'Antras <amanieu@gmail.com>" + ]; + dependencies = [ + { + name = "cfg-if"; + packageId = "cfg-if"; + } + { + name = "instant"; + packageId = "instant"; + } + { + name = "libc"; + packageId = "libc"; + target = { target, features }: target."unix"; + } + { + name = "redox_syscall"; + packageId = "redox_syscall"; + target = { target, features }: (target."os" == "redox"); + } + { + name = "smallvec"; + packageId = "smallvec"; + } + { + name = "winapi"; + packageId = "winapi"; + target = { target, features }: target."windows"; + features = [ "winnt" "ntstatus" "minwindef" "winerror" "winbase" "errhandlingapi" "handleapi" ]; + } + ]; + features = { + "deadlock_detection" = [ "petgraph" "thread-id" "backtrace" ]; + }; + }; + "petgraph" = rec { + crateName = "petgraph"; + version = "0.5.1"; + edition = "2018"; + sha256 = "1dzxda6z17sfxly11m8ja3iargh73pw0s1sdgjyp0qp5dm51cza6"; + authors = [ + "bluss" + "mitchmindtree" + ]; + dependencies = [ + { + name = "fixedbitset"; + packageId = "fixedbitset"; + usesDefaultFeatures = false; + } + { + name = "indexmap"; + packageId = "indexmap"; + } + ]; + features = { + "all" = [ "unstable" "quickcheck" "matrix_graph" "stable_graph" "graphmap" ]; + "default" = [ "graphmap" "stable_graph" "matrix_graph" ]; + "serde-1" = [ "serde" "serde_derive" ]; + "unstable" = [ "generate" ]; + }; + }; + "phf_shared" = rec { + crateName = "phf_shared"; + version = "0.8.0"; + edition = "2018"; + sha256 = "1xssnqrrcn0nr9ayqrnm8xm37ac4xvwcx8pax7jxss7yxawzh360"; + authors = [ + "Steven Fackler <sfackler@gmail.com>" + ]; + dependencies = [ + { + name = "siphasher"; + packageId = "siphasher"; + } + ]; + features = { + "default" = [ "std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; + "pico-args" = rec { + crateName = "pico-args"; + version = "0.4.2"; + edition = "2018"; + sha256 = "0s646i0pbcck300rqldb21m151zxp66m3mdskha063blrfbcv2yv"; + authors = [ + "Evgeniy Reizner <razrfalcon@gmail.com>" + ]; + features = { + "default" = [ "eq-separator" ]; + }; + }; + "precomputed-hash" = rec { + crateName = "precomputed-hash"; + version = "0.1.1"; + edition = "2015"; + sha256 = "075k9bfy39jhs53cb2fpb9klfakx2glxnf28zdw08ws6lgpq6lwj"; + authors = [ + "Emilio Cobos Álvarez <emilio@crisal.io>" + ]; + + }; + "predicates" = rec { + crateName = "predicates"; + version = "1.0.8"; + edition = "2018"; + sha256 = "1pr1h0gqak6zc7vdrzaw98spi20lcm70brx3dz6glfxazpvzm77l"; + authors = [ + "Nick Stevens <nick@bitcurry.com>" + ]; + dependencies = [ + { + name = "difference"; + packageId = "difference"; + optional = true; + } + { + name = "predicates-core"; + packageId = "predicates-core"; + } + ]; + features = { + "default" = [ "difference" "regex" "float-cmp" "normalize-line-endings" ]; + }; + resolvedDefaultFeatures = [ "difference" ]; + }; + "predicates-core" = rec { + crateName = "predicates-core"; + version = "1.0.2"; + edition = "2018"; + sha256 = "0l947jviipblyaqsp3p5mvsqq421bg0nxp7mhnm4jpmp4qrmmqsp"; + authors = [ + "Nick Stevens <nick@bitcurry.com>" + ]; + + }; + "predicates-tree" = rec { + crateName = "predicates-tree"; + version = "1.0.4"; + edition = "2018"; + sha256 = "1xsx8j9x2s2dgmn1hnshaa7zv52y5c1l0bsak3ijlwsvj3i7p31k"; + authors = [ + "Nick Stevens <nick@bitcurry.com>" + ]; + dependencies = [ + { + name = "predicates-core"; + packageId = "predicates-core"; + } + { + name = "termtree"; + packageId = "termtree"; + } + ]; + + }; + "proc-macro2" = rec { + crateName = "proc-macro2"; + version = "1.0.32"; + edition = "2018"; + sha256 = "0hqbxlvhiaybakl1gai3mgps1dxsmxricxsr2rfdrh222z0qql5s"; + authors = [ + "David Tolnay <dtolnay@gmail.com>" + "Alex Crichton <alex@alexcrichton.com>" + ]; + dependencies = [ + { + name = "unicode-xid"; + packageId = "unicode-xid"; + } + ]; + features = { + "default" = [ "proc-macro" ]; + }; + resolvedDefaultFeatures = [ "default" "proc-macro" ]; + }; + "quote" = rec { + crateName = "quote"; + version = "1.0.10"; + edition = "2018"; + sha256 = "01ff7a76f871ggnby57iagw6499vci4bihcr11g6bqzjlp38rg1q"; + authors = [ + "David Tolnay <dtolnay@gmail.com>" + ]; + dependencies = [ + { + name = "proc-macro2"; + packageId = "proc-macro2"; + usesDefaultFeatures = false; + } + ]; + features = { + "default" = [ "proc-macro" ]; + "proc-macro" = [ "proc-macro2/proc-macro" ]; + }; + resolvedDefaultFeatures = [ "default" "proc-macro" ]; + }; + "redox_syscall" = rec { + crateName = "redox_syscall"; + version = "0.2.10"; + edition = "2018"; + sha256 = "1zq36bhw4c6xig340ja1jmr36iy0d3djp8smsabxx71676bg70w3"; + libName = "syscall"; + authors = [ + "Jeremy Soller <jackpot51@gmail.com>" + ]; + dependencies = [ + { + name = "bitflags"; + packageId = "bitflags"; + } + ]; + + }; + "redox_users" = rec { + crateName = "redox_users"; + version = "0.4.0"; + edition = "2018"; + sha256 = "0r5y1a26flkn6gkayi558jg5dzh2m2fdsapgkpn7mj01v3rk51aj"; + authors = [ + "Jose Narvaez <goyox86@gmail.com>" + "Wesley Hershberger <mggmugginsmc@gmail.com>" + ]; + dependencies = [ + { + name = "getrandom"; + packageId = "getrandom"; + features = [ "std" ]; + } + { + name = "redox_syscall"; + packageId = "redox_syscall"; + } + ]; + features = { + "auth" = [ "rust-argon2" ]; + "default" = [ "auth" ]; + }; + }; + "regex" = rec { + crateName = "regex"; + version = "1.5.4"; + edition = "2018"; + sha256 = "0qf479kjbmb582h4d1d6gfl75h0j8aq2nrdi5wg6zdcy6llqcynh"; + authors = [ + "The Rust Project Developers" + ]; + dependencies = [ + { + name = "aho-corasick"; + packageId = "aho-corasick"; + optional = true; + } + { + name = "memchr"; + packageId = "memchr"; + optional = true; + } + { + name = "regex-syntax"; + packageId = "regex-syntax"; + usesDefaultFeatures = false; + } + ]; + features = { + "default" = [ "std" "perf" "unicode" "regex-syntax/default" ]; + "perf" = [ "perf-cache" "perf-dfa" "perf-inline" "perf-literal" ]; + "perf-literal" = [ "aho-corasick" "memchr" ]; + "unicode" = [ "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" "regex-syntax/unicode" ]; + "unicode-age" = [ "regex-syntax/unicode-age" ]; + "unicode-bool" = [ "regex-syntax/unicode-bool" ]; + "unicode-case" = [ "regex-syntax/unicode-case" ]; + "unicode-gencat" = [ "regex-syntax/unicode-gencat" ]; + "unicode-perl" = [ "regex-syntax/unicode-perl" ]; + "unicode-script" = [ "regex-syntax/unicode-script" ]; + "unicode-segment" = [ "regex-syntax/unicode-segment" ]; + "unstable" = [ "pattern" ]; + "use_std" = [ "std" ]; + }; + resolvedDefaultFeatures = [ "aho-corasick" "default" "memchr" "perf" "perf-cache" "perf-dfa" "perf-inline" "perf-literal" "std" "unicode" "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" ]; + }; + "regex-syntax" = rec { + crateName = "regex-syntax"; + version = "0.6.25"; + edition = "2018"; + sha256 = "16y87hz1bxmmz6kk360cxwfm3jnbsxb3x4zw9x1gzz7khic2i5zl"; + authors = [ + "The Rust Project Developers" + ]; + features = { + "default" = [ "unicode" ]; + "unicode" = [ "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" ]; + }; + resolvedDefaultFeatures = [ "default" "unicode" "unicode-age" "unicode-bool" "unicode-case" "unicode-gencat" "unicode-perl" "unicode-script" "unicode-segment" ]; + }; + "rustversion" = rec { + crateName = "rustversion"; + version = "1.0.5"; + edition = "2018"; + sha256 = "1250m7ymrhp3c5xfmliskmknhf23r7x3cirxy9wmrdwbfnfr1cv1"; + procMacro = true; + build = "build/build.rs"; + authors = [ + "David Tolnay <dtolnay@gmail.com>" + ]; + + }; + "ryu" = rec { + crateName = "ryu"; + version = "1.0.6"; + edition = "2018"; + sha256 = "0s35bwagycbzwmbj0fngm4jljnan272cz12i84kbmfbalssi75iw"; + authors = [ + "David Tolnay <dtolnay@gmail.com>" + ]; + features = { + }; + }; + "scopeguard" = rec { + crateName = "scopeguard"; + version = "1.1.0"; + edition = "2015"; + sha256 = "1kbqm85v43rq92vx7hfiay6pmcga03vrjbbfwqpyj3pwsg3b16nj"; + authors = [ + "bluss" + ]; + features = { + "default" = [ "use_std" ]; + }; + }; + "serde" = rec { + crateName = "serde"; + version = "1.0.130"; + edition = "2015"; + sha256 = "04y9s1mxcxakg9bhfdiff9w4zzprk6m6dazcpmpi8nfg6zg0cbgi"; + authors = [ + "Erick Tryzelaar <erick.tryzelaar@gmail.com>" + "David Tolnay <dtolnay@gmail.com>" + ]; + dependencies = [ + { + name = "serde_derive"; + packageId = "serde_derive"; + optional = true; + } + ]; + devDependencies = [ + { + name = "serde_derive"; + packageId = "serde_derive"; + } + ]; + features = { + "default" = [ "std" ]; + "derive" = [ "serde_derive" ]; + }; + resolvedDefaultFeatures = [ "default" "derive" "serde_derive" "std" ]; + }; + "serde_derive" = rec { + crateName = "serde_derive"; + version = "1.0.130"; + edition = "2015"; + sha256 = "12shxhi47db54i4j44ic2nl299x5p89ngna0w3m6854nn4d1mg6p"; + procMacro = true; + authors = [ + "Erick Tryzelaar <erick.tryzelaar@gmail.com>" + "David Tolnay <dtolnay@gmail.com>" + ]; + dependencies = [ + { + name = "proc-macro2"; + packageId = "proc-macro2"; + } + { + name = "quote"; + packageId = "quote"; + } + { + name = "syn"; + packageId = "syn"; + } + ]; + features = { + }; + resolvedDefaultFeatures = [ "default" ]; + }; + "serde_json" = rec { + crateName = "serde_json"; + version = "1.0.72"; + edition = "2018"; + sha256 = "09xmy9iycl8r8bkrgbbxbwbjwj5dii3bbhk812wnzyidgy1s1zyh"; + authors = [ + "Erick Tryzelaar <erick.tryzelaar@gmail.com>" + "David Tolnay <dtolnay@gmail.com>" + ]; + dependencies = [ + { + name = "itoa"; + packageId = "itoa"; + usesDefaultFeatures = false; + } + { + name = "ryu"; + packageId = "ryu"; + } + { + name = "serde"; + packageId = "serde"; + usesDefaultFeatures = false; + } + ]; + features = { + "alloc" = [ "serde/alloc" ]; + "default" = [ "std" ]; + "preserve_order" = [ "indexmap" ]; + "std" = [ "serde/std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; + "siphasher" = rec { + crateName = "siphasher"; + version = "0.3.7"; + edition = "2018"; + sha256 = "12wkdsvxq8ljckpsh92ri52w8z0gh32cclxb4lvd695pz6l98d2k"; + authors = [ + "Frank Denis <github@pureftpd.org>" + ]; + features = { + "default" = [ "std" ]; + "serde_no_std" = [ "serde/alloc" ]; + "serde_std" = [ "std" "serde/std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; + "smallvec" = rec { + crateName = "smallvec"; + version = "1.7.0"; + edition = "2018"; + sha256 = "02gka690j8l12gl50ifg7axqnx1m6v6d1byaq0wl3fx66p3vdjhy"; + authors = [ + "The Servo Project Developers" + ]; + features = { + "const_new" = [ "const_generics" ]; + }; + }; + "string_cache" = rec { + crateName = "string_cache"; + version = "0.8.2"; + edition = "2018"; + sha256 = "1in0va6rj884r795swff18jln4q2aqiyf6p77k93fz96nqwhygwj"; + authors = [ + "The Servo Project Developers" + ]; + dependencies = [ + { + name = "lazy_static"; + packageId = "lazy_static"; + } + { + name = "new_debug_unreachable"; + packageId = "new_debug_unreachable"; + } + { + name = "parking_lot"; + packageId = "parking_lot"; + } + { + name = "phf_shared"; + packageId = "phf_shared"; + } + { + name = "precomputed-hash"; + packageId = "precomputed-hash"; + } + ]; + features = { + "default" = [ "serde_support" ]; + "serde_support" = [ "serde" ]; + }; + }; + "syn" = rec { + crateName = "syn"; + version = "1.0.82"; + edition = "2018"; + sha256 = "0ncx7gg5mvd16q5xf77hgk09nwmfq0ppsn0vgc9x9jv0pg85vbwd"; + authors = [ + "David Tolnay <dtolnay@gmail.com>" + ]; + dependencies = [ + { + name = "proc-macro2"; + packageId = "proc-macro2"; + usesDefaultFeatures = false; + } + { + name = "quote"; + packageId = "quote"; + optional = true; + usesDefaultFeatures = false; + } + { + name = "unicode-xid"; + packageId = "unicode-xid"; + } + ]; + features = { + "default" = [ "derive" "parsing" "printing" "clone-impls" "proc-macro" ]; + "printing" = [ "quote" ]; + "proc-macro" = [ "proc-macro2/proc-macro" "quote/proc-macro" ]; + "test" = [ "syn-test-suite/all-features" ]; + }; + resolvedDefaultFeatures = [ "clone-impls" "default" "derive" "parsing" "printing" "proc-macro" "quote" ]; + }; + "term" = rec { + crateName = "term"; + version = "0.7.0"; + edition = "2018"; + sha256 = "07xzxmg7dbhlirpyfq09v7cfb9gxn0077sqqvszgjvyrjnngi7f5"; + authors = [ + "The Rust Project Developers" + "Steven Allen" + ]; + dependencies = [ + { + name = "dirs-next"; + packageId = "dirs-next"; + } + { + name = "rustversion"; + packageId = "rustversion"; + target = { target, features }: target."windows"; + } + { + name = "winapi"; + packageId = "winapi"; + target = { target, features }: target."windows"; + features = [ "consoleapi" "wincon" "handleapi" "fileapi" ]; + } + ]; + features = { + }; + resolvedDefaultFeatures = [ "default" ]; + }; + "termtree" = rec { + crateName = "termtree"; + version = "0.2.3"; + edition = "2018"; + sha256 = "05jchbaqqy88zac8fwrp4yqqkxv7v7xcq1278dbrpr9d18cfr90k"; + + }; + "tiny-keccak" = rec { + crateName = "tiny-keccak"; + version = "2.0.2"; + edition = "2018"; + sha256 = "0dq2x0hjffmixgyf6xv9wgsbcxkd65ld0wrfqmagji8a829kg79c"; + authors = [ + "debris <marek.kotewicz@gmail.com>" + ]; + dependencies = [ + { + name = "crunchy"; + packageId = "crunchy"; + } + ]; + features = { + "fips202" = [ "keccak" "shake" "sha3" ]; + "kmac" = [ "cshake" ]; + "parallel_hash" = [ "cshake" ]; + "sp800" = [ "cshake" "kmac" "tuple_hash" ]; + "tuple_hash" = [ "cshake" ]; + }; + resolvedDefaultFeatures = [ "default" "sha3" ]; + }; + "unicode-xid" = rec { + crateName = "unicode-xid"; + version = "0.2.2"; + edition = "2015"; + sha256 = "1wrkgcw557v311dkdb6n2hrix9dm2qdsb1zpw7pn79l03zb85jwc"; + authors = [ + "erick.tryzelaar <erick.tryzelaar@gmail.com>" + "kwantam <kwantam@gmail.com>" + "Manish Goregaokar <manishsmail@gmail.com>" + ]; + features = { + }; + resolvedDefaultFeatures = [ "default" ]; + }; + "wasi" = rec { + crateName = "wasi"; + version = "0.10.2+wasi-snapshot-preview1"; + edition = "2018"; + sha256 = "1ii7nff4y1mpcrxzzvbpgxm7a1nn3szjf1n21jnx37c2g6dbsvzx"; + authors = [ + "The Cranelift Project Developers" + ]; + features = { + "default" = [ "std" ]; + "rustc-dep-of-std" = [ "compiler_builtins" "core" "rustc-std-workspace-alloc" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; + "winapi" = rec { + crateName = "winapi"; + version = "0.3.9"; + edition = "2015"; + sha256 = "06gl025x418lchw1wxj64ycr7gha83m44cjr5sarhynd9xkrm0sw"; + authors = [ + "Peter Atashian <retep998@gmail.com>" + ]; + dependencies = [ + { + name = "winapi-i686-pc-windows-gnu"; + packageId = "winapi-i686-pc-windows-gnu"; + target = { target, features }: (stdenv.hostPlatform.config == "i686-pc-windows-gnu"); + } + { + name = "winapi-x86_64-pc-windows-gnu"; + packageId = "winapi-x86_64-pc-windows-gnu"; + target = { target, features }: (stdenv.hostPlatform.config == "x86_64-pc-windows-gnu"); + } + ]; + features = { + "debug" = [ "impl-debug" ]; + }; + resolvedDefaultFeatures = [ "consoleapi" "errhandlingapi" "fileapi" "handleapi" "knownfolders" "minwinbase" "minwindef" "ntstatus" "objbase" "processenv" "shlobj" "winbase" "wincon" "winerror" "winnt" ]; + }; + "winapi-i686-pc-windows-gnu" = rec { + crateName = "winapi-i686-pc-windows-gnu"; + version = "0.4.0"; + edition = "2015"; + sha256 = "1dmpa6mvcvzz16zg6d5vrfy4bxgg541wxrcip7cnshi06v38ffxc"; + authors = [ + "Peter Atashian <retep998@gmail.com>" + ]; + + }; + "winapi-x86_64-pc-windows-gnu" = rec { + crateName = "winapi-x86_64-pc-windows-gnu"; + version = "0.4.0"; + edition = "2015"; + sha256 = "0gqq64czqb64kskjryj8isp62m2sgvx25yyj3kpc2myh85w24bki"; + authors = [ + "Peter Atashian <retep998@gmail.com>" + ]; + + }; + }; + + # +# crate2nix/default.nix (excerpt start) +# + + /* Target (platform) data for conditional dependencies. + This corresponds roughly to what buildRustCrate is setting. + */ + defaultTarget = { + unix = true; + windows = false; + fuchsia = true; + test = false; + + # This doesn't appear to be officially documented anywhere yet. + # See https://github.com/rust-lang-nursery/rust-forge/issues/101. + os = if stdenv.hostPlatform.isDarwin + then "macos" + else stdenv.hostPlatform.parsed.kernel.name; + arch = stdenv.hostPlatform.parsed.cpu.name; + family = "unix"; + env = "gnu"; + endian = + if stdenv.hostPlatform.parsed.cpu.significantByte.name == "littleEndian" + then "little" else "big"; + pointer_width = toString stdenv.hostPlatform.parsed.cpu.bits; + vendor = stdenv.hostPlatform.parsed.vendor.name; + debug_assertions = false; + }; + + /* Filters common temp files and build files. */ + # TODO(pkolloch): Substitute with gitignore filter + sourceFilter = name: type: + let + baseName = builtins.baseNameOf (builtins.toString name); + in + ! ( + # Filter out git + baseName == ".gitignore" + || (type == "directory" && baseName == ".git") + + # Filter out build results + || ( + type == "directory" && ( + baseName == "target" + || baseName == "_site" + || baseName == ".sass-cache" + || baseName == ".jekyll-metadata" + || baseName == "build-artifacts" + ) + ) + + # Filter out nix-build result symlinks + || ( + type == "symlink" && lib.hasPrefix "result" baseName + ) + + # Filter out IDE config + || ( + type == "directory" && ( + baseName == ".idea" || baseName == ".vscode" + ) + ) || lib.hasSuffix ".iml" baseName + + # Filter out nix build files + || baseName == "Cargo.nix" + + # Filter out editor backup / swap files. + || lib.hasSuffix "~" baseName + || builtins.match "^\\.sw[a-z]$$" baseName != null + || builtins.match "^\\..*\\.sw[a-z]$$" baseName != null + || lib.hasSuffix ".tmp" baseName + || lib.hasSuffix ".bak" baseName + || baseName == "tests.nix" + ); + + /* Returns a crate which depends on successful test execution + of crate given as the second argument. + + testCrateFlags: list of flags to pass to the test exectuable + testInputs: list of packages that should be available during test execution + */ + crateWithTest = { crate, testCrate, testCrateFlags, testInputs }: + assert builtins.typeOf testCrateFlags == "list"; + assert builtins.typeOf testInputs == "list"; + let + # override the `crate` so that it will build and execute tests instead of + # building the actual lib and bin targets We just have to pass `--test` + # to rustc and it will do the right thing. We execute the tests and copy + # their log and the test executables to $out for later inspection. + test = let + drv = testCrate.override ( + _: { + buildTests = true; + } + ); + in + pkgs.runCommand "run-tests-${testCrate.name}" { + inherit testCrateFlags; + buildInputs = testInputs; + } '' + set -ex + cd ${crate.src} + for file in ${drv}/tests/*; do + $file $testCrateFlags 2>&1 | tee -a $out + done + ''; + in + crate.overrideAttrs ( + old: { + checkPhase = '' + test -e ${test} + ''; + passthru = (old.passthru or {}) // { + inherit test; + }; + } + ); + + /* A restricted overridable version of builtRustCratesWithFeatures. */ + buildRustCrateWithFeatures = + { packageId + , features ? rootFeatures + , crateOverrides ? defaultCrateOverrides + , buildRustCrateFunc ? ( + if crateOverrides == pkgs.defaultCrateOverrides + then buildRustCrate + else buildRustCrate.override { + defaultCrateOverrides = crateOverrides; + } + ) + , runTests ? false + , testCrateFlags ? [] + , testInputs ? [] + }: + lib.makeOverridable + ( + { features, crateOverrides, runTests, testCrateFlags, testInputs }: + let + builtRustCrates = builtRustCratesWithFeatures { + inherit packageId features buildRustCrateFunc; + runTests = false; + }; + builtTestRustCrates = builtRustCratesWithFeatures { + inherit packageId features buildRustCrateFunc; + runTests = true; + }; + drv = builtRustCrates.${packageId}; + testDrv = builtTestRustCrates.${packageId}; + in + if runTests then + crateWithTest { + crate = drv; + testCrate = testDrv; + inherit testCrateFlags testInputs; + } + else drv + ) + { inherit features crateOverrides runTests testCrateFlags testInputs; }; + + /* Returns an attr set with packageId mapped to the result of buildRustCrateFunc + for the corresponding crate. + */ + builtRustCratesWithFeatures = + { packageId + , features + , crateConfigs ? crates + , buildRustCrateFunc + , runTests + , target ? defaultTarget + } @ args: + assert (builtins.isAttrs crateConfigs); + assert (builtins.isString packageId); + assert (builtins.isList features); + assert (builtins.isAttrs target); + assert (builtins.isBool runTests); + let + rootPackageId = packageId; + mergedFeatures = mergePackageFeatures ( + args // { + inherit rootPackageId; + target = target // { test = runTests; }; + } + ); + + buildByPackageId = packageId: buildByPackageIdImpl packageId; + + # Memoize built packages so that reappearing packages are only built once. + builtByPackageId = + lib.mapAttrs (packageId: value: buildByPackageId packageId) crateConfigs; + + buildByPackageIdImpl = packageId: + let + features = mergedFeatures."${packageId}" or []; + crateConfig' = crateConfigs."${packageId}"; + crateConfig = + builtins.removeAttrs crateConfig' [ "resolvedDefaultFeatures" "devDependencies" ]; + devDependencies = + lib.optionals + (runTests && packageId == rootPackageId) + (crateConfig'.devDependencies or []); + dependencies = + dependencyDerivations { + inherit builtByPackageId features target; + dependencies = + (crateConfig.dependencies or []) + ++ devDependencies; + }; + buildDependencies = + dependencyDerivations { + inherit builtByPackageId features target; + dependencies = crateConfig.buildDependencies or []; + }; + + filterEnabledDependenciesForThis = dependencies: filterEnabledDependencies { + inherit dependencies features target; + }; + + dependenciesWithRenames = + lib.filter (d: d ? "rename") ( + filterEnabledDependenciesForThis + ( + (crateConfig.buildDependencies or []) + ++ (crateConfig.dependencies or []) + ++ devDependencies + ) + ); + + crateRenames = + builtins.listToAttrs + (map (d: { name = d.name; value = d.rename; }) dependenciesWithRenames); + in + buildRustCrateFunc ( + crateConfig // { + src = crateConfig.src or ( + pkgs.fetchurl { + name = "${crateConfig.crateName}-${crateConfig.version}.tar.gz"; + url = "https://crates.io/api/v1/crates/${crateConfig.crateName}/${crateConfig.version}/download"; + sha256 = crateConfig.sha256; + } + ); + inherit features dependencies buildDependencies crateRenames release; + } + ); + in + builtByPackageId; + + /* Returns the actual derivations for the given dependencies. */ + dependencyDerivations = + { builtByPackageId + , features + , dependencies + , target + }: + assert (builtins.isAttrs builtByPackageId); + assert (builtins.isList features); + assert (builtins.isList dependencies); + assert (builtins.isAttrs target); + let + enabledDependencies = filterEnabledDependencies { + inherit dependencies features target; + }; + depDerivation = dependency: builtByPackageId.${dependency.packageId}; + in + map depDerivation enabledDependencies; + + /* Returns a sanitized version of val with all values substituted that cannot + be serialized as JSON. + */ + sanitizeForJson = val: + if builtins.isAttrs val + then lib.mapAttrs (n: v: sanitizeForJson v) val + else if builtins.isList val + then builtins.map sanitizeForJson val + else if builtins.isFunction val + then "function" + else val; + + /* Returns various tools to debug a crate. */ + debugCrate = { packageId, target ? defaultTarget }: + assert (builtins.isString packageId); + let + debug = rec { + # The built tree as passed to buildRustCrate. + buildTree = buildRustCrateWithFeatures { + buildRustCrateFunc = lib.id; + inherit packageId; + }; + sanitizedBuildTree = sanitizeForJson buildTree; + dependencyTree = sanitizeForJson ( + buildRustCrateWithFeatures { + buildRustCrateFunc = crate: { + "01_crateName" = crate.crateName or false; + "02_features" = crate.features or []; + "03_dependencies" = crate.dependencies or []; + }; + inherit packageId; + } + ); + mergedPackageFeatures = mergePackageFeatures { + features = rootFeatures; + inherit packageId target; + }; + diffedDefaultPackageFeatures = diffDefaultPackageFeatures { + inherit packageId target; + }; + }; + in + { internal = debug; }; + + /* Returns differences between cargo default features and crate2nix default + features. + + This is useful for verifying the feature resolution in crate2nix. + */ + diffDefaultPackageFeatures = + { crateConfigs ? crates + , packageId + , target + }: + assert (builtins.isAttrs crateConfigs); + let + prefixValues = prefix: lib.mapAttrs (n: v: { "${prefix}" = v; }); + mergedFeatures = + prefixValues + "crate2nix" + (mergePackageFeatures { inherit crateConfigs packageId target; features = [ "default" ]; }); + configs = prefixValues "cargo" crateConfigs; + combined = lib.foldAttrs (a: b: a // b) {} [ mergedFeatures configs ]; + onlyInCargo = + builtins.attrNames + (lib.filterAttrs (n: v: !(v ? "crate2nix") && (v ? "cargo")) combined); + onlyInCrate2Nix = + builtins.attrNames + (lib.filterAttrs (n: v: (v ? "crate2nix") && !(v ? "cargo")) combined); + differentFeatures = lib.filterAttrs + ( + n: v: + (v ? "crate2nix") + && (v ? "cargo") + && (v.crate2nix.features or []) != (v."cargo".resolved_default_features or []) + ) + combined; + in + builtins.toJSON { + inherit onlyInCargo onlyInCrate2Nix differentFeatures; + }; + + /* Returns an attrset mapping packageId to the list of enabled features. + + If multiple paths to a dependency enable different features, the + corresponding feature sets are merged. Features in rust are additive. + */ + mergePackageFeatures = + { crateConfigs ? crates + , packageId + , rootPackageId ? packageId + , features ? rootFeatures + , dependencyPath ? [ crates.${packageId}.crateName ] + , featuresByPackageId ? {} + , target + # Adds devDependencies to the crate with rootPackageId. + , runTests ? false + , ... + } @ args: + assert (builtins.isAttrs crateConfigs); + assert (builtins.isString packageId); + assert (builtins.isString rootPackageId); + assert (builtins.isList features); + assert (builtins.isList dependencyPath); + assert (builtins.isAttrs featuresByPackageId); + assert (builtins.isAttrs target); + assert (builtins.isBool runTests); + let + crateConfig = crateConfigs."${packageId}" or (builtins.throw "Package not found: ${packageId}"); + expandedFeatures = expandFeatures (crateConfig.features or {}) features; + + depWithResolvedFeatures = dependency: + let + packageId = dependency.packageId; + features = dependencyFeatures expandedFeatures dependency; + in + { inherit packageId features; }; + + resolveDependencies = cache: path: dependencies: + assert (builtins.isAttrs cache); + assert (builtins.isList dependencies); + let + enabledDependencies = filterEnabledDependencies { + inherit dependencies target; + features = expandedFeatures; + }; + directDependencies = map depWithResolvedFeatures enabledDependencies; + foldOverCache = op: lib.foldl op cache directDependencies; + in + foldOverCache + ( + cache: { packageId, features }: + let + cacheFeatures = cache.${packageId} or []; + combinedFeatures = sortedUnique (cacheFeatures ++ features); + in + if cache ? ${packageId} && cache.${packageId} == combinedFeatures + then cache + else mergePackageFeatures { + features = combinedFeatures; + featuresByPackageId = cache; + inherit crateConfigs packageId target runTests rootPackageId; + } + ); + + cacheWithSelf = + let + cacheFeatures = featuresByPackageId.${packageId} or []; + combinedFeatures = sortedUnique (cacheFeatures ++ expandedFeatures); + in + featuresByPackageId // { + "${packageId}" = combinedFeatures; + }; + + cacheWithDependencies = + resolveDependencies cacheWithSelf "dep" ( + crateConfig.dependencies or [] + ++ lib.optionals + (runTests && packageId == rootPackageId) + (crateConfig.devDependencies or []) + ); + + cacheWithAll = + resolveDependencies + cacheWithDependencies "build" + (crateConfig.buildDependencies or []); + in + cacheWithAll; + + /* Returns the enabled dependencies given the enabled features. */ + filterEnabledDependencies = { dependencies, features, target }: + assert (builtins.isList dependencies); + assert (builtins.isList features); + assert (builtins.isAttrs target); + + lib.filter + ( + dep: + let + targetFunc = dep.target or (features: true); + in + targetFunc { inherit features target; } + && ( + !(dep.optional or false) + || builtins.any (doesFeatureEnableDependency dep) features + ) + ) + dependencies; + + /* Returns whether the given feature should enable the given dependency. */ + doesFeatureEnableDependency = { name, rename ? null, ... }: feature: + let + prefix = "${name}/"; + len = builtins.stringLength prefix; + startsWithPrefix = builtins.substring 0 len feature == prefix; + in + (rename == null && feature == name) + || (rename != null && rename == feature) + || startsWithPrefix; + + /* Returns the expanded features for the given inputFeatures by applying the + rules in featureMap. + + featureMap is an attribute set which maps feature names to lists of further + feature names to enable in case this feature is selected. + */ + expandFeatures = featureMap: inputFeatures: + assert (builtins.isAttrs featureMap); + assert (builtins.isList inputFeatures); + let + expandFeature = feature: + assert (builtins.isString feature); + [ feature ] ++ (expandFeatures featureMap (featureMap."${feature}" or [])); + outFeatures = builtins.concatMap expandFeature inputFeatures; + in + sortedUnique outFeatures; + + /* + Returns the actual features for the given dependency. + + features: The features of the crate that refers this dependency. + */ + dependencyFeatures = features: dependency: + assert (builtins.isList features); + assert (builtins.isAttrs dependency); + let + defaultOrNil = if dependency.usesDefaultFeatures or true + then [ "default" ] + else []; + explicitFeatures = dependency.features or []; + additionalDependencyFeatures = + let + dependencyPrefix = (dependency.rename or dependency.name) + "/"; + dependencyFeatures = + builtins.filter (f: lib.hasPrefix dependencyPrefix f) features; + in + builtins.map (lib.removePrefix dependencyPrefix) dependencyFeatures; + in + defaultOrNil ++ explicitFeatures ++ additionalDependencyFeatures; + + /* Sorts and removes duplicates from a list of strings. */ + sortedUnique = features: + assert (builtins.isList features); + assert (builtins.all builtins.isString features); + let + outFeaturesSet = lib.foldl (set: feature: set // { "${feature}" = 1; }) {} features; + outFeaturesUnique = builtins.attrNames outFeaturesSet; + in + builtins.sort (a: b: a < b) outFeaturesUnique; + + deprecationWarning = message: value: + if strictDeprecation + then builtins.throw "strictDeprecation enabled, aborting: ${message}" + else builtins.trace message value; + + # + # crate2nix/default.nix (excerpt end) + # + + }; +} diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..2446b10 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "lib", + "01", +] diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..dc7620a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +ANTI-CAPITALIST SOFTWARE LICENSE (v 1.4) + +Copyright © 2020 Irene Knapp + +This is anti-capitalist software, released for free use by individuals and organizations that do not operate by capitalist principles. + +Permission is hereby granted, free of charge, to any person or organization (the "User") obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, distribute, and/or sell copies of the Software, subject to the following conditions: + +1. The above copyright notice and this permission notice shall be included in all copies or modified versions of the Software. + +2. The User is one of the following: +a. An individual person, laboring for themselves +b. A non-profit organization +c. An educational institution +d. An organization that seeks shared profit for all of its members, and allows non-members to set the cost of their labor + +3. If the User is an organization with owners, then all owners are workers and all workers are owners with equal equity and/or equal vote. + +4. If the User is an organization, then the User is not law enforcement or military, or working for or under either. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..2ab3b66 --- /dev/null +++ b/default.nix @@ -0,0 +1,14 @@ +# Use `nix-build`, not `nix build`, when doing development on this file. It +# does a better job of propagating error messages from the build tools upward. + +let pkgs = import <nixpkgs> { }; + crateOverrides = pkgs.defaultCrateOverrides.override { + } // { }; + parameterOverrides = { }; + cargo = pkgs.callPackage ./Cargo.nix { + defaultCrateOverrides = crateOverrides; + }; +in +builtins.mapAttrs + (key: value: value.build.override parameterOverrides) + cargo.workspaceMembers diff --git a/lib/Cargo.toml b/lib/Cargo.toml new file mode 100644 index 0000000..7785a81 --- /dev/null +++ b/lib/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "advent_lib" +version = "0.1.0" +authors = ["Irene Knapp <ireneista@gmail.com>"] +edition = "2018" + +[dependencies] +lalrpop-util = "0.19" + +[build-dependencies] +lalrpop = { version = "0.19", features = [ "lexer" ] } diff --git a/lib/src/error.rs b/lib/src/error.rs new file mode 100644 index 0000000..4f594b7 --- /dev/null +++ b/lib/src/error.rs @@ -0,0 +1,52 @@ +#[derive(Debug)] +pub enum Error { + IO(std::io::Error), + Parse, +} + +impl std::error::Error for Error { } + +impl std::fmt::Display for Error { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Error::IO(e) => e.fmt(f), + Error::Parse => f.write_str("Parse error"), + } + } +} + +impl std::cmp::PartialEq for Error { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Error::IO(_), Error::IO(_)) => + false, + (Error::Parse, Error::Parse) => + true, + _ => + false, + } + } +} + +impl From<std::io::Error> for Error { + fn from(e: std::io::Error) -> Error { + Error::IO(e) + } +} + +impl From<std::num::ParseIntError> for Error { + fn from(_: std::num::ParseIntError) -> Error { + Error::Parse + } +} + +impl From<lalrpop_util::ParseError<usize, lalrpop_util::lexer::Token<'_>, + &str>> for Error +{ + fn from(_: lalrpop_util::ParseError<usize, lalrpop_util::lexer::Token<'_>, + &str>) -> Error + { + Error::Parse + } +} + diff --git a/lib/src/lib.rs b/lib/src/lib.rs new file mode 100644 index 0000000..8798359 --- /dev/null +++ b/lib/src/lib.rs @@ -0,0 +1,86 @@ +pub mod error; +pub mod prelude; + +pub use crate::prelude::Result; + +use std::fs::File; +use std::io::BufReader; +use std::io::prelude::*; + + +pub fn greeting() -> Result<()> { + println!("Hello, Irenes!"); + + Ok(()) +} + +pub fn read_lines_file(filename: &str) -> Result<Vec<String>> { + let file = File::open(filename)?; + let mut reader = BufReader::new(file); + let mut buffer = String::new(); + + let mut input = Vec::new(); + loop { + reader.read_line(&mut buffer)?; + if buffer.len() == 0 { + break; + } + + let mut line_copy = String::new(); + match buffer.strip_suffix("\n") { + Some(stripped) => { + line_copy.push_str(stripped); + } + None => { + line_copy.push_str(&buffer); + } + } + input.push(line_copy); + + buffer.clear(); + } + + Ok(input) +} + +pub fn group_lines_by_blanks(lines: Vec<String>) -> Vec<Vec<String>> { + let mut all_groups = Vec::new(); + let mut current_group = Vec::new(); + + for line in lines { + if line.len() == 0 { + all_groups.push(current_group); + current_group = Vec::new(); + } else { + current_group.push(line); + } + } + + if current_group.len() > 0 { + all_groups.push(current_group); + } + + all_groups +} + +pub fn read_int_file(filename: &str) -> Result<Vec<i64>> { + let file = File::open(filename)?; + let mut reader = BufReader::new(file); + let mut buffer = String::new(); + + let mut input: Vec<i64> = Vec::new(); + loop { + reader.read_line(&mut buffer)?; + if buffer.len() == 0 { + break; + } + + let item = buffer.trim().parse::<i64>()?; + + buffer.clear(); + + input.push(item); + } + + Ok(input) +} diff --git a/lib/src/prelude.rs b/lib/src/prelude.rs new file mode 100644 index 0000000..a4e81eb --- /dev/null +++ b/lib/src/prelude.rs @@ -0,0 +1,4 @@ +use crate::error::Error; + +pub type Result<T> = std::result::Result<T, Error>; + diff --git a/rust-nightly.nix b/rust-nightly.nix new file mode 100644 index 0000000..3f1fbe4 --- /dev/null +++ b/rust-nightly.nix @@ -0,0 +1,106 @@ +{ stdenv, lib, buildEnv, makeWrapper, runCommand, fetchurl, zlib, rsync, curl }: + +# rustc and cargo nightly binaries + +let + convertPlatform = system: + if system == "i686-linux" then "i686-unknown-linux-gnu" + else if system == "x86_64-linux" then "x86_64-unknown-linux-gnu" + else if system == "i686-darwin" then "i686-apple-darwin" + else if system == "x86_64-darwin" then "x86_64-apple-darwin" + else abort "no snapshot to bootstrap for this platform (missing target triple)"; + + thisSys = convertPlatform stdenv.system; + + defaultDateFile = builtins.fetchurl + "https://static.rust-lang.org/dist/channel-rust-nightly-date.txt"; + defaultDate = lib.removeSuffix "\n" (builtins.readFile defaultDateFile); + + mkUrl = { pname, archive, date, system }: + "${archive}/${date}/${pname}-nightly-${system}.tar.gz"; + + fetch = args: let + url = mkUrl { inherit (args) pname archive date system; }; + download = builtins.fetchurl (url + ".sha256"); + contents = builtins.readFile download; + sha256 = args.hash or (lib.head (lib.strings.splitString " " contents)); + in fetchurl { inherit url sha256; }; + + generic = { pname, archive, exes }: + { date ? defaultDate, system ? thisSys, ... } @ args: + stdenv.mkDerivation rec { + name = "${pname}-${version}"; + version = "nightly-${date}"; + preferLocalBuild = true; + # TODO meta; + outputs = [ "out" "doc" ]; + src = fetch (args // { inherit pname archive system date; }); + nativeBuildInputs = [ rsync ]; + dontStrip = true; + installPhase = '' + rsync --chmod=u+w -r ./*/ $out/ + ''; + preFixup = if stdenv.isLinux then let + # it's overkill, but fixup will prune + rpath = "$out/lib:" + lib.makeLibraryPath [ zlib stdenv.cc.cc.lib curl ]; + in '' + for executable in ${lib.concatStringsSep " " exes}; do + patchelf \ + --interpreter "$(< $NIX_CC/nix-support/dynamic-linker)" \ + --set-rpath "${rpath}" \ + "$out/bin/$executable" + done + for library in $out/lib/*.so; do + patchelf --set-rpath "${rpath}" "$library" + done + '' else ""; + }; + +in rec { + rustc = generic { + pname = "rustc"; + archive = "https://static.rust-lang.org/dist"; + exes = [ "rustc" "rustdoc" ]; + }; + + rustcWithSysroots = { rustc, sysroots ? [] }: buildEnv { + name = "combined-sysroots"; + paths = [ rustc ] ++ sysroots; + pathsToLink = [ "/lib" "/share" ]; + #buildInputs = [ makeWrapper ]; + # Can't use wrapper script because of https://github.com/rust-lang/rust/issues/31943 + postBuild = '' + mkdir -p $out/bin/ + cp ${rustc}/bin/* $out/bin/ + ''; + }; + + rust-std = { date ? defaultDate, system ? thisSys, ... } @ args: + stdenv.mkDerivation rec { + # Strip install.sh, etc + pname = "rust-std"; + version = "nightly-${date}"; + name = "${pname}-${version}-${system}"; + src = fetch (args // { + inherit pname date system; + archive = "https://static.rust-lang.org/dist"; + }); + installPhase = '' + mkdir -p $out + mv ./*/* $out/ + rm $out/manifest.in + ''; + }; + + cargo = generic { + pname = "cargo"; + archive = "https://static.rust-lang.org/dist"; + exes = [ "cargo" ]; + }; + + rust = generic { + pname = "rust"; + archive = "https://static.rust-lang.org/dist"; + exes = [ "rustc" "rustdoc" "cargo" ]; + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..7cc2faf --- /dev/null +++ b/shell.nix @@ -0,0 +1,37 @@ +let + pkgs = import <nixpkgs> {}; + crate2nix-src = pkgs.fetchFromGitHub { + owner = "kolloch"; + repo = "crate2nix"; + rev = "0.8.0"; + sha256 = "17mmf5sqn0fmpqrf52icq92nf1sy5yacwx9vafk43piaq433ba56"; + }; + crate2nix = pkgs.callPackage (import crate2nix-src) { }; + #rustPackages = pkgs.callPackage ./rust-nightly.nix { }; +in +pkgs.mkShell { + buildInputs = (with pkgs; [ + cargo + cmake + crate2nix + go + pkgconfig + rustc + ]); + /* + ++ (with rustPackages; [ + (cargo { + date = "2020-12-20"; + hash= "0rnbf2hb94yrs7xl567i35641z52by3jlijxwjn8m1slvnqvzshc"; + }) + (rustc { + date = "2020-12-20"; + hash= "1asahv0lv78r2v0117hc56a62hkssnnsl6qyzyh43wrwv70jv6i7"; + }) + (rust-std { + date = "2020-12-20"; + hash= "0x4qpwgqibljdsplrqap8r7n8kfc6lnys46c2czqva87w4fhzpwp"; + }) + ]); + */ +} |