Skip to content

Commit

Permalink
Adding nix flake (#547)
Browse files Browse the repository at this point in the history
* adding flake

* fix README

* README: fix grammar

* README: add nix profile example

* README: make linter happy

* README: remove multiple blank lines

* Update README.md

Co-authored-by: Pavel Ivanov <[email protected]>

* Update README.md

Co-authored-by: Pavel Ivanov <[email protected]>

* READMDE: align nix-flake section

---------

Co-authored-by: Pavel Ivanov <[email protected]>
  • Loading branch information
TornaxO7 and pamburus authored Dec 12, 2024
1 parent 2380d85 commit 7c88384
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
/*.log.xz
/*.log.zst
/target

# devenv
.direnv
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,51 @@ High performance and convenient features are the main goals.
cargo install --locked --git https://github.com/pamburus/hl.git
```

* Run using [nix](https://nixos.org/download/)

```sh
nix run github:pamburus/hl
```

or install with [nix profile](https://nix.dev/manual/nix/2.22/command-ref/new-cli/nix3-profile-install):

```sh
nix profile install github:pamburus/hl
```

* Install the package using [nix-flakes](https://wiki.nixos.org/wiki/Flakes)

<details>
<summary>Example how to update nix configuration</summary>

```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
hl.url = "github:pamburus/hl";
};
outputs = {nixpkgs, hl, ...}:
let
system = "x86_64-linux";
in
{
# this is just an example!
nixosConfigurations.yourHost = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
({...}: {
environment.systemPackages = [
hl.packages.${system}
];
})
];
};
};
}
```

</details>

* Download latest release from [download page](https://github.com/pamburus/hl/releases/latest)

## Examples
Expand Down
93 changes: 93 additions & 0 deletions flake.lock

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

32 changes: 32 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
flake-parts.url = "github:hercules-ci/flake-parts";
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; }
{
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];

perSystem = { self', lib, system, pkgs, config, ... }: {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;

overlays = with inputs; [
rust-overlay.overlays.default
];
};

packages.default = pkgs.callPackage ./nix/package.nix { };

devShells.default = self'.packages.default;
};
};
}
30 changes: 30 additions & 0 deletions nix/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ lib
, rustPlatform
,
}:
let
cargoToml = builtins.fromTOML (builtins.readFile ../Cargo.toml);
in
rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.workspace.package.version;

src = builtins.path {
path = ../.;
};

cargoLock = {
lockFile = ../Cargo.lock;
outputHashes = {
"htp-0.4.2" = "sha256-oYLN0aCLIeTST+Ib6OgWqEgu9qyI0n5BDtIUIIThLiQ=";
"wildflower-0.3.0" = "sha256-vv+ppiCrtEkCWab53eutfjHKrHZj+BEAprV5by8plzE=";
};
};

meta = {
description = cargoToml.package.description;
homepage = cargoToml.workspace.package.repository;
license = lib.licenses.mit;
mainProgram = cargoToml.package.name;
};
}

0 comments on commit 7c88384

Please sign in to comment.