Skip to content
Snippets Groups Projects
Commit 24be8e69 authored by fpamberger's avatar fpamberger
Browse files
parents f3ec6717 fe8112f6
No related branches found
No related tags found
No related merge requests found
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
- Easier to change, manage and maintain the configuration - Easier to change, manage and maintain the configuration
- Easier to back up and share with people - Easier to back up and share with people
- Easy to deploy machines and their configuration - Easy to deploy machines and their configuration
- Out of the box Rollbacks. - Out of the box Rollbacks
- Configuration options for many programs & services - Configuration options for many programs & services
- Free of side effects - Actually uninstalls packages and their dependencies - Free of side effects - Actually uninstalls packages and their dependencies
- Easy to set up VMs - Easy to set up VMs
...@@ -103,16 +103,38 @@ a ...@@ -103,16 +103,38 @@ a
true true
``` ```
]) ])
=== let ... in
assign values and use them in a single expression
```nix
> let
a = 4;
in
a + a;
8
```
=== Attribute sets: === Attribute sets:
- collection of name-value pairs - collection of name-value pairs
#columns(2, [
```nix ```nix
> {a = 1; b = "2"; c = 3.0;} > {a = 1; b = "2"; c = 3.0;}
{ {
a = 1; a = 1;
b = "2"; b = "2";
c = 3; c = 3;
}``` }
```
#colbreak()
access values in an attribute set:
```nix
> let
a ={b = 2; c = "a";}
in
toString a.b + a.c
"2a"
```
])
=== Nix is lazy! === Nix is lazy!
```nix ```nix
> {a = {lazy = 5;}; b = "2"; c = 3.0;} > {a = {lazy = 5;}; b = "2"; c = 3.0;}
...@@ -174,6 +196,8 @@ addtwo 3 ...@@ -174,6 +196,8 @@ addtwo 3
``` ```
]) ])
=== Functions, a bit more in depth: === Functions, a bit more in depth:
#columns(2, [
Function which returns a function: Function which returns a function:
```nix ```nix
> add = a: b: a + b > add = a: b: a + b
...@@ -184,6 +208,16 @@ Function which returns a function: ...@@ -184,6 +208,16 @@ Function which returns a function:
b: 3 + b b: 3 + b
``` ```
`a` is being replaced by 3. `a` is being replaced by 3.
#colbreak()
They can take attribute sets too!
```nix
> let
f = {a, b, c ? 3, ...}: a + b + c;
in
f {a =1; b = 2; d = "Hi!"}
6
```
])
= Nix derivations = Nix derivations
== A simple bash script == A simple bash script
#columns(2, [ #columns(2, [
...@@ -469,7 +503,6 @@ in ...@@ -469,7 +503,6 @@ in
- have what-is-my-ip installed! - have what-is-my-ip installed!
])]) ])])
]) ])
// https://fzakaria.com/2024/07/05/learn-nix-the-fun-way.html
= NixOS = NixOS
== What is NixOS? == What is NixOS?
...@@ -673,7 +706,7 @@ flake.lock flake.nix result what-is-my-ip.nix ...@@ -673,7 +706,7 @@ flake.lock flake.nix result what-is-my-ip.nix
total 16 total 16
-rw-r--r-- 1 cr users 567 Oct 30 18:34 flake.lock -rw-r--r-- 1 cr users 567 Oct 30 18:34 flake.lock
-rw-r--r-- 1 cr users 312 Oct 30 18:34 flake.nix -rw-r--r-- 1 cr users 312 Oct 30 18:34 flake.nix
lrwxrwxrwx 1 cr users 57 Oct 30 18:35 result -> /nix/store/hysmspp11fxnkgjsp032q9zinl1gdk5n-what-is-my-ip/ lrwxrwxrwx 1 cr users 57 Oct 30 18:35 result -> /nix/store/5jf23xp5nmqw8vhrjpgvbimrvd086v6z-what-is-my-ip/
-rw-r--r-- 1 cr users 247 Oct 30 18:34 what-is-my-ip.nix -rw-r--r-- 1 cr users 247 Oct 30 18:34 what-is-my-ip.nix
``` ```
- Symlink to the location of the build package in the nix store - Symlink to the location of the build package in the nix store
...@@ -718,9 +751,8 @@ size: 15pt, ...@@ -718,9 +751,8 @@ size: 15pt,
- Keep track of all inputs, lock them - Keep track of all inputs, lock them
- version-control your dependencies - version-control your dependencies
- something broken after a `nix flake update`? \ - something broken after a `nix flake update`? \
switch back to the latest commit $==>$ go back back a commit
- provide packages easily - provide packages easily
- I can expose my sys
== NixOS flake structure == NixOS flake structure
#columns(1)[ #columns(1)[
...@@ -1227,3 +1259,8 @@ content = { ...@@ -1227,3 +1259,8 @@ content = {
== Sources == Sources
- https://cohost.org/leftpaddotpy/post/798893-rechosting-a-banger - https://cohost.org/leftpaddotpy/post/798893-rechosting-a-banger
- https://nix.dev/tutorials/nix-language
- https://github.com/danth/stylix
- https://github.com/nix-community/disko
- https://github.com/NotAShelf/nvf
- https://fzakaria.com/2024/07/05/learn-nix-the-fun-way
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment