Giter VIP home page Giter VIP logo

flakes's Introduction

Resources

> Proper way to build a remote system with flakes - discourse.nixos.org > Awesome Nix - github

> Nix4Noobs VM

Usage

Building to a remote server # nixos-rebuild switch --flake .#myMachine --target-host user@system examples: # nixos-rebuild switch --flake .#system --target-host [email protected]

NixOS system in ./result

The build command to end up with a nixOS in ./result:

  1. Use this one if you don’t have nixOS but only nix available (e.g. on a CI action) # nix build .#nixosConfigurations.staging.config.system.build.toplevel
  2. # nixos-rebuild build --flake .#staging Note that nixosConfigurations prefix is ommitted if nixos-rebuild is used. The error messages differ and are somewhat more usable via nixos-rebuild command, although it lacks a -o flag, so you can’t build multiple results next to each other without manually renaming them between builds.

Building a qcow2 image

> Basic VM - Nix 4 Noobs

Flake example

This defines a system configuration called computer1, this configuration can be built on a NixOS system with the next command.

$ sudo nixos-rebuild switch --flake /path/to/flake#computer1

-> ./flake.nix

{
    description = "Simple nixOS flake";
    inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  
    outputs = { 
        self, 
        nixpkgs 
    }: {
        nixosConfigurations = {
            computer1 = nixpkgs.lib.nixosSystem {
                system = "x86_64-linux";
                specialArgs = {
                    # Inherit argument from let here, or define arguments.
                    #inherit argument; 
                    hostname = "computer1"; 
                };
                modules = [ 
                    ./hosts/computer1
                    # Add inputs here (like disko.nixosModules.disko)
                ];
                # Example how to pass an arg to configuration.nix:       
            };

            #computer2 = nixpkgs.lib.nixosSystem {
                #system = "x86_64-linux";
                # ...
            };
        };
    };
}

-> ./hosts/computer1/default.nix

{
    imports = [
        configuration.nix
        hardware-configuration.nix
    ];
}

-> ./hosts/computer1/configuration.nix:

{ config, pkgs, hostname, ... }: {

    networking.hostName = hostname;
    ...
}

flakes's People

Contributors

asynthe avatar

Watchers

 avatar

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.