Giter Club home page Giter Club logo

system's Introduction

Nix System Configuration

Build Status

This repository manages system configurations for all of my macOS, nixOS, and linux machines.

Structure

This repository is a flake. All system configurations are defined in flake.nix. Platorm specific configurations are found defined in the flake outputs darwinConfigurations, nixosConfigurations for macOS and NixOS respectively.

Overlapping Nix-Darwin and NixOS

Nix-Darwin and NixOS configurations share as much overlap as possible in the common module, ./modules/common.nix. Platform specific modules add onto the common module in ./modules/darwin/default.nix and ./modules/nixos/default.nix for macOS and NixOS respectively.

Decoupled Home Manager Configuration

My home-manager configuration is entirely decoupled from NixOS and nix-darwin configurations. This means that all of its modules are found in ./modules/home-manager. These modules are imported into all other configurations in the common module similarly to this:

{ config, pkgs, ... }: {
  home-manager.users.kclejeune = import ./home-manager/home.nix;
}

This means that home.nix is fully compatible as a standalone configuration, managed with the home-manager CLI. This allows close replication of any user config for any linux system running nix. These configurations are defined in the homeConfigurations output.

User Customization

User "profiles" are specified in ./profiles; these modules configure contextual, identity-specific settings such as SSL certificates or work vs. personal email addresses. When possible, home-manager functionality is extracted into ./profiles/home-manager, as mentioned previously

Installing a Configuration

Non-NixOS Prerequisite: Install Nix Package Manager

Run the installer script to perform a multi-user installation on darwin or linux:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

Note that this step is naturally skipped on NixOS since nix is the package manager by default.

System Bootstrapping

NixOS

Follow the installation instructions, then run

sudo nixos-install --flake github:kclejeune/system#phil

Darwin/Linux

Clone this repository into ~/.nixpkgs with

git clone https://github.com/kclejeune/system ~/.nixpkgs

You can bootstrap a new system with the bootstrap command:

nix run .#sysdo bootstrap

This will attempt to detect the host system and install nix-darwin or home-manager, but this behavior can be overridden using the --darwin or --home-manager flags.

sysdo CLI

The sysdo utility is a python script that wraps nix, darwin-rebuild, nixos-rebuild, and home-manager commands to provide a consistent interface across multiple platforms. It has some dependencies which are defined in the devShell flake output. Documentation for this tool is found in sysdo.md.

system's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar kclejeune avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

system's Issues

How to upgrade packages?

Hi @kclejeune, I hope you are doing well. I'm wondering what's your recommendation to upgrade the packages?

Here is what I did, but not sure it's right or wrong

nix flake update
nix build .#host
darwin-rebuild swith --flake .#host

And how about upgrade a single package only? For example I want to upgrade Neovim.

Nixos password hash

Hi Kennan,

First of all, thanks a lot for sharing your configuration. I started learning Nix just about a week ago and I'm learning a lot reading through it.

I was curious about your nixos module password. How did you get its hash here

Why I couldn't use relative path in home-manager module?

Hi, just came across your config from Reddit and I really like your code structure. I'm new about Nix and trying to simplify your config however I got the issue when building your setup. nix build complain that access path is forbidden at... in restricted mode
I fixed this after doing some research by using --impure argument. You can see it in the following link:
https://github.com/babygau/nix/blob/4d2ab96c65f02059d66a4cad4d71d297d045d46e/modules/home-manager/dotfiles.nix
Currently, I have dotfiles folder with nix inside which is a fork from your config. Atm, I couldn't use sth like ../../../alacritty. Could you please explain to me?

darwin-rebuild: command not found

Hi @kclejeune ,

Thanks for sharing your nix configuration, it is very nice config.
But after bootstrap on my MacBook with nix --extra-experimental-features "nix-command flakes" develop -c sysdo bootstrap --darwin MacBook, it works as expected.

but when I try to use sysdo switch MacBook after update my configuration, it will got this error.

❯ sysdo switch MacBook
> darwin-rebuild switch --flake .#MacBook --show-trace
sh: darwin-rebuild: command not found

To make it work , I need to run this in terminal manually

export PATH="/run/current-system/sw/bin:$PATH"
export PATH="/etc/profiles/per-user/aqua0210/bin:$PATH"

How do you make sysdo work without manually add PATH?

Can I use this to manage system configuration declaratively on Debian?

root@customer-portal:/root# history
    1  apt update
    2  apt-get upgrade
    3  apt-get dist-upgrade
    4  apt-get install nix
    6  sudo nano /etc/nix/nix.conf # add experimental-features = nix-command flakes
    7  sudo systemctl restart nix-daemon
    8  nix run nixpkgs#hello

After this, how would I make like a flake or a config file or whatever and be like "ok, I want to add a system user" and then use nix to deploy it/apply it? Or can I not do this because I'm not using NixOS?

`nix run .#sysdo bootstrap` + `darwin-rebuild` Errors

Hi, I'm new to nix and I just found your config - thanks for open sourcing it!

I'm trying your configs out on an M3 Macbook and I'm falling at the first hurdle...

I have modified flake.nix to change the username to my local username, but when I run nix run .#sysdo bootstrap it errors out with:

error: flake 'github:kclejeune/system' does not provide attribute 'packages.aarch64-darwin.darwinConfigurations.will@aarch64-darwin.config.system.build.toplevel', 'legacyPackages.aarch64-darwin.darwinConfigurations.will@aarch64-darwin.config.system.build.toplevel' or 'darwinConfigurations.will@aarch64-darwin.config.system.build.toplevel'

and

FileNotFoundError: [Errno 2] No such file or directory: './result/sw/bin/darwin-rebuild'

I am far from competent in nix at the moment, but I would have thought that the configurations would be for <username>@<hostname>, not <username>@<arch>. Should I have made some other modifications within flake.nix?

At the moment I'm just looking to get this up and running, then work my way through the config to customise it to my needs. Starting with a working config would make it a lot easier to learn than the current trial and error I've been going through over the last few days.

Full error:

error: flake 'github:kclejeune/system' does not provide attribute 'packages.aarch64-darwin.darwinConfigurations.will@aarch64-darwin.config.system.build.toplevel', 'legacyPackages.aarch64-darwin.darwinConfigurations.will@aarch64-darwin.config.system.build.toplevel' or 'darwinConfigurations.will@aarch64-darwin.config.system.build.toplevel'
$ ./result/sw/bin/darwin-rebuild switch --flake github:kclejeune/system#will@aarch64-darwin
Traceback (most recent call last):

  File "/nix/store/6c3arqnvmfr2r0p42c9k6vwzydliccmr-sysdo/bin/sysdo", line 331, in <module>
    app()

  File "/nix/store/6c3arqnvmfr2r0p42c9k6vwzydliccmr-sysdo/bin/sysdo", line 137, in bootstrap
    run_cmd(

  File "/nix/store/6c3arqnvmfr2r0p42c9k6vwzydliccmr-sysdo/bin/sysdo", line 72, in run_cmd
    else subprocess.run(cmd, shell=False)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/nix/store/kqsqlfvvr4gr3q83vl43gprk47rbsc5d-python3-3.11.9/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/nix/store/kqsqlfvvr4gr3q83vl43gprk47rbsc5d-python3-3.11.9/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,

  File "/nix/store/kqsqlfvvr4gr3q83vl43gprk47rbsc5d-python3-3.11.9/lib/python3.11/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)

FileNotFoundError: [Errno 2] No such file or directory: './result/sw/bin/darwin-rebuild'

`home.packages` vs `users.packages`

Hi @kclejeune, today I got sometimes to learn me some Nix. Pretty happy with my current config based on yours. Thank you so much for that. However, my today question is, I see you use home-manager to manage user installed packages home.packages = with pkgs; [...];. What make it different from users.users.{name}.packages?

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.