Skip to content

Commit

Permalink
Merge pull request #52 from Danil-Grigorev/add-nix-env
Browse files Browse the repository at this point in the history
Introduce nix to cover prerequisites
  • Loading branch information
Danil-Grigorev authored May 31, 2024
2 parents c6cd3e9 + 2ee1fb0 commit b9bfa6d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
11 changes: 11 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# default.nix
{ pkgs ? import <nixpkgs> { } }:
let manifest = (pkgs.lib.importTOML ./Cargo.toml).package;
in
pkgs.rustPlatform.buildRustPackage rec {
pname = manifest.name;
version = manifest.version;
doCheck = false;
cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;
}
9 changes: 9 additions & 0 deletions development.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustc cargo gcc rustfmt clippy ];

# Certain Rust tools won't work without this
# This can also be fixed by using oxalica/rust-overlay and specifying the rust-src extension
# See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/3?u=samuela. for more details.
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}
14 changes: 14 additions & 0 deletions docs/book/src/developers/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@
- [helm](https://helm.sh/)
- [just](https://github.com/casey/just)

Alternatively:

- [nix](https://nixos.org/download/)

To enter the environment with prerequisites:

```bash
nix-shell
```

#### Common prerequisite

- [docker](https://docs.docker.com/engine/install/)

### Create a local development environment

1. Clone the [CAAPF](https://github.com/rancher-sandbox/cluster-api-addon-provider-fleet/) repository locally.
Expand Down
23 changes: 23 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
# Get dependencies from the main package
inputsFrom = [ (pkgs.callPackage ./default.nix { }) ];
# Additional tooling
buildInputs = with pkgs; [
rust-analyzer # LSP Server
rustfmt # Formatter
clippy # Linter
just
kind
kubernetes-helm
clusterctl
kubectl
k9s
jq
yq
envsubst
iproute2
docker-client
kustomize
];
}

0 comments on commit b9bfa6d

Please sign in to comment.