项目介绍

nix-community/todomvc-nix 是一个托管在 GitHub 上的开源项目,主要使用 Nix 编写,目前获得 180 个 Star、29 次 Fork。

仓库全名
nix-community/todomvc-nix
Star 数
180
Fork 数
29
未关闭 Issue
4

README 摘要

TodoMVC-Nix One-stop reference to build TodoMVC application inside the Nix world Are you new to Nix? Or are you use Nix, but still don't know how Nix is useful for your company? Maybe you have use Nix/NixOS in your current project, and you want to know how other project (using other programming language) fits into Nix world? TodoMVC-Nix can help you to understand how your project is structured using Nix to ease your…

完整内容见 GitHub 原始 README 或本页 。

常见问题

todomvc-nix 用什么语言开发?

主要使用 Nix 编写,目前有 180 个 Star。

如何获取 todomvc-nix 的源码?

可以直接克隆仓库:git clone https://github.com/nix-community/todomvc-nix.git,默认分支为 master;安装与运行步骤见仓库 README。

todomvc-nix 最近还在维护吗?

仓库最近一次更新为 2025年1月26日,当前有 4 个未关闭 Issue;Star 数为 180,可作为社区活跃度的参考。

关于

Example on how to nixify a project [maintainer=@Rizary]

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
246
价值分
117
活跃状态
活跃

语言占比

Dockerfile
HTML
Haskell
JavaScript
Nix
PLpgSQL
Rust
Shell

README

TodoMVC-Nix

One-stop reference to build TodoMVC application inside the Nix world

built with nix

Nix Flake

Are you new to Nix? Or are you use Nix, but still don’t know how Nix is useful for your company? Maybe you have use Nix/NixOS in your current project, and you want to know how other project (using other programming language) fits into Nix world? TodoMVC-Nix can help you to understand how your project is structured using Nix to ease your project development setting.

This project’s goal is to provide Nix user on every level (beginner, intermediate, and advance) a reference for building project using Nix programming language new feature called Flakes. This project contains several project written in different programming language and also how to nixified it.

Related article: todomvc-nix: One-Stop Solution for Developing Projects Using Nix

Structure

Technology Stack

[Back to the Table of Contents] ↑

TodoMVC-Nix has several examples on how fullstack project is structured using Nix Flakes. This stack can be used as an example for early stage startup or some new project which might want to consider to use Nix in their development journey. The stack consists of the following:

  • Backend
    • Rust
    • Haskell
  • Frontend
    • Rust
    • Haskell
  • Database
    • PostgreSQL

Another language and stack will be added accordingly.

Get Started

[Back to the Table of Contents] ↑

Before exploring the project, there are several things that need to be prepared first as explained below.

Prerequisites

[Back to the Table of Contents] ↑

Make sure that you have the following package installed in your machine:

Setup

[Back to the Table of Contents] ↑

Non-nix-flake user

This repository can be used using plain nix-build or nix-shell. This is possible with the help of flake-compat as mentioned in default.nix. To build the package, just run:

$ nix-build -A defaultNix.legacyPackages.x86_64-linux.nix.haskellBackend

and to enter into Nix shell, run:

$ nix-shell
Nix-flake user

If you want to use this repo with flakes feature, please enable it using the following method:

Linux and Windows Subsystem Linux 2 (WSL2)

Install Nix as instructed above. Next, install nixUnstable by running the following code:

nix-env -iA nixpkgs.nixFlakes

Lastly, open your ~/.config/nix/nix.conf or /etc/nix/nix.conf file and add:

experimental-features = nix-command flakes

NixOS

Add the following code into your configuration.nix:

{ pkgs, ... }: {
  nix = {
    package = pkgs.nixFlakes;
      extraOptions = ''
        experimental-features = nix-command flakes
      '';
  };
}

Usage

[Back to the Table of Contents] ↑

Clone this repository, and enter into it:

$ git clone https://github.com/nix-community/todomvc-nix.git
$ cd todomvc-nix

run nix develop and wait until the downloading/caching the dependencies are finished.

Once it is finished, you can refer to the documentation below:

For Developers

[Back to the Table of Contents] ↑

Build

[Back to the Table of Contents] ↑

Building package in Nix Flakes is simply by running the following code:

nix build .#todomvc.nix.haskellBackend

The above example will build todo-haskell package which is a backend built in Haskell. Here is the breakdown of the command:

  • nix build - is a nix v2 command to build package
  • .#todomvc.nix.haskellBackend
    • . - it means the directory contain flake.nix,
    • # - it is to separate between directory and package,
    • todomvc.nix.haskellBackend - is the package describe in the overlay that we want to build.

The result of the build will be available in the result folder.

Run

[Back to the Table of Contents] ↑

By running nix develop in the project, some command as written in shell.nix will be available in the PATH.

There is also custom script that can be created to simplify the command as specified in the commands attributes in shell.nix.

For example, command pgstart can be run to start the postgresql server. pgstart is custom script based on the following code:

{
  name = "pgstart";
  help = "start psql service";
  command = "${todomvc.nix.database.pgutil.start_pg} || echo '''PG start failed''' ";
}

Please refer to shell.nix for further command and package.

Acknowledgements

[Back to the Table of Contents] ↑

Most of the code that we put in this repo has previously been made by others. Here we credit the repository that we take the code from.

评论

暂无评论