Giter VIP home page Giter VIP logo

nixos-config's Introduction

nixos-config

My NixOS, nix-darwin and Home Manager configurations.

Structure

I use NixOS inside of a Parallels VM on a M1 Mac running macOS. In addition to this, I use nix-darwin to configure macOS with nix-darwin. Both of these setups also use Home Manager. These configurations share the same modules/ and home-modules/.

Modules

There are two kinds of modules:

  1. modules/, which define NixOS or nix-darwin level options.
  2. home-modules/, which define Home Manager options on both NixOS and macOS.

Configuration generating functions

The modules mentioned above are imported inside of two configuration generation functions:

  1. ./nixos.nix, this function generates a nixosConfiguration
  2. ./darwin.nix, this function generates a darwinConfiguration

These fucntions are used in ./flake.nix's nixosConfigurations and darwinConfigurations

How to fork this configuration for your own usage

NOTE: These instructions are out of date

  1. Do a project-wide search of my username, cor and replace it with your_username. Be careful not to replace things that are not my username, such as "core".
  2. In ./nixos.nix, replace the value of hashedPassword with one you've generated with mkpasswd -m sha-512 See here for more info.
  3. In ./programs/git.nix, change userName and extraConfig.github.user to your GitHub username. Also change signing.key to the public GPG key you use for your GitHub account.

macOS Nix config with nix-darwin

NOTE: macOS Nix config is not required for setting up the NixOS VM. For instructions on this, check the next section

Make sure not to install Homebrew or Xcode Command Line Tools!

  1. Do a clean install macOS, deny analytics.
  2. Install Nix on macOS with the installer
  3. In ~, execute nix-shell -p git --command "git clone https://github.com/cor/nixos-config"
  4. Install nix-darwin with the nix-darwin installer.
  5. Restart Terminal.app
  6. sudo mv /etc/nix/nix.conf /etc/nix/nix.conf.original
  7. In ~/nixos-config, execute nix-shell --no-sandbox -p cmake --command "make switch-darwin"
  8. Download 1Password and browser extension
  9. From 1Password, download SSH keys: id_ed25519 and id_ed25519.pub. Move them to ~/.ssh~
  10. From 1Password, download GPG keys: secret-key-backup.asc. Import them with: gpg --import ./secret-key-backup.asc. Afterwards, run rm ./secret-key-backup.asc
  11. From 1Password, download GPG trust-db-backup.txt. Import them with: gpg --import-ownertrust < ./trustdb-backup.txt, Afterwards, run rm ./trustdb-backup.txt
  12. Open Safari, go to Settings > Search > Search Engine. Select DuckDuckGo. Go to Settings > Advanced > Smart Search Field, click "Show full ewbsite address". Go to Settings > Advanced, at the bottom click "Show Develop menu in menu bar"
  13. Open Settings.app, Go to Desktop & Dock > Show recent applications in Dock and disable it
  14. Remove all apps from dock, turn hide dock on

NixOS VM using UTM

  1. Install UTM from the Mac App Store
  2. Download a minimal 64-bit ARM ISO from the NixOS download page.
  3. Open UTM, Create a new Linux VM, Use Apple Virutalization & Enable Rosetta
  4. Select your nixos-minimal-...-aarch64-linux.iso
  5. Hardware:
  • CPU: 8 cores
  • RAM: 22528 MB
  1. configure login
  • sudo su
  • passwd (set to root)
  1. get machine ip: ip -brief address

NixOS VM using Parallels Desktop

  1. Install Parallels Desktop.
  2. Download a minimal 64-bit ARM ISO from the NixOS download page.
  3. In parallels: click "Install Windows or another OS from a DVD or image file"
  4. Select your nixos-minimal-...-aarch64-linux.iso
  5. Select "Other Linux"
  6. In Name, type "NixOS"
  7. Click "Customize settings before installation"
  8. Go to "Hardware"
  • CPU & Memory:
    • Processors: N - 2 cores where N is your core count (I have 10, so I pick 8)
    • Memory N - 8 GB where N is your GB count (I have 32, so I pick 24)
  • Graphics:
    • Resolution: More Space
    • Advanced > Ensure "Enable 3D acceleration" is enabled.
  • Mouse & Keyboard:
    • Click "Open Shortcuts Preferences" and uncheck all shortcuts.
    • Click "macOS System Shortcuts" in the sidebar, and change "Send macOS system shortcuts" to "always"
  • Shared Printers: uncheck "share mac printers with other linux"
  • Network: Source: Shared Network (Should be selected by default)
  • Hard Disk: Click Advanced > Properties. Select Size 256 GB. (More if you can, but I currently have just 1TB of storage)
  1. Boot the VM, you may have to re-attach the ISO by clicking the CD icon and rebooting.
  2. In the VM, type sudo su, then passwd, and type root twice.
  3. In the VM, type ip -brief address in order to see your VM's IP.
  4. On your Mac in this repository, type export NIXADDR=10.211.55.3 (replace the IP with the IP you found in step 11).
  5. On your Mac, in the same shell, type make vm/bootstrap0 When prompted for the root password, type root
  6. Your VM will reboot automtaically by this
  7. On your Mac, in the same shell, type make vm/bootstrap. (note that there's no 0 at the end this time)
  8. On your Mac, in the same shell, type make vm/secrets.
  9. Reboot your VM by typing reboot.
  10. Log into your VM
  11. In ~, run git clone [email protected]:cor/nixos-config
  12. Enter your SSH password (stored in 1Password)
  13. Run cd nixos-config && make switch
  14. reboot
  15. Open chromium, go to chrome://settings/cookies, and disable "Clear cookies and site data when you close all windows"
  16. Go to chrome://settings/search and set search engine to "DuckDuckGo"

You now have your VM fully set up! To make changes to the config, just edit the contenst ~/nixos-config, and run make switch


Config is partially based on https://github.com/mitchellh/nixos-config

nixos-config's People

Contributors

cor avatar qlp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nixos-config's Issues

Final bootstrap fails with installing 1Password extension

The final make vm/bootstrap fails with the following:

error: hash mismatch in file downloaded from 'https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&prodversion=107&x=id%3Daeblfdkhhhdcdjpifhhbdiojplfjncoa%26installsource%3Dondemand%26uc':
         specified: sha256:0ccvpi88s3c1psb5ipkz4cch89ib6h3g9nw8qbxzwvnzh72qg8rl
         got:       sha256:0s024whdj37hbghjqq4qazn5cm77crlp0pqwgacnfm7vfqwxyq12

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.