Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yuyatinnefeld/nix
https://github.com/yuyatinnefeld/nix
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/yuyatinnefeld/nix
- Owner: yuyatinnefeld
- Created: 2024-06-20T14:27:44.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-28T07:58:51.000Z (5 months ago)
- Last Synced: 2024-07-28T09:05:42.604Z (5 months ago)
- Language: Nix
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nix
## Install
To install Nix, run the following command:
```bash
sh <(curl -L https://nixos.org/nix/install)
```## Clean Up
To clean up the Nix store and free up space, run:
```bash
nix-store --gc
nix-collect-garbage
```## Search Packages
To search for packages in the Nixpkgs repository, use:
```bash
nix search nixpkgs
nix search nixpkgs hyperkit
nix search nixpkgs colima
```## Build and Run
To build and run a package:
```bash
# Build the package (creating a file in /nix/store/xxxx-nix-shell.drv which is used for nix-shell)
nix-build packages/all.nix# run the package
nix-shell packages/all.nix# clean up
nix-shell --pure packages/all.nix
```## nix-shell
### Temporary shell
```bash
nix-shell -p git nodejs
``````bash
[nix-shell:~/desktop/projects/github/my-nix]$ which git
/nix/store/5hkhxkqzwyak9ji766885jm98pgkxxjx-git-2.45.1/bin/git[nix-shell:~/desktop/projects/github/my-nix]$ which npm
/nix/store/gxi71m2y8x1rl83dpr1g0x9yz3klrcb0-nodejs-20.12.2/bin/npm[nix-shell:~/desktop/projects/github/my-nix]$ git --version
git version 2.45.1[nix-shell:~/desktop/projects/github/my-nix]$ npm --version
10.5.0# free up some disk space
nix-collect-garbage[nix-shell:~/desktop/projects/github/my-nix]$ git --version
bash: /nix/store/5hkhxkqzwyak9ji766885jm98pgkxxjx-git-2.45.1/bin/git: No such file or directory[nix-shell:~/desktop/projects/github/my-nix]$ npm
bash: /nix/store/gxi71m2y8x1rl83dpr1g0x9yz3klrcb0-nodejs-20.12.2/bin/npm: No such file or directory
```### Declarative Shell
```bash
nix-shell packages/shell.nix
``````bash
[nix-shell:~/desktop/projects/github/my-nix]$ git --version
git version 2.42.2[nix-shell:~/desktop/projects/github/my-nix]$ which git
/nix/store/w8wgxggkw1g9hkg9l1na0vh5379jfk2k-git-2.42.2/bin/git
```## Evaluate Nix expressions interactively
```bash
[nix-shell:~/desktop/projects/github/my-nix]$ nix repl
Nix 2.23.0
Type :? for help.
nix-repl> let
x = 1;
y = 2;
in x + y
3nix-repl> "say hello"
"say hello"nix-repl> data = 1
nix-repl> data
# escape
nix-repl> :q
```## Nix Flake
### Install Home Manager
```bash
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-channel list
```### Create flake.nix
```bash
nix flake init
wrote: /Users//.config/flake.nix
```### Create config file
```bash
mkdir -p ~/.config/nix
echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf
```### Update Flake file
```bash
vi /.config/flake.nix
vi /.config/packages.nix
```### Build & Run Flake
```bash
nix build
nix develop
```