All Projects → nix-community → todomvc-nix

nix-community / todomvc-nix

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

Programming Languages

Nix
1067 projects
rust
11053 projects
haskell
3896 projects
shell
77523 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to todomvc-nix

dns.nix
A Nix DSL for DNS zone files
Stars: ✭ 69 (-50%)
Mutual labels:  nix
yarn-plugin-nixify
Yarn v3 plugin to help with Nix packaging
Stars: ✭ 41 (-70.29%)
Mutual labels:  nix
crane
A Nix library for building cargo projects. Never build twice thanks to incremental artifact caching.
Stars: ✭ 348 (+152.17%)
Mutual labels:  nix
terranix
terranix is a terraform.json generator with a nix-like feeling
Stars: ✭ 164 (+18.84%)
Mutual labels:  nix
freebsd-ports-nix
Nix package manager port for the FreeBSD Ports Collection
Stars: ✭ 33 (-76.09%)
Mutual labels:  nix
nix bsd mac inventory
Collect Inventory data from *Nix, BSD and mac OS and upload to Device42
Stars: ✭ 17 (-87.68%)
Mutual labels:  nix
nvfetcher
Generate nix sources expr for the latest version of packages
Stars: ✭ 95 (-31.16%)
Mutual labels:  nix
nix-install-vendor-gl
Ensure that a system-compatible OpenGL driver is available for `nix-shell`-encapsulated programs.
Stars: ✭ 22 (-84.06%)
Mutual labels:  nix
nix-config
A collection of my system configs and dotfiles
Stars: ✭ 35 (-74.64%)
Mutual labels:  nix
impermanence
Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
Stars: ✭ 401 (+190.58%)
Mutual labels:  nix
nix-configs
My Nix{OS} configuration files
Stars: ✭ 54 (-60.87%)
Mutual labels:  nix
nixpkgs-review-checks
Add additional checks and more information from build logs and outputs to the reports generated by nixpkgs-review.
Stars: ✭ 27 (-80.43%)
Mutual labels:  nix
nixos-configuration
A repo for my nixos configuration files
Stars: ✭ 20 (-85.51%)
Mutual labels:  nix
psc-package2nix
Tool to derive a Nix expression from a psc-package.json configuration.
Stars: ✭ 13 (-90.58%)
Mutual labels:  nix
buildkit-nix
Nix derivations as Dockerfiles (`docker build -f default.nix .`)
Stars: ✭ 99 (-28.26%)
Mutual labels:  nix
nyoom.emacs
Configurable, Minimal, Fast emacs config based on Nano-emacs and Doom
Stars: ✭ 59 (-57.25%)
Mutual labels:  nix
persway
Small Sway IPC Daemon
Stars: ✭ 51 (-63.04%)
Mutual labels:  nix
nixvim
Configure Neovim with Nix!
Stars: ✭ 120 (-13.04%)
Mutual labels:  nix
nixpkgs-pytools
Tools for removing the tedious nature of creating nixpkgs derivations [maintainer=@costrouc]
Stars: ✭ 36 (-73.91%)
Mutual labels:  nix
release-services
Mozilla Release Engineering Services
Stars: ✭ 49 (-64.49%)
Mutual labels:  nix

TodoMVC-Nix

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

built with nix

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].