Skip to content

Conversation

@jaschutte
Copy link
Contributor

@jaschutte jaschutte commented Sep 17, 2025

Nix changes

Changes the Nix infrastructure inside of simple-nix to use Nix flakes. Adds some more explanation how to include dependencies using Nix and includes a Nix template. All of this was done to make it more user friendly (...for Nix users) to get started with Clash without having to have very deep knowledge of Nix or how Cabal works to make Nix and Cabal work together happily.

People who have Nix installed can now use immediately start using Clash with the simple-nix directory by running three commands:

mkdir my-project
cd my-project
nix flake init -t github:clash-lang/clash-starters

After this nix command is executed, it will display a 'welcome' message which gives a plain overview of what the Nix related commands do and instructs the user to read the README.md for more information.

Template changes

Aside from the Nix specific changes, we changed the entire way templates are set up. Nix specific templates can now be placed under the projects-nix sub-directory. This was an essential change to make as Nix and Stack templates are not compatible with each other. Nix and Stack in general do not play very nicely together so dropping Stack support for the Nix related template does not lose much. Files under clash-starters-files are now also copied verbatim into the clash-starters directory.

Original PR

The original PR is: clash-lang/clash-starters#6
Which I have closed after realizing that repository is essentially just a mirror

Credits

Big credits to @DigitalBrains1 for his massive help regarding everything really and @rslawson for testing!

Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

So there is a pretty major change involved with this. Before this PR, all our starter projects use the latest released version of Clash. With this PR, the Nix starter suddenly starts using Clash master. I don't think we should do that. I think it should keep on using the latest released version, and if currently our clash-compiler repo is not set up to support that (I don't know whether this is the case), we should make it such that it is.

If we decide to switch Nix users to Clash master (you somehow manage to convince me :-), then we should thoroughly document this in these starter projects as it is surely surprising.

@jaschutte jaschutte force-pushed the nix-flakes branch 3 times, most recently from daf0bb0 to 4dc09e5 Compare September 17, 2025 13:00
@jaschutte jaschutte force-pushed the nix-flakes branch 4 times, most recently from f8a88e4 to 6b816fb Compare November 9, 2025 17:37
@jaschutte
Copy link
Contributor Author

jaschutte commented Nov 9, 2025

Alright! This should use version 1.8.4 of clash now :)

One notable change is that I renamed {{name}}.cabal to simple-nix.cabal. This is because it also contains a Nix template, which does not substitute the {{name}} with the project name (and thus it all crashes and burns).

Short list of the down/upside of this change:
- have to manually rename the cabal
+ get an easy to use Nix template in return

@jaschutte
Copy link
Contributor Author

I have no clue why Github keeps closing this PR automatically???

Anyways, a lot of things in this PR changed regarding the Nix/Stack template side of things. simple-nix is now under a different directory for Nix related templates and no longer supports stack as an option.

The reasoning for this is as follows:

  • Nix and Stack templates were incompatible
  • If you were using Nix, there is no reason to use Stack (as Nix handles the dependencies and uses Cabal over stack)

@jaschutte jaschutte reopened this Nov 10, 2025
Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

Excellent, I think we're there. Just one teeeeensy little edit...

@jaschutte jaschutte force-pushed the nix-flakes branch 2 times, most recently from e63c20d to f992289 Compare November 12, 2025 10:01
@jaschutte jaschutte force-pushed the nix-flakes branch 9 times, most recently from 3f14b2e to cea568f Compare November 12, 2025 15:45
jaschutte and others added 2 commits November 12, 2025 16:50
Changes the Nix infrastructure inside of simple-nix to use Nix flakes.
Adds some more explanation how to include dependencies using Nix and
includes a Nix template. All of this was done to make it more user
friendly (...for Nix users) to get started with Clash without having to
have very deep knowledge of Nix or how Cabal works to make Nix and Cabal
work together happily.

People who have Nix installed can now use immediately start using Clash
with the simple-nix directory by running three commands:

```
mkdir my-project
cd my-project
nix flake init -t github:clash-lang/clash-starters
```

After this nix command is executed, it will display a 'welcome' message
which gives a plain overview of what the Nix related commands do and
instructs the user to read the README.md for more information.

The original PR is: clash-lang/clash-starters#6
Which I have closed after realizing that repository is essentially just
a mirror

Co-authored-by: Peter Lebbing <peter@digitalbrains.com>
The old CI did not run the Nix tests (it was silently failing). This
resolves that and also removes the publishing of Nix to Cachix as the
dependencies should be cached by the dependants themselves, and not the
starter projects.
@jaschutte jaschutte merged commit 8ec4652 into master Nov 12, 2025
21 checks passed
@jaschutte jaschutte deleted the nix-flakes branch November 12, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants