Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matejamaric/nix-setup
My Nix Flake configuration
https://github.com/matejamaric/nix-setup
nix nix-darwin nix-flake
Last synced: 2 months ago
JSON representation
My Nix Flake configuration
- Host: GitHub
- URL: https://github.com/matejamaric/nix-setup
- Owner: MatejaMaric
- License: gpl-3.0
- Created: 2023-11-27T11:07:33.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-20T08:53:13.000Z (3 months ago)
- Last Synced: 2024-11-20T10:47:12.610Z (3 months ago)
- Topics: nix, nix-darwin, nix-flake
- Language: Nix
- Homepage:
- Size: 179 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## How to use:
### MacOS:
First build the Nix Flake:
```bash
nix build --extra-experimental-features "nix-command flakes" .#darwinConfigurations.Matejas-MacBook-Pro.system
```Then use the produced result directory (symlink) to switch into the configuration for the first time:
```bash
./result/sw/bin/darwin-rebuild switch --flake ~/nix-setup
```Every time you change something you can just use this command, just don't forget to stage or commit the changes with Git:
```bash
darwin-rebuild switch --flake ~/nix-setup/.#
```### NixOS:
This command is all you need:
```bash
sudo nixos-rebuild switch --flake ~/nix-setup/.#
```### Server VM (testing):
Sadly, using this command you can build VMs only for Linux. Building VMs on MacOS (especially on M1) is to much of a hassle for me personally.
```bash
nixos-rebuild build-vm --flake .#server
./result/bin/run-server-vm
```You can SSH into a VM using:
```bash
ssh -p 50000 localhost
```You might want do delete the state of the previous VM instance:
```bash
rm server.qcow2
```## How to update packages:
You can update the flake using this command, which is going to update the flake lock file:
```bash
nix flake update
```After than you can update the system itself by switching into the flake with
`nixos-rebuild switch` or `darwin-rebuild switch` depending on the platform you
use.You can also use this, if you are feeling too lazy to commit the changes yourself:
```
nix flake update --commit-lock-file
```## How to update a single flake input:
Here's an example for updating `matejasblog` package:
```bash
nix flake lock --update-input matejasblog
```## How to optimise storage:
List all of the available generations:
```bash
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
```Remove all but the current generation:
```bash
sudo nix-collect-garbage -d
```Garbage collect unneeded entires:
```bash
nix-store --gc
```Optimise the store by manually running the command (potentially long operation):
```bash
sudo nix-store --optimise
```
For more checkout the [documentation](https://nixos.wiki/wiki/Storage_optimization).