diff --git a/default.nix b/default.nix index ae3438d..2a39ff2 100644 --- a/default.nix +++ b/default.nix @@ -8,24 +8,24 @@ let # TODO: remove once cargo-nextest is available in nixpkgs stable cargo-nextest = (pkgs.callPackage ./nix/cargo-nextest/default.nix { }); in - with pkgs; - mkShell { - name = "build"; - buildInputs = [ - # cargo tooling - cargo-deny - cargo-nextest - cargo-watch - pkgs.rust-bin.nightly."2022-07-01".rustfmt +with pkgs; +mkShell { + name = "build"; + buildInputs = [ + # cargo tooling + cargo-deny + cargo-nextest + cargo-watch + pkgs.rust-bin.nightly."2022-07-01".rustfmt - # hard dependencies - cmake - openssl - pkgconfig - rust-overlay + # hard dependencies + cmake + openssl + pkgconfig + rust-overlay - # testing utilities - gettext # for `envsubst` - socat - ]; - } + # testing utilities + gettext # for `envsubst` + socat + ]; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..490f101 --- /dev/null +++ b/flake.lock @@ -0,0 +1,176 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1697639218, + "narHash": "sha256-OGODP0O6ZtXrdP2lBNqNumQZ2k/KzWsvxgwY1zSeKE8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b21a8c71aa75e67bd58eb709f4506a76c7fd28a1", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1695644571, + "narHash": "sha256-asS9dCCdlt1lPq0DLwkVBbVoEKuEuz+Zi3DG7pR/RxA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6500b4580c2a1f3d0f980d32d285739d8e156d92", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", + "systems": "systems_3", + "treefmt-nix": "treefmt-nix" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "narHash": "sha256-zdN6UVtEml7t0WQHVy0avsE+TWJLklXnqJyiPaOa8u0=", + "type": "tarball", + "url": "https://github.com/oxalica/rust-overlay/archive/673e2d3d2a3951adc6f5e3351c9fce6ad130baed.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/oxalica/rust-overlay/archive/673e2d3d2a3951adc6f5e3351c9fce6ad130baed.tar.gz" + } + }, + "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" + } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "id": "systems", + "type": "indirect" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1697388351, + "narHash": "sha256-63N2eBpKaziIy4R44vjpUu8Nz5fCJY7okKrkixvDQmY=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "aae39f64f5ecbe89792d05eacea5cb241891292a", + "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 0000000..548aa31 --- /dev/null +++ b/flake.nix @@ -0,0 +1,65 @@ +{ + description = "Radicle Git"; + + # Can use `input.` instead + outputs = { self, nixpkgs, systems, flake-utils, rust-overlay, treefmt-nix, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ rust-overlay.overlays.default ]; + }; + + # Small tool to iterate over each systems + treefmtEval = treefmt-nix.lib.evalModule pkgs { + # Used to find the project root + projectRootFile = "flake.nix"; + programs.nixpkgs-fmt.enable = true; + programs.rustfmt.package = pkgs.rust-bin.nightly."2022-07-01".rustfmt; + programs.rustfmt.enable = true; + }; + in + { + devShells.default = import ./shell.nix { inherit pkgs; }; + + # formatter = pkgs.alejandra; + # for `nix fmt` + formatter = treefmtEval.config.build.wrapper; + # for `nix flake check` + checks = { + # ci = pkgs.runCommand "ci/run" { + # src = ./.; + # _noChroot = true; + # nativeBuildInputs = self.devShells.${system}.default.nativeBuildInputs ++ [ pkgs.cargo pkgs.rust-bin.nightly."2022-07-01".rustfmt pkgs.clippy ]; + # } '' + # set -eou pipefail + + # HOME=$(pwd)/rust-build + # mkdir $HOME + # export HOME + + # mkdir $HOME/.cargo -p + # chmod +w -R $HOME/.cargo + + # cp $src ./build -r + # cd ./build + + # cargo fmt -- --check + # bash ./scripts/ci/lint + # bash ./scripts/ci/build + # bash ./scripts/ci/test + # bash ./scripts/ci/docs + # bash ./scripts/ci/advisory + # ''; + formatting = treefmtEval.config.build.check self; + }; + } + ); + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/release-23.05"; + rust-overlay.url = "https://github.com/oxalica/rust-overlay/archive/673e2d3d2a3951adc6f5e3351c9fce6ad130baed.tar.gz"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + flake-utils.url = "github:numtide/flake-utils"; + }; +} diff --git a/nix/cargo-nextest/default.nix b/nix/cargo-nextest/default.nix index e41e1fd..536954d 100644 --- a/nix/cargo-nextest/default.nix +++ b/nix/cargo-nextest/default.nix @@ -22,8 +22,6 @@ rustPlatform.buildRustPackage rec { buildInputs = [ openssl libiconv - ] ++ lib.optionals stdenv.isDarwin [ - Security ]; doCheck = false; diff --git a/shell.nix b/shell.nix index 71ae45a..ae791b1 100644 --- a/shell.nix +++ b/shell.nix @@ -8,16 +8,16 @@ let rust-overlay = stable.override { extensions = [ "rust-src" "rust-analysis" ]; }; - devault = (pkgs.callPackage ./default.nix {}); + devault = (pkgs.callPackage ./default.nix { }); in - with pkgs; - mkShell { - name = "development"; - buildInputs = devault.buildInputs ++ [ - clang - lld +with pkgs; +mkShell { + name = "development"; + buildInputs = devault.buildInputs ++ [ + clang + lld - ripgrep - rust-analyzer - ]; - } + ripgrep + rust-analyzer + ]; +}