Code Monkey home page Code Monkey logo

nix-flake-templates's Introduction

Start packaging projects with flakes without the fuss

This is a small collection of flake templates for use when developing software intended to be built or distributed with Nix flakes.

Usage

Initialising a Python virtual environment managed with poetry and Nix is as simple as

nix flake init -t "github:lukebfox/nix-flake-templates#python_nixpkgs_venv"
git init && git add .

which will give you

my_project
├─flake.nix
├─flake.lock
├─pyproject.toml
├─.gitignore
└─.envrc

Using with NixOS

When developing on NixOS reuse the nixpkgs instance which built your system for your ad-hoc dev environments will skip downloading a new nixpkgs when you initialise a project, and simplifies ensuring compatibility between system drivers, libraries and applications i.e nvidia/CUDA/Pytorch.

All the templates provided by this flake leave the 'nixpkgs' flake input to be resolved by the flake registry. In the flake providing your NixOS system, configure the local flake registry to use the flake's nixpkgs pin. Also, I find using the same registry technique with my flake-templates flake helpful.

Your system flake.nix:

{
    inputs.nixpkgs = "NixOS/nixpkgs/nixos-unstable";
    inputs.templates = "github:lukebfox/nix-flake-templates";
    ...
}

Your system configuration.nix

{
  nix.registry = {

    # Local flakes can use the system's nixpkgs.
    nixpkgs.flake = inputs.nixpkgs;

    # Can run anywhere: $ nix flake init -t "templates#<template_name>"
    templates.flake = inputs.templates;

  };
};

Templates

$ nix flake show "github:lukebfox/nix-flake-templates"

github:lukebfox/nix-configs/<commit-hash>
└───templates
    ├───python_nixpkgs_venv: template: A simple Python virtualenv, using nixpkgs packages.
    └───python_poetry_venv: template: A python virtual environment, managed by Poetry.

Contributing

If you want more like this feel free to open up an issue or a PR.


More like this

nixos/templates
serokell/templates

nix-flake-templates's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

layeddie

nix-flake-templates's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.