Skip to content

Commit 8bccc25

Browse files
spenserblackkoibtw
andauthored
Add Nix build configuration (#42)
Co-authored-by: koi <me@koi.rip>
1 parent 0a93a58 commit 8bccc25

File tree

9 files changed

+105
-0
lines changed

9 files changed

+105
-0
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ indent_size = 2
2727
indent_style = tab
2828
indent_size = unset
2929

30+
# Nix
31+
[*.nix]
32+
indent_style = space
33+
indent_size = 2
34+
3035
# PowerShell
3136
[*.ps1]
3237
end_of_line = CRLF

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,19 @@ jobs:
5050

5151
- name: Test
5252
run: cargo test
53+
54+
build-nix:
55+
name: Build Nix
56+
needs:
57+
- build
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- uses: actions/checkout@v6
62+
- uses: cachix/install-nix-action@v31
63+
with:
64+
nix_path: nixpkgs=channel:nixos-unstable
65+
- name: Build Nix Package (classic)
66+
run: nix-build
67+
- name: Build Flake
68+
run: nix build

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Rust build files
55
/target
6+
7+
# Nix build files
8+
/result

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ exclude = [
1616
"INSTALL.md",
1717
"/lua/",
1818
"/scripts/",
19+
"*.nix",
20+
"flake.lock",
1921
]
2022
rust-version = "1.92"
2123
categories = ["command-line-utilities", "filesystem", "visualization"]

INSTALL.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,27 @@ Visit the [latest release](https://github.com/spenserblack/fancy-tree/releases/l
2525
```shell
2626
cargo install --locked fancy-tree
2727
```
28+
29+
## From source
30+
31+
Build the executable from source code and then copy it to a place in `PATH`.
32+
33+
### With `cargo`
34+
35+
```shell
36+
cargo build --release
37+
```
38+
39+
### With Nix
40+
41+
#### The classic way
42+
43+
```shell
44+
nix-build
45+
```
46+
47+
#### The Nix Flakes way
48+
49+
```shell
50+
nix --experimental-features nix-command --extra-experimental-features flakes build
51+
```

default.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
with import <nixpkgs> { };
2+
callPackage ./nix/package.nix { inherit rustPlatform; }

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
description = "Displays file structure as a tree with Nerd Font icons, git statuses, etc.";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
6+
};
7+
8+
outputs = { self, nixpkgs }:
9+
let
10+
system = "x86_64-linux";
11+
pkgs = nixpkgs.legacyPackages.${system};
12+
in {
13+
packages.${system} = rec {
14+
fancy-tree = pkgs.callPackage ./nix/package.nix { };
15+
default = fancy-tree;
16+
};
17+
};
18+
}

nix/package.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{ rustPlatform }: rustPlatform.buildRustPackage {
2+
pname = "fancy-tree";
3+
version = "0.1.2";
4+
src = ../.;
5+
cargoLock = {
6+
lockFile = ../Cargo.lock;
7+
};
8+
}

0 commit comments

Comments
 (0)