Skip to content

Commit

Permalink
WIP: flake-ify radicle-git
Browse files Browse the repository at this point in the history
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
  • Loading branch information
FintanH committed Oct 19, 2023
1 parent f83c6d6 commit 0130374
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 32 deletions.
38 changes: 19 additions & 19 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}
176 changes: 176 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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";
};
}
2 changes: 0 additions & 2 deletions nix/cargo-nextest/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ rustPlatform.buildRustPackage rec {
buildInputs = [
openssl
libiconv
] ++ lib.optionals stdenv.isDarwin [
Security
];

doCheck = false;
Expand Down
22 changes: 11 additions & 11 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}

0 comments on commit 0130374

Please sign in to comment.