Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ target

# Others
.DS_Store

# Nix build result
/result
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,45 @@ brew install rezigned/tap/upmd
cargo install --git https://github.com/rezigned/upmd.git
```

**Nix**

*Flakes*
You can try it in the shell without needing to install it first.
```bash
# Requires experimental features `flakes` and `nix-command` enabled
nix run github:rezigned/upmd -- DEMO.md
```

Install it temporarily in your shell
```bash
nix shell github:rezigned/upmd
```


*NixOS*
Install on NixOS as an overlay
```nix
{
inputs = {
nixpkgs.url = "https://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.zst";

upmd.url = "github:rezigned/upmd";
upmd.inputs.nixpkgs.follows = "nixpkgs";
};

# NixOS Configurations...
}
```

In your `configuration.nix`
```nix
{inputs, pkgs, ...}: {
nixpkgs.overlays = [inputs.upmd.overlays.default];
environment.systemPackages = [pkgs.upmd];
}
```


## Quick start

```bash
Expand Down
43 changes: 43 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
pkgs ? import <nixpkgs> {},
lib ? pkgs.lib,
rustPlatform,
python3,
}: let
manifest = lib.importTOML ./Cargo.toml;
in
rustPlatform.buildRustPackage {
pname = manifest.package.name;
version = manifest.package.version;

nativeBuildInputs = [
# Needed for test:
# runner::tests::unix::test_python_state_capture_roundtrip
python3
];

src = lib.cleanSource ./.;

cargoLock.lockFile = ./Cargo.lock;
cargoLock.outputHashes = {
"vt100-0.16.2" = "sha256-18opt/6FxwTx1CfWUEUm3QajujJvddBdvFDkRpopTtE=";
};

checkFlags = [
# FIXME: Skipped because NixOS is not guaranteed to have /bin/bash,
# which these tests rely on
#
# These tests pass in NixOS if /bin/bash is available
"--skip=runner::tests::unix::test_bin_attr_without_config"
"--skip=runner::tests::unix::test_bin_attr_takes_precedence_over_config"

# Failing (seems to fail due to non-interactive shell during nix build)
"--skip=apps::cli::app::tests::test_write_card_contains_code_and_separator"
];

meta = {
description = "Run any code blocks in markdown from the terminal";
mainProgram = manifest.package.name;
license = lib.licenses.mit;
};
}
35 changes: 24 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@
};
};

outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
outputs = {
self,
nixpkgs,
flake-utils,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
pkgs = import nixpkgs {
inherit system overlays;
};
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
with pkgs; {
packages = {
default = pkgs.callPackage ./default.nix {};
upmd = pkgs.callPackage ./default.nix {};
};
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
in
with pkgs;
{

devShells.default = mkShell {
buildInputs = [
rustToolchain
Expand All @@ -38,5 +46,10 @@
echo "Welcome to the upmd development environment!"
'';
};
});
})
// {
overlays.default = final: prev: {
upmd = prev.callPackage ./default.nix {};
};
};
}
Loading