Skip to content

Commit

Permalink
Fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
brumik committed May 30, 2024
1 parent 32ed4a7 commit 4afea16
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 39 deletions.
4 changes: 3 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
use flake
if has nix_direnv_version; then
use flake
fi
19 changes: 19 additions & 0 deletions NIX.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# NixOS and Flakes

The package is contains all the required install scripts and dependencies. You can use the flake as:

```nix
{
inputs = {
# ...
amber.url = "github:Ph0enixKM/Amber";
};
# then later with home manager for example
home.packages = [ inputs.amber.packages.${pkgs.system}.default ];
}
```

The package is avaiable as `amber-lang` on [nixpkgs](https://github.com/NixOS/nixpkgs/pull/313774).

While developing with Nix, the flake defines all dependencies for `nix develop` (or `direnv` if used).
21 changes: 2 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Programming language that compiles to Bash. It's a high level programming langua
Amber compiler currently works on:
- Linux x86 and ARM
- macOS x86 and ARM (Apple Silicon)
- Nix (NixOs)
- Nix (NixOS)

### macOS / Linux
Make sure that the operating system meets the following prerequisites
Expand All @@ -40,24 +40,7 @@ Arch (AUR) - `amber-bash-bin`

#### Nix

The package is already containing all the required install scripts and dependencies. You can use the flake as:

```nix
{
inputs = {
# ...
amber.url = "github:brumik/ytsum";
};
# outputs somewhere
amber = inputs.amber.defaultPackage."${pkgs.system}";
# then later with home manager for example
home.packages = [ amber ];
}
```

While developing on Nixos the flake also defines all dependencies for `nix develop` (or `direnv` if used).
See [NIX.md](./NIX.md)

### Windows support
As windows does not come with bash installed it makes no sense to support it. Please install WSL 2 on your windows machine and install Linux version of Amber compiler inside.
Expand Down
7 changes: 0 additions & 7 deletions default.nix

This file was deleted.

7 changes: 3 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
naersk-lib = pkgs.callPackage naersk { };
in
{
defaultPackage = naersk-lib.buildPackage {
packages.default = naersk-lib.buildPackage {
src = ./.;
postInsall = ''
wrapProgram "$out/bin/amber" --set PATH ${nixpkgs.lib.makeBinPath [
pkgs.bash
pkgs.bc
]}
'';
};
devShell = with pkgs; mkShell {
buildInputs = [ bc bash cargo rustc rustfmt pre-commit rustPackages.clippy ];
devShells.default = with pkgs; mkShell {
buildInputs = [ bc cargo rustc rustfmt pre-commit rustPackages.clippy ];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
};
}
Expand Down
7 changes: 0 additions & 7 deletions shell.nix

This file was deleted.

2 changes: 1 addition & 1 deletion src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl AmberCompiler {
#[allow(dead_code)]
pub fn test_eval(&mut self) -> Result<String, Message> {
self.compile().map_or_else(Err, |(_, code)| {
let child = Command::new("/bin/bash")
let child = Command::new("/usr/bin/env").arg("bash")
.arg("-c").arg::<&str>(code.as_ref())
.output().unwrap();
Ok(String::from_utf8_lossy(&child.stdout).to_string())
Expand Down

0 comments on commit 4afea16

Please sign in to comment.