Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/test-utilities/Cargo.lock
/test-utilities/target
/tmp
result
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,27 @@ most Windows users.)
</tbody>
</table>


#### Nix flake

The `just` repository has a `flake.nix` file defining the repository as a [nix flake](https://nix.dev/concepts/flakes.html)

You can specify the `just` repository as an input to another nix flake:

```nix
{
inputs = {
...
just.url = "github:casey/just";
}

outputs = {self, nixpkgs, just}: {
...
}
}

```

![just package version table](https://repology.org/badge/vertical-allrepos/just.svg)

### Pre-Built Binaries
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

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

137 changes: 137 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
description = "Just a command runner";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
};

# Read version from Cargo.toml
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
version = cargoToml.package.version;

# Common build inputs
buildInputs = with pkgs;
lib.optionals stdenv.hostPlatform.isDarwin [
libiconv
darwin.apple_sdk.frameworks.Security
];

nativeBuildInputs = with pkgs; [
installShellFiles
pkg-config
];

# The main just package
just = pkgs.rustPlatform.buildRustPackage {
pname = "just";
inherit version;

src = ./.;

cargoLock = {
lockFile = ./Cargo.lock;
};

inherit nativeBuildInputs buildInputs;

# Don't check during build since we run tests separately
doCheck = false;

# Generate shell completions and man pages
postInstall = ''
# Generate and install shell completions
for shell in bash fish zsh; do
$out/bin/just --completions $shell > just.$shell
installShellCompletion just.$shell
done

# Generate and install man page
$out/bin/just --man > just.1
installManPage just.1
'';

# Setup hook for runtime dependencies
setupHook = pkgs.writeText "setup-hook.sh" ''
export JUST_PATH_PREFIX="${pkgs.lib.makeBinPath [pkgs.coreutils pkgs.bashInteractive]}''${JUST_PATH_PREFIX:+:$JUST_PATH_PREFIX}"
'';

meta = let
p = cargoToml.package;
in {
description = p.description;
homepage = p.homepage;
changelog = "${p.repository}/blob/master/CHANGELOG.md";
license = pkgs.lib.licenses.cc0;
mainProgram = "just";
};
};

# Development shell with additional tools
devShell = pkgs.mkShell {
inputsFrom = [just];

packages = with pkgs; [
# Rust toolchain
rustc
cargo
clippy
rustfmt
rust-analyzer

# Development tools
cargo-watch
cargo-fuzz
cargo-outdated
cargo-udeps
mdbook
mdbook-linkcheck
shellcheck

# Runtime dependencies
bashInteractive
coreutils

# Additional utilities from justfile
python3
nodejs
perl
ruby
];

shellHook = ''
echo "Just development environment"
echo "Version: ${version}"
'';
};
in {
packages = {
default = just;
just = just;
};

apps = {
default = flake-utils.lib.mkApp {
drv = just;
exePath = "/bin/just";
};
};

devShells.default = devShell;

# Formatter for `nix fmt`
formatter = pkgs.nixpkgs-fmt;
}
);
}