Skip to content

Add Nix build configuration#42

Merged
spenserblack merged 21 commits intomainfrom
chore/nix
Feb 1, 2026
Merged

Add Nix build configuration#42
spenserblack merged 21 commits intomainfrom
chore/nix

Conversation

@spenserblack
Copy link
Copy Markdown
Owner

@spenserblack spenserblack commented Jan 29, 2026

This adds configuration to build the package with Nix tooling.

It also adds instructions to build from source to INSTALL.md.

See https://nix.dev/manual/nix/2.28/command-ref/new-cli/nix3-flake.html

Closes #26

@spenserblack spenserblack added the release:ignore PRs with this label are not included in release notes label Jan 29, 2026
@spenserblack
Copy link
Copy Markdown
Owner Author

@koibtw The Nix is happening

@koibtw
Copy link
Copy Markdown
Contributor

koibtw commented Jan 29, 2026

WOW 😮
you should look into flakes and make a flake for this
then u can use nix eval or even nix build in CI
here https://nix.dev/concepts/flakes
simple example https://codeberg.org/koibtw/kitget/src/branch/main/flake.nix

@spenserblack
Copy link
Copy Markdown
Owner Author

I'm thinking I'll have both default.nix and flake.nix so that there's both the old way and the new way (flake.nix is an experimental feature IIRC?)

@koibtw
Copy link
Copy Markdown
Contributor

koibtw commented Jan 29, 2026

well...... thats not really how that works. flakes are experimental but like literally 90% of nix users use flakes
flake can contain things like packages (your default.nix) and other stuff. it's just all managed in one place. you should look at my kitget example (updated it a minute ago), its fairly simple.

@spenserblack
Copy link
Copy Markdown
Owner Author

Alright, thanks! Will check out flakes, then.

@spenserblack spenserblack marked this pull request as draft January 29, 2026 20:50
@spenserblack spenserblack changed the title Add default.nix Add Nix build configuration Jan 30, 2026
@spenserblack spenserblack added the packaging Issues and PRs related to package managers and installer configurations label Jan 30, 2026
@spenserblack
Copy link
Copy Markdown
Owner Author

I followed examples in Nix docs and ended up writing something pretty different from your example. It's a mix of me being a beginner to Nix tooling and wanting to keep things simple.

It works (builds to ./result), but what do you think? Am I doing anything unwise or evil?

@spenserblack spenserblack marked this pull request as ready for review January 30, 2026 15:13
Copy link
Copy Markdown
Contributor

@koibtw koibtw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!!!!!!

Comment thread flake.nix Outdated
description = "Displays file structure as a tree with Nerd Font icons, git statuses, etc.";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nixpkgs.url = "github:NixOS/nixpkgs";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

you should NOT be using master

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any difference between this and github:NixOS/nixpkgs?ref=nixos-unstable?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, its the same

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, cool. I'll just go with that since that's what nix flake init defaulted to.

Comment thread .github/workflows/ci.yml Outdated
Comment thread flake.nix Outdated
Comment thread .github/workflows/ci.yml
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build Nix Package (classic)
run: nix-build
Copy link
Copy Markdown
Contributor

@koibtw koibtw Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
run: nix-build
nix-build -E "with import <nixpkgs> { }; callPackage ./nix/package.nix { }"

you should use it like this but you dont need it anyway since its the same package

Comment thread default.nix
Copy link
Copy Markdown
Contributor

@koibtw koibtw Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need a default.nix at all

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for flake.nix, but I think I need it so that users can build it the "old" way with nix-build instead of nix build, right? Since the docs noted some controversies with Flakes I figured I would let users also use the old way if they wanted. I guess nix-build -E "with import <nixpkgs> { }; callPackage ./nix/package.nix { }" would let me get rid of it but it's kind of nice to just call nix-build I guess 🤷

What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean i wouldnt do that personally but if you have to, then instead of doing it that way, just put this in default.nix

with import <nixpkgs> { }; callPackage ./nix/package.nix { }

Comment thread flake.nix Outdated
Comment thread INSTALL.md Outdated
Comment on lines +39 to +49
### With `nix-build`

```shell
nix-build
```

### As a Nix flake

```shell
nix --experimental-features nix-command --extra-experimental-features flakes build
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one With Nix with nix build is probably fine

Co-authored-by: koi <me@koi.rip>
@spenserblack
Copy link
Copy Markdown
Owner Author

@koibtw Thanks for helping so much with getting Nix builds set up ❤️

Comment thread default.nix
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean i wouldnt do that personally but if you have to, then instead of doing it that way, just put this in default.nix

with import <nixpkgs> { }; callPackage ./nix/package.nix { }

@spenserblack spenserblack removed the release:ignore PRs with this label are not included in release notes label Feb 1, 2026
@spenserblack spenserblack merged commit 8bccc25 into main Feb 1, 2026
5 checks passed
@spenserblack spenserblack deleted the chore/nix branch February 1, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packaging Issues and PRs related to package managers and installer configurations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants