From 7d49aef5625a7267e23e53af11ceadd487586b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=97=8D+85CD?= <50108258+kwaa@users.noreply.github.com> Date: Sat, 8 Jun 2024 16:25:42 +0800 Subject: [PATCH] refactor: use flake instead of devbox (#45) * refactor: remove devbox * chore: remove rust-toolchain * chore: init devenv * fix(devenv): fix typo * fix(devenv): set root * fix(devenv): fix imports * fix(ci): add rust-toolchain * fix(devenv): add fenix * fix: use nightly rust --- .envrc | 8 +- .gitignore | 5 +- devbox.json | 29 --- devbox.lock | 184 ----------------- devenv.nix | 32 +++ flake.lock | 472 ++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 62 ++++++ rust-toolchain.toml | 5 +- 8 files changed, 572 insertions(+), 225 deletions(-) delete mode 100644 devbox.json delete mode 100644 devbox.lock create mode 100644 devenv.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc index 84fc8e53..7fa66fa2 100644 --- a/.envrc +++ b/.envrc @@ -1,7 +1 @@ -# Automatically sets up your devbox environment whenever you cd into this -# directory via our direnv integration: - -eval "$(devbox generate direnv --print-envrc)" - -# check out https://www.jetpack.io/devbox/docs/ide_configuration/direnv/ -# for more details +use flake . --override-input devenv-root "file+file://"<(printf %s "$PWD") diff --git a/.gitignore b/.gitignore index c26335a4..a6097f9b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,5 +23,6 @@ target/ # mdBook docs/book -# devbox -.devbox +# direnv / devenv +.direnv +.devenv diff --git a/devbox.json b/devbox.json deleted file mode 100644 index 8c8aaf92..00000000 --- a/devbox.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "packages": [ - "rustup@latest", - "cmake@latest", - "just@latest", - "cargo-watch@latest", - "cargo-zigbuild@latest", - "openssl@latest", - "pkg-config@latest", - "sea-orm-cli@latest", - "postgresql@latest" - ], - "env": { - "HATSU_DATABASE_URL": "postgres://hatsu:hatsu@localhost/hatsu" - }, - "shell": { - "scripts": { - "init_db": "initdb", - "start_db": "devbox services start postgresql", - "stop_db": "devbox services stop postgresql", - "create_db": [ - "dropdb --if-exists hatsu", - "createdb hatsu", - "psql hatsu -c \"CREATE USER hatsu WITH PASSWORD 'hatsu';\"", - "psql hatsu -c \"GRANT ALL ON SCHEMA public TO hatsu;\"" - ] - } - } -} diff --git a/devbox.lock b/devbox.lock deleted file mode 100644 index 3819c249..00000000 --- a/devbox.lock +++ /dev/null @@ -1,184 +0,0 @@ -{ - "lockfile_version": "1", - "packages": { - "cargo-watch@latest": { - "last_modified": "2024-03-19T05:49:19Z", - "resolved": "github:NixOS/nixpkgs/5710127d9693421e78cca4f74fac2db6d67162b1#cargo-watch", - "source": "devbox-search", - "version": "8.5.2", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/hh976x0j908iyjjni3v5k14iw0a765lh-cargo-watch-8.5.2" - }, - "aarch64-linux": { - "store_path": "/nix/store/sv3c3mp9ryq76vvgmk1dx81amz5366jq-cargo-watch-8.5.2" - }, - "x86_64-darwin": { - "store_path": "/nix/store/cr7b2ph334w8w835sjch31x14xnyz0si-cargo-watch-8.5.2" - }, - "x86_64-linux": { - "store_path": "/nix/store/hqwbki4vfrwcm3rb0pwxyv7dyrj99m78-cargo-watch-8.5.2" - } - } - }, - "cargo-zigbuild@latest": { - "last_modified": "2024-02-24T23:06:34Z", - "resolved": "github:NixOS/nixpkgs/9a9dae8f6319600fa9aebde37f340975cab4b8c0#cargo-zigbuild", - "source": "devbox-search", - "version": "0.18.3", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/diivvkiqbvk3lcglbj825rmnfzricvs8-cargo-zigbuild-0.18.3" - }, - "aarch64-linux": { - "store_path": "/nix/store/087y3qaqazcnr7403s8mfbx2ymkiikfn-cargo-zigbuild-0.18.3" - }, - "x86_64-linux": { - "store_path": "/nix/store/nc07606g0g9gc5l10l09cr10jh58h7gk-cargo-zigbuild-0.18.3" - } - } - }, - "cmake@latest": { - "last_modified": "2024-02-28T06:32:26Z", - "resolved": "github:NixOS/nixpkgs/d53c2037394da6fe98decca417fc8fda64bf2443#cmake", - "source": "devbox-search", - "version": "3.28.2", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/bin32lqag7lx38994xpf9jvhk1xbd64c-cmake-3.28.2" - }, - "aarch64-linux": { - "store_path": "/nix/store/fw3h7g7ngy535pnx2fna57sq9279sbps-cmake-3.28.2" - }, - "x86_64-darwin": { - "store_path": "/nix/store/wpw5vjn95w8mhr7zn101684xnm0ilap1-cmake-3.28.2" - }, - "x86_64-linux": { - "store_path": "/nix/store/paxnwg89pdx4car5fj84mmiprg952459-cmake-3.28.2" - } - } - }, - "just@latest": { - "last_modified": "2024-02-24T23:06:34Z", - "resolved": "github:NixOS/nixpkgs/9a9dae8f6319600fa9aebde37f340975cab4b8c0#just", - "source": "devbox-search", - "version": "1.24.0", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/4y0018ypsv9psa73sz6na2806ndpx5sf-just-1.24.0" - }, - "aarch64-linux": { - "store_path": "/nix/store/gafx9wd70rzrk16jwm1fdmvs0y15knzk-just-1.24.0" - }, - "x86_64-darwin": { - "store_path": "/nix/store/imhg52m87050xjs76mkdlql422n28kvg-just-1.24.0" - }, - "x86_64-linux": { - "store_path": "/nix/store/92k9inba4i5bs7cp0kh99y1f93v407v0-just-1.24.0" - } - } - }, - "openssl@latest": { - "last_modified": "2024-03-02T13:37:51Z", - "resolved": "github:NixOS/nixpkgs/fa9a51752f1b5de583ad5213eb621be071806663#openssl", - "source": "devbox-search", - "version": "3.0.13", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/kshshywxqxw2rfnyz58ply8mvaxgmd8j-openssl-3.0.13-bin" - }, - "aarch64-linux": { - "store_path": "/nix/store/6122fpl8a71sjlm9nqp9b8mn5s9sd4b0-openssl-3.0.13-bin" - }, - "x86_64-darwin": { - "store_path": "/nix/store/mbd8hxmmzl2v905gf6m4m6haqzx1marc-openssl-3.0.13-bin" - }, - "x86_64-linux": { - "store_path": "/nix/store/0q8d0kcw57hi75lx8m1yb408w11ddbbg-openssl-3.0.13-bin" - } - } - }, - "pkg-config@latest": { - "last_modified": "2024-02-24T23:06:34Z", - "resolved": "github:NixOS/nixpkgs/9a9dae8f6319600fa9aebde37f340975cab4b8c0#pkg-config", - "source": "devbox-search", - "version": "0.29.2", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/fnmg21mqlh2l1svk9fbj4qgf2d3ahxb7-pkg-config-wrapper-0.29.2" - }, - "aarch64-linux": { - "store_path": "/nix/store/4pwc2xiin23qgdjih3l75rwwa8ysjb2k-pkg-config-wrapper-0.29.2" - }, - "x86_64-darwin": { - "store_path": "/nix/store/s0ygc53g9qllbsbmwfk11rp0kb76wh3c-pkg-config-wrapper-0.29.2" - }, - "x86_64-linux": { - "store_path": "/nix/store/492n7ylp2f9zn0k3vghv1snypgkzznc5-pkg-config-wrapper-0.29.2" - } - } - }, - "postgresql@latest": { - "last_modified": "2024-03-18T04:03:26Z", - "plugin_version": "0.0.2", - "resolved": "github:NixOS/nixpkgs/79bb4155141a5e68f2bdee2bf6af35b1d27d3a1d#postgresql", - "source": "devbox-search", - "version": "15.6", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/3np46k5s4y1i8vncjwi9rffx5f769bzh-postgresql-15.6" - }, - "aarch64-linux": { - "store_path": "/nix/store/3sjfbgsni8z05s1f42lsf31j8sgk2kdq-postgresql-15.6" - }, - "x86_64-darwin": { - "store_path": "/nix/store/nkg7g91zmmhv52h3dif32p33500fndg0-postgresql-15.6" - }, - "x86_64-linux": { - "store_path": "/nix/store/6mr1dkqqgkm6lhnkvir9i1jim2dnrl8j-postgresql-15.6" - } - } - }, - "rustup@latest": { - "last_modified": "2024-02-24T23:06:34Z", - "plugin_version": "0.0.1", - "resolved": "github:NixOS/nixpkgs/9a9dae8f6319600fa9aebde37f340975cab4b8c0#rustup", - "source": "devbox-search", - "version": "1.26.0", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/aq1krqfcib3811f8n9y7cv4ybqymdj80-rustup-1.26.0" - }, - "aarch64-linux": { - "store_path": "/nix/store/4yjhm4n7l81vqxlymanngflpyhwwjrbk-rustup-1.26.0" - }, - "x86_64-darwin": { - "store_path": "/nix/store/623yx50y1bswv71d0r4ss5fkhsh8vylf-rustup-1.26.0" - }, - "x86_64-linux": { - "store_path": "/nix/store/rs66y4kzwh1n8cz2ia0qw5m4fhahqwia-rustup-1.26.0" - } - } - }, - "sea-orm-cli@latest": { - "last_modified": "2024-02-24T23:06:34Z", - "resolved": "github:NixOS/nixpkgs/9a9dae8f6319600fa9aebde37f340975cab4b8c0#sea-orm-cli", - "source": "devbox-search", - "version": "0.12.10", - "systems": { - "aarch64-darwin": { - "store_path": "/nix/store/6x88gzmac9dazkzwbkjdfr39alqgghyr-sea-orm-cli-0.12.10" - }, - "aarch64-linux": { - "store_path": "/nix/store/030ljh6zpmyvcj37f3325h9sc68j8pzs-sea-orm-cli-0.12.10" - }, - "x86_64-darwin": { - "store_path": "/nix/store/f3ai0gm83wh1m33vr1s7qz6ginlrnnlb-sea-orm-cli-0.12.10" - }, - "x86_64-linux": { - "store_path": "/nix/store/yp6dp7d3s0bh79rrp3lpfjs7amz7i7hh-sea-orm-cli-0.12.10" - } - } - } - } -} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 00000000..8b88fe4c --- /dev/null +++ b/devenv.nix @@ -0,0 +1,32 @@ +# https://devenv.sh/basics/ +{ lib, pkgs, ... }: +let rust_toolchain = lib.importTOML ./rust-toolchain.toml; +in { + name = "hatsu"; + + # https://devenv.sh/languages/ + languages.rust = { + enable = true; + channel = rust_toolchain.toolchain.channel; + components = rust_toolchain.toolchain.components; + }; + + imports = [ + # This is just like the imports in devenv.nix. + # See https://devenv.sh/guides/using-with-flake-parts/#import-a-devenv-module + # ./devenv-foo.nix + ]; + + # https://devenv.sh/packages/ + packages = with pkgs; [ + # cargo-* + cargo-watch + + mold + sccache + ]; + + # enterShell = '' + # hello + # ''; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..269894d5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,472 @@ +{ + "nodes": { + "cachix": { + "inputs": { + "devenv": "devenv_2", + "flake-compat": [ + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "pre-commit-hooks": [ + "devenv", + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1712055811, + "narHash": "sha256-7FcfMm5A/f02yyzuavJe06zLa9hcMHsagE28ADcmQvk=", + "owner": "cachix", + "repo": "cachix", + "rev": "02e38da89851ec7fec3356a5c04bc8349cae0e30", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "cachix", + "type": "github" + } + }, + "devenv": { + "inputs": { + "cachix": "cachix", + "flake-compat": "flake-compat_2", + "nix": "nix_2", + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1717698746, + "narHash": "sha256-Bt/q+zyBpI3Uwd6HGTvZSPvRR2DoaHXtvfFULeXP/aI=", + "owner": "cachix", + "repo": "devenv", + "rev": "866ecadab5d92cdbb296723f67fa464d01401d9a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "devenv_2": { + "inputs": { + "flake-compat": [ + "devenv", + "cachix", + "flake-compat" + ], + "nix": "nix", + "nixpkgs": "nixpkgs", + "poetry2nix": "poetry2nix", + "pre-commit-hooks": [ + "devenv", + "cachix", + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1708704632, + "narHash": "sha256-w+dOIW60FKMaHI1q5714CSibk99JfYxm0CzTinYWr+Q=", + "owner": "cachix", + "repo": "devenv", + "rev": "2ee4450b0f4b95a1b90f2eb5ffea98b90e48c196", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "python-rewrite", + "repo": "devenv", + "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" + } + }, + "flake-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1717285511, + "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "devenv", + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nix": { + "inputs": { + "flake-compat": "flake-compat", + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression" + }, + "locked": { + "lastModified": 1712911606, + "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "poetry2nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1688870561, + "narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "165b1650b753316aa7f1787f3005a8d2da0f5301", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nix_2": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-regression": "nixpkgs-regression_2" + }, + "locked": { + "lastModified": 1712911606, + "narHash": "sha256-BGvBhepCufsjcUkXnEEXhEVjwdJAwPglCC2+bInc794=", + "owner": "domenkozar", + "repo": "nix", + "rev": "b24a9318ea3f3600c1e24b4a00691ee912d4de12", + "type": "github" + }, + "original": { + "owner": "domenkozar", + "ref": "devenv-2.21", + "repo": "nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1692808169, + "narHash": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9201b5ff357e781bf014d0330d18555695df7ba8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1717284937, + "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" + } + }, + "nixpkgs-regression": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-regression_2": { + "locked": { + "lastModified": 1643052045, + "narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1710695816, + "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "614b4613980a522ba49f0d194531beddbb7220d3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1713361204, + "narHash": "sha256-TA6EDunWTkc5FvDCqU3W2T3SFn0gRZqh6D/hJnM02MM=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "285676e87ad9f0ca23d8714a6ab61e7e027020c6", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1717646450, + "narHash": "sha256-KE+UmfSVk5PG8jdKdclPVcMrUB8yVZHbsjo7ZT1Bm3c=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "818dbe2f96df233d2041739d6079bb616d3e5597", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": "flake-utils", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "devenv", + "cachix", + "devenv", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692876271, + "narHash": "sha256-IXfZEkI0Mal5y1jr6IRWMqK8GW2/f28xJenZIPQqkY0=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "d5006be9c2c2417dafb2e2e5034d83fabd207ee3", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": [ + "devenv", + "flake-compat" + ], + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": [ + "devenv", + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1713775815, + "narHash": "sha256-Wu9cdYTnGQQwtT20QQMg7jzkANKQjwBD9iccfGKkfls=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "2ac4dcbf55ed43f3be0bae15e181f08a57af24a4", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_3" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..1a7f328d --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "Description for the project"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + devenv-root.url = "file+file:///dev/null"; + devenv-root.flake = false; + devenv.url = "github:cachix/devenv"; + + flake-parts.url = "github:hercules-ci/flake-parts"; + + fenix.url = "github:nix-community/fenix/monthly"; + fenix.inputs.nixpkgs.follows = "nixpkgs"; + + # nix2container.url = "github:nlewo/nix2container"; + # nix2container.inputs.nixpkgs.follows = "nixpkgs"; + + # mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin"; + }; + + nixConfig = { + extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="; + extra-substituters = "https://devenv.cachix.org"; + }; + + outputs = inputs@{ flake-parts, devenv-root, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.devenv.flakeModule + ]; + systems = [ "x86_64-linux" "aarch64-linux" ]; + + perSystem = { config, self', inputs', lib, pkgs, system, ... }: { + # Per-system attributes can be defined here. The self' and inputs' + # module parameters provide easy access to attributes of the same + # system. + + # Equivalent to inputs'.nixpkgs.legacyPackages.hello; + # packages.default = pkgs.hello; + + devenv.shells.default = { + name = "hatsu"; + imports = [ + ./devenv.nix + ]; + + devenv.root = + let + devenvRootFileContent = builtins.readFile devenv-root.outPath; + in + pkgs.lib.mkIf (devenvRootFileContent != "") devenvRootFileContent; + }; + }; + flake = { + # The usual flake attributes can be defined here, including system- + # agnostic ones like nixosModule and system-enumerating ones, although + # those are more easily expressed in perSystem. + + }; + }; +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 81112c0b..b7f9c4e2 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,8 +1,7 @@ # https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file -# https://taplo.tamasfe.dev/configuration/directives.html#the-schema-directive -#:schema undefined [toolchain] channel = "nightly" -components = ["rustc", "rust-analyzer", "rustfmt", "cargo", "clippy"] +# https://rust-lang.github.io/rustup/concepts/components.html +components = ["rustc", "cargo", "rustfmt", "rust-analyzer", "clippy"] profile = "minimal"