aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.envrc5
-rw-r--r--README.md5
-rw-r--r--flake.lock106
-rw-r--r--flake.nix72
-rw-r--r--rustfmt.toml2
-rw-r--r--treefmt.nix8
6 files changed, 197 insertions, 1 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 00000000..a3d54537
--- /dev/null
+++ b/.envrc
@@ -0,0 +1,5 @@
+# shellcheck shell=bash
+if ! has nix_direnv_version || ! nix_direnv_version 3.2.0; then
+ source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.2.0/direnvrc" "sha256-hW6NC1JHue3IjZN3uDM6l6I2PMaauqd2D7hXYJ1Zfr4="
+fi
+use flake
diff --git a/README.md b/README.md
index f3f22741..9ef03103 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,11 @@ Building Shirabe requires:
* Git
* PHP
* Composer
+* Nix (optional)
+* Direnv (optional)
+
+Nix flake supported; use `nix develop` to enter the development shell.
+TODO: support `nix build`
## Build
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 00000000..186ecf72
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,106 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": [
+ "systems"
+ ]
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1786593342,
+ "narHash": "sha256-smTKQXMLLStzc8zJevMCckbk3My7SvbbLmPYZUJJKW4=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "6b5e5b7a6631f065bf6908986990b37d845f847f",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs",
+ "rust-overlay": "rust-overlay",
+ "systems": "systems",
+ "treefmt-nix": "treefmt-nix"
+ }
+ },
+ "rust-overlay": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1786680812,
+ "narHash": "sha256-5lDFwethgqSULdupYl3Eu5n80jfcbb85gSJX/jb58GQ=",
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "rev": "f1dcc7e4ea4fdb6d8f276face22f353832b161e3",
+ "type": "github"
+ },
+ "original": {
+ "owner": "oxalica",
+ "repo": "rust-overlay",
+ "type": "github"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1680978846,
+ "narHash": "sha256-Gtqg8b/v49BFDpDetjclCYXm8mAnTrUzR0JnE2nv5aw=",
+ "owner": "nix-systems",
+ "repo": "x86_64-linux",
+ "rev": "2ecfcac5e15790ba6ce360ceccddb15ad16d08a8",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "x86_64-linux",
+ "type": "github"
+ }
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1785945821,
+ "narHash": "sha256-NLSyTCW4K4ofhNBllt3omPasm6QpralXH1DBZOc91Dw=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "ae7910970dddc408fe6ab1c8e4b277bb21d72dc0",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 00000000..57955bc2
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,72 @@
+{
+ description = "Port of Composer, the dependency manager for PHP, written in Rust";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+
+ systems.url = "github:nix-systems/x86_64-linux";
+
+ flake-utils = {
+ url = "github:numtide/flake-utils";
+ inputs.systems.follows = "systems";
+ };
+
+ rust-overlay = {
+ url = "github:oxalica/rust-overlay";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+
+ treefmt-nix = {
+ url = "github:numtide/treefmt-nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
+ };
+
+ outputs =
+ {
+ nixpkgs,
+ flake-utils,
+ rust-overlay,
+ treefmt-nix,
+ ...
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [ rust-overlay.overlays.default ];
+ };
+ rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
+ treefmt = treefmt-nix.lib.evalModule pkgs {
+ imports = [ ./treefmt.nix ];
+ programs.rustfmt.package = rustToolchain;
+ };
+ in
+ {
+ formatter = treefmt.config.build.wrapper;
+
+ devShells.default = pkgs.mkShell {
+ packages = [
+ rustToolchain
+ pkgs.php85
+
+ # The following softwares are used for testing.
+ # VCSs
+ pkgs.fossil
+ pkgs.git
+ pkgs.mercurial
+ pkgs.subversion
+ # Archivers
+ pkgs.bzip2
+ pkgs.gnutar
+ pkgs.gzip
+ pkgs.p7zip
+ pkgs.unzip
+ pkgs.xz
+ pkgs.zip
+ ];
+ };
+ }
+ );
+}
diff --git a/rustfmt.toml b/rustfmt.toml
index 35011368..f216078d 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -1 +1 @@
-style_edition = "2024"
+edition = "2024"
diff --git a/treefmt.nix b/treefmt.nix
new file mode 100644
index 00000000..b5a4ab9b
--- /dev/null
+++ b/treefmt.nix
@@ -0,0 +1,8 @@
+{ ... }:
+{
+ projectRootFile = "flake.nix";
+
+ programs.nixfmt.enable = true;
+ programs.rustfmt.enable = true;
+ # TODO: add php formatter
+}