Compare commits
1 Commits
wireguard
...
kubernetes
Author | SHA1 | Date | |
---|---|---|---|
a8ca3653b4 |
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
**/wallpapers/*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||||
|
**/wallpapers/*.png filter=lfs diff=lfs merge=lfs -text
|
1
.gitmodules
vendored
1
.gitmodules
vendored
@@ -2,6 +2,7 @@
|
|||||||
path = submodules/nixpkgs
|
path = submodules/nixpkgs
|
||||||
url = git@github.com:karaolidis/nixpkgs.git
|
url = git@github.com:karaolidis/nixpkgs.git
|
||||||
branch = integration
|
branch = integration
|
||||||
|
|
||||||
[submodule "submodules/home-manager"]
|
[submodule "submodules/home-manager"]
|
||||||
path = submodules/home-manager
|
path = submodules/home-manager
|
||||||
url = git@github.com:karaolidis/home-manager.git
|
url = git@github.com:karaolidis/home-manager.git
|
||||||
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"sops.defaults.ageKeyFile": "./secrets/personal/key.txt"
|
|
||||||
}
|
|
10
README.md
10
README.md
@@ -7,7 +7,6 @@ NixOS dotfiles and configuration for various hosts and users.
|
|||||||
- [`flake.lock`](./flake.lock) and [`flake.nix`](./flake.nix): Core Nix flake files defining the repository's dependencies and entry points.
|
- [`flake.lock`](./flake.lock) and [`flake.nix`](./flake.nix): Core Nix flake files defining the repository's dependencies and entry points.
|
||||||
|
|
||||||
- [`hosts/`](./hosts): All host-specific configurations.
|
- [`hosts/`](./hosts): All host-specific configurations.
|
||||||
|
|
||||||
- [`common/`](./hosts/common): Shared configuration definitions.
|
- [`common/`](./hosts/common): Shared configuration definitions.
|
||||||
- [`shells/`](./hosts/common/shells): Nix dev shells.
|
- [`shells/`](./hosts/common/shells): Nix dev shells.
|
||||||
- [`configs/`](./hosts/common/configs): System configurations applicable to all hosts.
|
- [`configs/`](./hosts/common/configs): System configurations applicable to all hosts.
|
||||||
@@ -17,12 +16,9 @@ NixOS dotfiles and configuration for various hosts and users.
|
|||||||
- [`gui/`](./hosts/common/configs/user/gui): GUI-related settings.
|
- [`gui/`](./hosts/common/configs/user/gui): GUI-related settings.
|
||||||
- `<name>/`: Individual host configurations.
|
- `<name>/`: Individual host configurations.
|
||||||
|
|
||||||
- [`packages/`](./packages/): Custom packages.
|
|
||||||
|
|
||||||
- `secrets/<namespace>/`: Global secrets for individual namespaces that apply across all hosts.
|
- `secrets/<namespace>/`: Global secrets for individual namespaces that apply across all hosts.
|
||||||
|
|
||||||
- [`lib/`](./lib): Nix library function definitions and utilities.
|
- [`lib/`](./lib): Nix library function definitions and utilities.
|
||||||
|
|
||||||
- [`scripts/`](./lib/scripts): Utility scripts for managing the repository.
|
- [`scripts/`](./lib/scripts): Utility scripts for managing the repository.
|
||||||
- [`add-host.sh`](./lib/scripts/add-host.sh): Instantiate the keys for a new host configuration.
|
- [`add-host.sh`](./lib/scripts/add-host.sh): Instantiate the keys for a new host configuration.
|
||||||
- [`remove-host.sh`](./lib/scripts/remove-host.sh): Remove references to a host.
|
- [`remove-host.sh`](./lib/scripts/remove-host.sh): Remove references to a host.
|
||||||
@@ -38,9 +34,7 @@ Any `options.nix` files create custom option definitions when present.
|
|||||||
Below is a table of all hosts, with links to their respective README files, which may provide further details and/or post-installation checklists.
|
Below is a table of all hosts, with links to their respective README files, which may provide further details and/or post-installation checklists.
|
||||||
|
|
||||||
| Host | README |
|
| Host | README |
|
||||||
| ------------- | ------------------------------------------------------------ |
|
|-------------|----------------------------------------------------------|
|
||||||
| `installer` | [hosts/installer/README.md](./hosts/installer/README.md) |
|
| `installer` | [hosts/installer/README.md](./hosts/installer/README.md) |
|
||||||
| `himalia` | [hosts/himalia/README.md](./hosts/himalia/README.md) |
|
| `eirene` | [hosts/eirene/README.md](./hosts/eirene/README.md) |
|
||||||
| `elara` | [hosts/elara/README.md](./hosts/elara/README.md) |
|
| `elara` | [hosts/elara/README.md](./hosts/elara/README.md) |
|
||||||
| `jupiter` | [hosts/jupiter/README.md](./hosts/jupiter/README.md) |
|
|
||||||
| `jupiter-vps` | [hosts/jupiter-vps/README.md](./hosts/jupiter-vps/README.md) |
|
|
||||||
|
104
flake.lock
generated
104
flake.lock
generated
@@ -10,16 +10,15 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1744557573,
|
"lastModified": 1736090999,
|
||||||
"narHash": "sha256-XAyj0iDuI51BytJ1PwN53uLpzTDdznPDQFG4RwihlTQ=",
|
"narHash": "sha256-B5CJuHqfJrzPa7tObK0H9669/EClSHpa/P7B9EuvElU=",
|
||||||
"owner": "aylur",
|
"owner": "aylur",
|
||||||
"repo": "ags",
|
"repo": "ags",
|
||||||
"rev": "3ed9737bdbc8fc7a7c7ceef2165c9109f336bff6",
|
"rev": "5527c3c07d92c11e04e7fd99d58429493dba7e3c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "aylur",
|
"owner": "aylur",
|
||||||
"ref": "main",
|
|
||||||
"repo": "ags",
|
"repo": "ags",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
@@ -31,16 +30,15 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749559749,
|
"lastModified": 1736497508,
|
||||||
"narHash": "sha256-TM95tg1G7S6rVBBoMwurXMz8Il4xlnuZ2TI4h6lfZzg=",
|
"narHash": "sha256-murrCQMYKtZ8rkZ5O726ZCsCDee1l3ZdmV8yC9gRaIc=",
|
||||||
"owner": "aylur",
|
"owner": "aylur",
|
||||||
"repo": "astal",
|
"repo": "astal",
|
||||||
"rev": "dd8a4662f2f17fb4326a7bd0fb2d054f5d477ba3",
|
"rev": "ef4f95608481414053ecdbe4de29bd86fb452813",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "aylur",
|
"owner": "aylur",
|
||||||
"ref": "main",
|
|
||||||
"repo": "astal",
|
"repo": "astal",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
@@ -52,20 +50,35 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749436314,
|
"lastModified": 1736437680,
|
||||||
"narHash": "sha256-CqmqU5FRg5AadtIkxwu8ulDSOSoIisUMZRLlcED3Q5w=",
|
"narHash": "sha256-9Sy17XguKdEU9M5peTrkWSlI/O5IAqjHzdzxbXnc30g=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"rev": "dfa4d1b9c39c0342ef133795127a3af14598017a",
|
"rev": "4d5d07d37ff773338e40a92088f45f4f88e509c8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"ref": "master",
|
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"flake-compat": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1733328505,
|
||||||
|
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "edolstra",
|
||||||
|
"repo": "flake-compat",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-parts": {
|
"flake-parts": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs-lib": [
|
"nixpkgs-lib": [
|
||||||
@@ -103,7 +116,6 @@
|
|||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"ref": "main",
|
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
@@ -115,11 +127,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749678254,
|
"lastModified": 1736504054,
|
||||||
"narHash": "sha256-6I+qez0MnHu9M2spLj3LsGA/cUGgfx17/hMPvmrUMoU=",
|
"narHash": "sha256-Mb0aIdOIg5ge0Lju1zogdAcfklRciR8G0NY6R423oek=",
|
||||||
"owner": "karaolidis",
|
"owner": "karaolidis",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "e248f54290b483a47c7550f69faecb8ed97e4831",
|
"rev": "baa0e7a14088ff1ed891afe4c6457faf40aa30a6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -131,11 +143,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749678247,
|
"lastModified": 1738150270,
|
||||||
"narHash": "sha256-K83Q3c/o5CdMB3Npk3P1kCIz6FcUuJV8E4k6z1YN8AQ=",
|
"narHash": "sha256-GkH7I9LW0aFklGc3YxjaBW7TtJy5aWHE0rPBUuz35Hk=",
|
||||||
"owner": "karaolidis",
|
"owner": "karaolidis",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "4d408c92fe165ab68f012a3fa36d4c58d84e83bd",
|
"rev": "e8e18ef6309d021fa600f5aa2665963d8cf76ab7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -151,41 +163,22 @@
|
|||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"treefmt-nix": [
|
"treefmt-nix": "treefmt-nix"
|
||||||
"treefmt-nix"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749675110,
|
"lastModified": 1736500613,
|
||||||
"narHash": "sha256-NkDE/JyeQJmLtpXjyFZK2wKs5K7isap7MBIzoYMC9nk=",
|
"narHash": "sha256-OCEXlRyOIMzxrhmnzoX32e241A7+Z+zsuyR7i6AG608=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "NUR",
|
"repo": "NUR",
|
||||||
"rev": "0e8328c18d801a253ed5dfd17bd78254d9669d06",
|
"rev": "d51e847f68700c38f850a62c2b3e728864a38cde",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"ref": "main",
|
|
||||||
"repo": "NUR",
|
"repo": "NUR",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"quadlet-nix": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1749099346,
|
|
||||||
"narHash": "sha256-5gi/YaLVsFztGvVH45eB6jsBmZf+HnvDeSA9RXUqbcY=",
|
|
||||||
"owner": "SEIAROTg",
|
|
||||||
"repo": "quadlet-nix",
|
|
||||||
"rev": "d4119a3423f938427252ba8bbdbe8ce040751864",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "SEIAROTg",
|
|
||||||
"ref": "main",
|
|
||||||
"repo": "quadlet-nix",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"ags": "ags",
|
"ags": "ags",
|
||||||
@@ -195,11 +188,9 @@
|
|||||||
"home-manager": "home-manager",
|
"home-manager": "home-manager",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"nur": "nur",
|
"nur": "nur",
|
||||||
"quadlet-nix": "quadlet-nix",
|
|
||||||
"sops-nix": "sops-nix",
|
"sops-nix": "sops-nix",
|
||||||
"spicetify-nix": "spicetify-nix",
|
"spicetify-nix": "spicetify-nix",
|
||||||
"systems": "systems",
|
"systems": "systems"
|
||||||
"treefmt-nix": "treefmt-nix"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sops-nix": {
|
"sops-nix": {
|
||||||
@@ -209,22 +200,22 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749592509,
|
"lastModified": 1736203741,
|
||||||
"narHash": "sha256-VunQzfZFA+Y6x3wYi2UE4DEQ8qKoAZZCnZPUlSoqC+A=",
|
"narHash": "sha256-eSjkBwBdQk+TZWFlLbclF2rAh4JxbGg8az4w/Lfe7f4=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "50754dfaa0e24e313c626900d44ef431f3210138",
|
"rev": "c9c88f08e3ee495e888b8d7c8624a0b2519cb773",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"ref": "master",
|
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"spicetify-nix": {
|
"spicetify-nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"flake-compat": "flake-compat",
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
@@ -233,16 +224,15 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749357231,
|
"lastModified": 1736482561,
|
||||||
"narHash": "sha256-AbrPgGFVYR45TlYLHYTppayG0xzOG9XXhi+1j3Klbw8=",
|
"narHash": "sha256-f4hvN4MF26NIYeFA/H1sVW6KU5X9/jy9l95WrMsNUIU=",
|
||||||
"owner": "Gerg-L",
|
"owner": "Gerg-L",
|
||||||
"repo": "spicetify-nix",
|
"repo": "spicetify-nix",
|
||||||
"rev": "03783416f7416715c52166d4e8ba0492a7149397",
|
"rev": "77fb1ae39e0f5c60a7d0bd6ce078b9c56e3356cb",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "Gerg-L",
|
"owner": "Gerg-L",
|
||||||
"ref": "master",
|
|
||||||
"repo": "spicetify-nix",
|
"repo": "spicetify-nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
@@ -266,20 +256,20 @@
|
|||||||
"treefmt-nix": {
|
"treefmt-nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
|
"nur",
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1749194973,
|
"lastModified": 1733222881,
|
||||||
"narHash": "sha256-eEy8cuS0mZ2j/r/FE0/LYBSBcIs/MKOIVakwHVuqTfk=",
|
"narHash": "sha256-JIPcz1PrpXUCbaccEnrcUS8jjEb/1vJbZz5KkobyFdM=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"rev": "a05be418a1af1198ca0f63facb13c985db4cb3c5",
|
"rev": "49717b5af6f80172275d47a418c9719a31a78b53",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"ref": "main",
|
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
106
flake.nix
106
flake.nix
@@ -32,20 +32,12 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
disko = {
|
disko = {
|
||||||
type = "github";
|
url = "github:nix-community/disko";
|
||||||
owner = "nix-community";
|
|
||||||
repo = "disko";
|
|
||||||
ref = "master";
|
|
||||||
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
sops-nix = {
|
sops-nix = {
|
||||||
type = "github";
|
url = "github:Mic92/sops-nix";
|
||||||
owner = "Mic92";
|
|
||||||
repo = "sops-nix";
|
|
||||||
ref = "master";
|
|
||||||
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,57 +49,22 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
nur = {
|
nur = {
|
||||||
type = "github";
|
url = "github:nix-community/NUR";
|
||||||
owner = "nix-community";
|
|
||||||
repo = "NUR";
|
|
||||||
ref = "main";
|
|
||||||
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.follows = "nixpkgs";
|
|
||||||
treefmt-nix.follows = "treefmt-nix";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
flake-utils = {
|
|
||||||
type = "github";
|
|
||||||
owner = "numtide";
|
|
||||||
repo = "flake-utils";
|
|
||||||
ref = "main";
|
|
||||||
|
|
||||||
inputs.systems.follows = "systems";
|
|
||||||
};
|
|
||||||
|
|
||||||
treefmt-nix = {
|
|
||||||
type = "github";
|
|
||||||
owner = "numtide";
|
|
||||||
repo = "treefmt-nix";
|
|
||||||
ref = "main";
|
|
||||||
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
quadlet-nix = {
|
flake-utils = {
|
||||||
type = "github";
|
url = "github:numtide/flake-utils";
|
||||||
owner = "SEIAROTg";
|
inputs.systems.follows = "systems";
|
||||||
repo = "quadlet-nix";
|
|
||||||
ref = "main";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
astal = {
|
astal = {
|
||||||
type = "github";
|
url = "github:aylur/astal";
|
||||||
owner = "aylur";
|
|
||||||
repo = "astal";
|
|
||||||
ref = "main";
|
|
||||||
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
ags = {
|
ags = {
|
||||||
type = "github";
|
url = "github:aylur/ags";
|
||||||
owner = "aylur";
|
|
||||||
repo = "ags";
|
|
||||||
ref = "main";
|
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.follows = "nixpkgs";
|
nixpkgs.follows = "nixpkgs";
|
||||||
astal.follows = "astal";
|
astal.follows = "astal";
|
||||||
@@ -115,11 +72,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
spicetify-nix = {
|
spicetify-nix = {
|
||||||
type = "github";
|
url = "github:Gerg-L/spicetify-nix";
|
||||||
owner = "Gerg-L";
|
|
||||||
repo = "spicetify-nix";
|
|
||||||
ref = "master";
|
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.follows = "nixpkgs";
|
nixpkgs.follows = "nixpkgs";
|
||||||
systems.follows = "systems";
|
systems.follows = "systems";
|
||||||
@@ -137,9 +90,9 @@
|
|||||||
specialArgs = { inherit inputs system; };
|
specialArgs = { inherit inputs system; };
|
||||||
};
|
};
|
||||||
|
|
||||||
himalia = nixpkgs.lib.nixosSystem rec {
|
eirene = nixpkgs.lib.nixosSystem rec {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = [ ./hosts/himalia ];
|
modules = [ ./hosts/eirene ];
|
||||||
specialArgs = { inherit inputs system; };
|
specialArgs = { inherit inputs system; };
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -148,37 +101,26 @@
|
|||||||
modules = [ ./hosts/elara ];
|
modules = [ ./hosts/elara ];
|
||||||
specialArgs = { inherit inputs system; };
|
specialArgs = { inherit inputs system; };
|
||||||
};
|
};
|
||||||
|
|
||||||
jupiter = nixpkgs.lib.nixosSystem rec {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
modules = [ ./hosts/jupiter ];
|
|
||||||
specialArgs = { inherit inputs system; };
|
|
||||||
};
|
|
||||||
|
|
||||||
jupiter-vps = nixpkgs.lib.nixosSystem rec {
|
|
||||||
system = "x86_64-linux";
|
|
||||||
modules = [ ./hosts/jupiter-vps ];
|
|
||||||
specialArgs = { inherit inputs system; };
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// inputs.flake-utils.lib.eachSystem [ "x86_64-linux" ] (
|
// inputs.flake-utils.lib.eachDefaultSystem (
|
||||||
system:
|
system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
inherit system;
|
|
||||||
config.allowUnfree = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
treefmt = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells = import ./hosts/common/shells { inherit pkgs; };
|
devShells = {
|
||||||
lib = import ./lib { inherit pkgs; };
|
bun = import ./hosts/common/shells/bun { inherit pkgs; };
|
||||||
packages = import ./packages { inherit pkgs inputs system; };
|
c = import ./hosts/common/shells/c { inherit pkgs; };
|
||||||
|
go = import ./hosts/common/shells/go { inherit pkgs; };
|
||||||
|
java = import ./hosts/common/shells/java { inherit pkgs; };
|
||||||
|
nix = import ./hosts/common/shells/nix { inherit pkgs; };
|
||||||
|
nodejs = import ./hosts/common/shells/nodejs { inherit pkgs; };
|
||||||
|
python = import ./hosts/common/shells/python { inherit pkgs; };
|
||||||
|
};
|
||||||
|
|
||||||
formatter = treefmt.config.build.wrapper;
|
formatter = pkgs.nixfmt-rfc-style;
|
||||||
checks.formatting = treefmt.config.build.check self;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
4
hosts/.gitignore
vendored
4
hosts/.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
**/secrets/ssh_host_ed25519_key
|
*/secrets/ssh_host_ed25519_key
|
||||||
**/secrets/.decrypted~*
|
*/secrets/.decrypted~*
|
||||||
|
16
hosts/common/configs/system/backup/backup.completion.zsh
Normal file
16
hosts/common/configs/system/backup/backup.completion.zsh
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
_backup_completion() {
|
||||||
|
local options=(
|
||||||
|
'-m[Partition to mount for backup]:partition:($(_partitions))'
|
||||||
|
'-b[Backup directory]:backup directory:_files -/'
|
||||||
|
)
|
||||||
|
local curcontext="$curcontext" state line
|
||||||
|
typeset -A opt_args
|
||||||
|
|
||||||
|
_partitions() {
|
||||||
|
lsblk -rno NAME | sed 's/^/\/dev\//'
|
||||||
|
}
|
||||||
|
|
||||||
|
_arguments -s $options
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _backup_completion backup
|
64
hosts/common/configs/system/backup/backup.sh
Normal file
64
hosts/common/configs/system/backup/backup.sh
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
if [[ "$EUID" -ne 0 ]]; then
|
||||||
|
echo "Please run the script as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [-m partition] [-b backup_location]"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
if [ -d "/persist.bak" ]; then btrfs -q subvolume delete "/persist.bak"; fi
|
||||||
|
if [ -n "$backup_location" ]; then rm -f "$backup_location.tmp"; fi
|
||||||
|
|
||||||
|
if [ -n "$mount_location" ]; then
|
||||||
|
if mount | grep -q "$mount_location"; then umount "$mount_location"; fi
|
||||||
|
if [ -d "$mount_location" ]; then rmdir "$mount_location"; fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
partition=""
|
||||||
|
backup_location=""
|
||||||
|
mount_location=""
|
||||||
|
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
while getopts "m:b:" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
m) partition="$OPTARG" ;;
|
||||||
|
b) backup_location="$OPTARG" ;;
|
||||||
|
*) usage ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$partition" ]; then
|
||||||
|
mount_location=$(mktemp -d /mnt/backup.XXXXXX)
|
||||||
|
echo "Mounting $partition at $mount_location..."
|
||||||
|
mount "$partition" "$mount_location"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$mount_location" ]; then
|
||||||
|
if [[ "$backup_location" != /* ]]; then
|
||||||
|
backup_location="$(realpath "$backup_location")"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ "$backup_location" = /* ]]; then
|
||||||
|
echo "Error: When a partition is mounted, backup_location must be relative."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
backup_location="$(realpath "$mount_location/$backup_location")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
backup_location="$backup_location/$(hostname)-$(date +%Y-%m-%d-%H-%M-%S).btrfs.gz"
|
||||||
|
|
||||||
|
echo "Creating /persist snapshot..."
|
||||||
|
btrfs -q subvolume snapshot -r "/persist" "/persist.bak"
|
||||||
|
|
||||||
|
echo "Creating backup at $backup_location..."
|
||||||
|
btrfs -q send "/persist.bak" | gzip > "$backup_location.tmp"
|
||||||
|
|
||||||
|
mv "$backup_location.tmp" "$backup_location"
|
||||||
|
|
||||||
|
echo "Backup completed successfully!"
|
20
hosts/common/configs/system/backup/default.nix
Normal file
20
hosts/common/configs/system/backup/default.nix
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = [
|
||||||
|
(pkgs.writeShellApplication {
|
||||||
|
name = "backup";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
btrfs-progs
|
||||||
|
coreutils-full
|
||||||
|
util-linux
|
||||||
|
];
|
||||||
|
text = builtins.readFile ./backup.sh;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
home-manager.sharedModules = [
|
||||||
|
{
|
||||||
|
programs.zsh.initExtra = builtins.readFile ./backup.completion.zsh;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
@@ -8,11 +8,15 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.persistence."/persist/state"."/var/lib/bluetooth" = { };
|
environment.persistence."/persist"."/var/lib/bluetooth" = { };
|
||||||
|
|
||||||
systemd.services.bluetooth.after = [
|
systemd.services.bluetooth.after = [
|
||||||
config.environment.persistence."/persist/state"."/var/lib/bluetooth".mount
|
config.environment.persistence."/persist"."/var/lib/bluetooth".mount
|
||||||
];
|
];
|
||||||
|
|
||||||
home-manager.sharedModules = [ { services.mpris-proxy.enable = config.services.pipewire.enable; } ];
|
home-manager.sharedModules = [
|
||||||
|
{
|
||||||
|
services.mpris-proxy.enable = config.services.pipewire.enable;
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
@@ -10,8 +10,11 @@
|
|||||||
timeout = 1;
|
timeout = 1;
|
||||||
efi.canTouchEfiVariables = true;
|
efi.canTouchEfiVariables = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
initrd.systemd.enable = true;
|
initrd.systemd.enable = true;
|
||||||
kernelPackages = pkgs.linuxPackages_latest;
|
kernelPackages = pkgs.linuxPackages_latest;
|
||||||
|
supportedFilesystems = [
|
||||||
|
"btrfs"
|
||||||
|
"ntfs"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,33 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
systemd.tmpfiles.rules = [
|
|
||||||
"d /persist/user.bak 0755 root root"
|
|
||||||
"d /persist/state.bak 0755 root root"
|
|
||||||
];
|
|
||||||
|
|
||||||
services.btrbk = {
|
|
||||||
ioSchedulingClass = "idle";
|
|
||||||
niceness = 19;
|
|
||||||
instances = {
|
|
||||||
persist-user = {
|
|
||||||
onCalendar = "hourly";
|
|
||||||
settings.volume."/persist" = {
|
|
||||||
subvolume = "user";
|
|
||||||
snapshot_dir = "user.bak";
|
|
||||||
snapshot_preserve_min = "latest";
|
|
||||||
snapshot_preserve = "48h 14d 4w 6m";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
persist-state = {
|
|
||||||
onCalendar = "daily";
|
|
||||||
settings.volume."/persist" = {
|
|
||||||
subvolume = "state";
|
|
||||||
snapshot_dir = "state.bak";
|
|
||||||
snapshot_preserve_min = "latest";
|
|
||||||
snapshot_preserve = "7d 4w 3m";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
@@ -1,14 +1,7 @@
|
|||||||
{ pkgs, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
boot = {
|
|
||||||
initrd.supportedFilesystems = [ "btrfs" ];
|
|
||||||
supportedFilesystems = [ "btrfs" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.btrfs.autoScrub = {
|
services.btrfs.autoScrub = {
|
||||||
enable = true;
|
enable = true;
|
||||||
interval = "weekly";
|
interval = "weekly";
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [ compsize ];
|
|
||||||
}
|
}
|
||||||
|
4
hosts/common/configs/system/cpu/default.nix
Normal file
4
hosts/common/configs/system/cpu/default.nix
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [ ./options.nix ];
|
||||||
|
}
|
@@ -1,7 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./cpu/options.nix
|
|
||||||
./impermanence/options.nix
|
|
||||||
];
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
{ lib, pkgs, ... }:
|
|
||||||
{
|
|
||||||
networking.networkmanager.dns = "dnsmasq";
|
|
||||||
|
|
||||||
environment.etc."NetworkManager/dnsmasq.d/10-bind-interfaces.conf".source =
|
|
||||||
(pkgs.formats.keyValue {
|
|
||||||
mkKeyValue =
|
|
||||||
name: value:
|
|
||||||
if value == true then
|
|
||||||
name
|
|
||||||
else if value == false then
|
|
||||||
""
|
|
||||||
else
|
|
||||||
lib.generators.mkKeyValueDefault { } "=" name value;
|
|
||||||
listsAsDuplicateKeys = true;
|
|
||||||
}).generate
|
|
||||||
"10-bind-interfaces.conf"
|
|
||||||
{
|
|
||||||
bind-interfaces = true;
|
|
||||||
listen-address = [ "127.0.0.1" ];
|
|
||||||
};
|
|
||||||
}
|
|
29
hosts/common/configs/system/docker/default.nix
Normal file
29
hosts/common/configs/system/docker/default.nix
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{ config, pkgs, ... }:
|
||||||
|
{
|
||||||
|
virtualisation.docker = {
|
||||||
|
enable = true;
|
||||||
|
enableOnBoot = false;
|
||||||
|
storageDriver = "btrfs";
|
||||||
|
|
||||||
|
daemon.settings = {
|
||||||
|
experimental = true;
|
||||||
|
ipv6 = true;
|
||||||
|
fixed-cidr-v6 = "fd00::/80";
|
||||||
|
};
|
||||||
|
|
||||||
|
autoPrune = {
|
||||||
|
enable = true;
|
||||||
|
flags = [ "--all" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
persistence."/persist"."/var/lib/docker" = { };
|
||||||
|
systemPackages = with pkgs; [ docker-compose ];
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd = {
|
||||||
|
services.docker.after = [ config.environment.persistence."/persist"."/var/lib/docker".mount ];
|
||||||
|
sockets.docker.after = [ config.environment.persistence."/persist"."/var/lib/docker".mount ];
|
||||||
|
};
|
||||||
|
}
|
@@ -1,10 +1,5 @@
|
|||||||
{ pkgs, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
man-pages
|
|
||||||
man-pages-posix
|
|
||||||
];
|
|
||||||
|
|
||||||
documentation = {
|
documentation = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
@@ -1,16 +1,48 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{
|
{
|
||||||
|
imports = [ ./options.nix ];
|
||||||
|
|
||||||
|
boot.initrd.systemd = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
initrdBin = with pkgs; [
|
||||||
|
coreutils
|
||||||
|
util-linux
|
||||||
|
findutils
|
||||||
|
btrfs-progs
|
||||||
|
];
|
||||||
|
|
||||||
|
services.impermanence = {
|
||||||
|
description = "Rollback BTRFS subvolumes to a pristine state";
|
||||||
|
wantedBy = [ "initrd.target" ];
|
||||||
|
before = [ "sysroot.mount" ];
|
||||||
|
after = [
|
||||||
|
"cryptsetup.target"
|
||||||
|
"local-fs-pre.target"
|
||||||
|
];
|
||||||
|
unitConfig.DefaultDependencies = false;
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
environment.DEVICE = config.environment.impermanence.device;
|
||||||
|
script = builtins.readFile ./scripts/wipe.sh;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# uuidgen -r | tr -d -
|
# uuidgen -r | tr -d -
|
||||||
# https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/administration/systemd-state.section.md
|
# https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/administration/systemd-state.section.md
|
||||||
# https://github.com/NixOS/nixpkgs/pull/286140/files
|
# https://github.com/NixOS/nixpkgs/pull/286140/files
|
||||||
# https://git.eisfunke.com/config/nixos/-/blob/e65e1dc21d06d07b454005762b177ef151f8bfb6/nixos/machine-id.nix
|
# https://git.eisfunke.com/config/nixos/-/blob/e65e1dc21d06d07b454005762b177ef151f8bfb6/nixos/machine-id.nix
|
||||||
sops.secrets.machineId.mode = "0444";
|
sops.secrets."machineId".mode = "0444";
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
impermanence.enable = true;
|
etc."machine-id".source = pkgs.runCommandLocal "machine-id-link" { } ''
|
||||||
|
ln -s ${config.sops.secrets."machineId".path} $out
|
||||||
etc.machine-id.source = pkgs.runCommandLocal "machine-id-link" { } ''
|
|
||||||
ln -s ${config.sops.secrets.machineId.path} $out
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
persistence."/persist" = {
|
||||||
|
"/etc/nixos" = { };
|
||||||
|
"/var/lib/nixos" = { };
|
||||||
|
"/var/lib/systemd" = { };
|
||||||
|
"/var/log" = { };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
|
||||||
utils,
|
utils,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
@@ -48,17 +47,13 @@ in
|
|||||||
with lib;
|
with lib;
|
||||||
with types;
|
with types;
|
||||||
{
|
{
|
||||||
impermanence = {
|
impermanence.device = mkOption {
|
||||||
enable = mkEnableOption "Impermanence";
|
|
||||||
|
|
||||||
device = mkOption {
|
|
||||||
type = str;
|
type = str;
|
||||||
default = config.disko.devices.disk.main.content.partitions.root.content.content.device;
|
default = config.disko.devices.disk.main.content.partitions.root.content.name;
|
||||||
description = ''
|
description = ''
|
||||||
LUKS BTRFS partition to wipe on boot.
|
LUKS BTRFS partition to wipe on boot.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
persistence =
|
persistence =
|
||||||
let
|
let
|
||||||
@@ -121,19 +116,6 @@ in
|
|||||||
type = str;
|
type = str;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
create = mkOption {
|
|
||||||
type = enum [
|
|
||||||
"none"
|
|
||||||
"file"
|
|
||||||
"directory"
|
|
||||||
];
|
|
||||||
default = "none";
|
|
||||||
description = ''
|
|
||||||
Whether to create the file or directory
|
|
||||||
in persistence if it does not exist.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -197,31 +179,8 @@ in
|
|||||||
let
|
let
|
||||||
all = lib.lists.flatten (builtins.concatMap builtins.attrValues (builtins.attrValues cfg));
|
all = lib.lists.flatten (builtins.concatMap builtins.attrValues (builtins.attrValues cfg));
|
||||||
in
|
in
|
||||||
lib.mkIf config.environment.impermanence.enable {
|
{
|
||||||
boot.initrd.systemd = {
|
fileSystems = builtins.mapAttrs (_: _: { neededForBoot = true; }) cfg;
|
||||||
enable = true;
|
|
||||||
|
|
||||||
initrdBin = with pkgs; [
|
|
||||||
coreutils
|
|
||||||
util-linux
|
|
||||||
findutils
|
|
||||||
btrfs-progs
|
|
||||||
];
|
|
||||||
|
|
||||||
services.impermanence = {
|
|
||||||
description = "Rollback BTRFS subvolumes to a pristine state";
|
|
||||||
wantedBy = [ "initrd.target" ];
|
|
||||||
before = [ "sysroot.mount" ];
|
|
||||||
after = [
|
|
||||||
"cryptsetup.target"
|
|
||||||
"local-fs-pre.target"
|
|
||||||
];
|
|
||||||
unitConfig.DefaultDependencies = false;
|
|
||||||
serviceConfig.Type = "oneshot";
|
|
||||||
environment.DEVICE = config.environment.impermanence.device;
|
|
||||||
script = builtins.readFile ./scripts/wipe.sh;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd = {
|
systemd = {
|
||||||
mounts = builtins.map (c: {
|
mounts = builtins.map (c: {
|
||||||
@@ -270,7 +229,6 @@ in
|
|||||||
source=${lib.strings.escapeShellArg c._sourceRoot}
|
source=${lib.strings.escapeShellArg c._sourceRoot}
|
||||||
target=${lib.strings.escapeShellArg c._targetRoot}
|
target=${lib.strings.escapeShellArg c._targetRoot}
|
||||||
path=${lib.strings.escapeShellArg c.path}
|
path=${lib.strings.escapeShellArg c.path}
|
||||||
create=${lib.strings.escapeShellArg c.create}
|
|
||||||
|
|
||||||
${builtins.readFile ./scripts/start.sh}
|
${builtins.readFile ./scripts/start.sh}
|
||||||
'';
|
'';
|
||||||
@@ -278,7 +236,6 @@ in
|
|||||||
source=${lib.strings.escapeShellArg c._sourceRoot}
|
source=${lib.strings.escapeShellArg c._sourceRoot}
|
||||||
target=${lib.strings.escapeShellArg c._targetRoot}
|
target=${lib.strings.escapeShellArg c._targetRoot}
|
||||||
path=${lib.strings.escapeShellArg c.path}
|
path=${lib.strings.escapeShellArg c.path}
|
||||||
create=${lib.strings.escapeShellArg c.create}
|
|
||||||
|
|
||||||
${builtins.readFile ./scripts/stop.sh}
|
${builtins.readFile ./scripts/stop.sh}
|
||||||
'';
|
'';
|
||||||
@@ -287,19 +244,6 @@ in
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
fileSystems = builtins.mapAttrs (_: _: { neededForBoot = true; }) cfg // {
|
|
||||||
"/persist".neededForBoot = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
environment.persistence = {
|
|
||||||
"/persist/user"."/etc/nixos" = { };
|
|
||||||
"/persist/state" = {
|
|
||||||
"/var/lib/nixos" = { };
|
|
||||||
"/var/lib/systemd" = { };
|
|
||||||
"/var/log" = { };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
assertions =
|
assertions =
|
||||||
let
|
let
|
||||||
paths = builtins.map (c: c.path) all;
|
paths = builtins.map (c: c.path) all;
|
||||||
|
@@ -1,49 +1,19 @@
|
|||||||
# shellcheck shell=bash
|
echo "Starting impermanence mount with source: $source, target: $target, path: $path."
|
||||||
|
|
||||||
# shellcheck disable=SC2154
|
|
||||||
echo "Starting impermanence mount with source: $source, target: $target, path: $path, create: $create"
|
|
||||||
|
|
||||||
source_current="$source"
|
source_current="$source"
|
||||||
target_current="$target"
|
target_current="$target"
|
||||||
|
|
||||||
IFS='/' read -ra parts <<< "$path"
|
IFS='/' read -ra path_parts <<< "$path"
|
||||||
leaf="${parts[-1]}"
|
unset "path_parts[-1]"
|
||||||
|
|
||||||
for part in "${parts[@]}"; do
|
for part in "${path_parts[@]}"; do
|
||||||
source_current+="/$part"
|
source_current="$source_current/$part"
|
||||||
target_current+="/$part"
|
target_current="$target_current/$part"
|
||||||
|
|
||||||
if [[ -e "$source_current" ]]; then
|
if [[ ! -d "$source_current" ]]; then
|
||||||
read -r mode owner group <<< "$(stat -c '%a %u %g' "$source_current")"
|
|
||||||
|
|
||||||
if [[ -d "$source_current" ]]; then
|
|
||||||
install -d -m "$mode" -o "$owner" -g "$group" "$target_current"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$part" != "$leaf" ]]; then
|
|
||||||
echo "Error: $source_current is not a directory, persistence for $path can not be applied."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
install -m "$mode" -o "$owner" -g "$group" /dev/null "$target_current"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$create" == "none" ]]; then
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -e "$target_current" ]]; then
|
read -r mode owner group <<< "$(stat -c '%a %u %g' "$source_current")"
|
||||||
template="$target_current"
|
install -d -m "$mode" -o "$owner" -g "$group" "$target_current"
|
||||||
else
|
|
||||||
template="${source_current%/*}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -r mode owner group <<< "$(stat -c '%a %u %g' "$template")"
|
|
||||||
|
|
||||||
if [[ "$part" == "$leaf" && "$create" == "file" ]]; then
|
|
||||||
install -m "$mode" -o "$owner" -g "$group" /dev/null "$source_current"
|
|
||||||
else
|
|
||||||
install -d -m "$mode" -o "$owner" -g "$group" "$source_current"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
# shellcheck shell=bash
|
echo "Stopping impermanence mount with source: $source, target: $target, path: $path."
|
||||||
|
|
||||||
# shellcheck disable=SC2154
|
|
||||||
echo "Stopping impermanence mount with source: $source, target: $target, path: $path, create: $create"
|
|
||||||
|
|
||||||
source_current="$source"
|
source_current="$source"
|
||||||
target_current="$target"
|
target_current="$target"
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
delete_subvolume_recursively() {
|
delete_subvolume_recursively() {
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do
|
||||||
@@ -8,27 +6,21 @@ delete_subvolume_recursively() {
|
|||||||
btrfs subvolume delete "$1"
|
btrfs subvolume delete "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [[ -z "$DEVICE" ]]; then
|
||||||
|
echo "Error: DEVICE variable is not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p /mnt/btrfs
|
mkdir -p /mnt/btrfs
|
||||||
mount "$DEVICE" /mnt/btrfs
|
mount "/dev/mapper/$DEVICE" /mnt/btrfs
|
||||||
|
|
||||||
if [[ -e /mnt/btrfs/@ ]]; then
|
if [[ -e /mnt/btrfs/@ ]]; then
|
||||||
mkdir -p /mnt/btrfs/@.bak
|
mkdir -p /mnt/btrfs/@.bak
|
||||||
timestamp=$(date --date="@$(stat -c %Y /mnt/btrfs/@)" "+%Y%m%dT%H%M")
|
timestamp=$(date --date="@$(stat -c %Y /mnt/btrfs/@)" "+%Y-%m-%d_%H:%M:%S")
|
||||||
base="@.$timestamp"
|
mv /mnt/btrfs/@ "/mnt/btrfs/@.bak/$timestamp"
|
||||||
|
|
||||||
target="/mnt/btrfs/@.bak/$base"
|
|
||||||
if [[ -e "$target" ]]; then
|
|
||||||
i=1
|
|
||||||
while [[ -e "/mnt/btrfs/@.bak/${base}_$i" ]]; do
|
|
||||||
(( i++ ))
|
|
||||||
done
|
|
||||||
target="/mnt/btrfs/@.bak/${base}_$i"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mv /mnt/btrfs/@ "$target"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find /mnt/btrfs/@.bak/ -maxdepth 1 -mtime +7 | while IFS= read -r i; do
|
find /mnt/btrfs/@.bak/ -maxdepth 1 -mtime +14 | while IFS= read -r i; do
|
||||||
delete_subvolume_recursively "$i"
|
delete_subvolume_recursively "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
52
hosts/common/configs/system/kubernetes/default.nix
Normal file
52
hosts/common/configs/system/kubernetes/default.nix
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./options
|
||||||
|
./secrets
|
||||||
|
];
|
||||||
|
|
||||||
|
environment = {
|
||||||
|
persistence."/persist" = {
|
||||||
|
"/var/lib/containerd" = { };
|
||||||
|
"/var/lib/kubernetes" = { };
|
||||||
|
"/var/lib/kubelet" = { };
|
||||||
|
"/var/lib/etcd" = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
etc."kubeconfig".source = config.services.kubernetes.kubeconfigs.admin;
|
||||||
|
systemPackages = with pkgs; [ kubectl ];
|
||||||
|
};
|
||||||
|
|
||||||
|
services = {
|
||||||
|
kubernetes = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
roles = [
|
||||||
|
"master"
|
||||||
|
"node"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services = {
|
||||||
|
kube-addon-manager.after = [
|
||||||
|
config.environment.persistence."/persist"."/var/lib/kubernetes".mount
|
||||||
|
];
|
||||||
|
|
||||||
|
kubelet.after = [
|
||||||
|
config.environment.persistence."/persist"."/var/lib/kubelet".mount
|
||||||
|
];
|
||||||
|
|
||||||
|
kube-apiserver.after = [
|
||||||
|
config.environment.persistence."/persist"."/var/lib/kubernetes".mount
|
||||||
|
];
|
||||||
|
|
||||||
|
etcd.after = [
|
||||||
|
config.environment.persistence."/persist"."/var/lib/etcd".mount
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
@@ -0,0 +1,70 @@
|
|||||||
|
{ ... }:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "Role";
|
||||||
|
metadata = {
|
||||||
|
name = "system:kube-addon-manager";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
rules = [
|
||||||
|
{
|
||||||
|
apiGroups = [ "*" ];
|
||||||
|
resources = [ "*" ];
|
||||||
|
verbs = [ "*" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "RoleBinding";
|
||||||
|
metadata = {
|
||||||
|
name = "system:kube-addon-manager";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
roleRef = {
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
kind = "Role";
|
||||||
|
name = "system:kube-addon-manager";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
kind = "User";
|
||||||
|
name = "system:kube-addon-manager";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
metadata = {
|
||||||
|
name = "system:kube-addon-manager:cluster-lister";
|
||||||
|
};
|
||||||
|
rules = [
|
||||||
|
{
|
||||||
|
apiGroups = [ "*" ];
|
||||||
|
resources = [ "*" ];
|
||||||
|
verbs = [ "list" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRoleBinding";
|
||||||
|
metadata = {
|
||||||
|
name = "system:kube-addon-manager:cluster-lister";
|
||||||
|
};
|
||||||
|
roleRef = {
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
name = "system:kube-addon-manager:cluster-lister";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "User";
|
||||||
|
name = "system:kube-addon-manager";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
]
|
@@ -0,0 +1,206 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRoleBinding";
|
||||||
|
metadata = {
|
||||||
|
name = "create-csrs-for-bootstrapping";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "Group";
|
||||||
|
name = "system:bootstrappers";
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
roleRef = {
|
||||||
|
kind = "ClusterRole";
|
||||||
|
name = "system:node-bootstrapper";
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRoleBinding";
|
||||||
|
metadata = {
|
||||||
|
name = "auto-approve-csrs-for-group";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "Group";
|
||||||
|
name = "system:bootstrappers";
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
roleRef = {
|
||||||
|
kind = "ClusterRole";
|
||||||
|
name = "system:certificates.k8s.io:certificatesigningrequests:nodeclient";
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRoleBinding";
|
||||||
|
metadata = {
|
||||||
|
name = "auto-approve-renewals-for-nodes";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "Group";
|
||||||
|
name = "system:nodes";
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
roleRef = {
|
||||||
|
kind = "ClusterRole";
|
||||||
|
name = "system:certificates.k8s.io:certificatesigningrequests:selfnodeclient";
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
metadata = {
|
||||||
|
name = "kubelet-csr-approver";
|
||||||
|
};
|
||||||
|
rules = [
|
||||||
|
{
|
||||||
|
apiGroups = [ "certificates.k8s.io" ];
|
||||||
|
resources = [ "certificatesigningrequests" ];
|
||||||
|
verbs = [
|
||||||
|
"get"
|
||||||
|
"list"
|
||||||
|
"watch"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiGroups = [ "coordination.k8s.io" ];
|
||||||
|
resources = [ "leases" ];
|
||||||
|
verbs = [
|
||||||
|
"create"
|
||||||
|
"get"
|
||||||
|
"update"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiGroups = [ "certificates.k8s.io" ];
|
||||||
|
resources = [ "certificatesigningrequests/approval" ];
|
||||||
|
verbs = [ "update" ];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiGroups = [ "certificates.k8s.io" ];
|
||||||
|
resourceNames = [ "kubernetes.io/kubelet-serving" ];
|
||||||
|
resources = [ "signers" ];
|
||||||
|
verbs = [ "approve" ];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiGroups = [ "" ];
|
||||||
|
resources = [ "events" ];
|
||||||
|
verbs = [ "create" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRoleBinding";
|
||||||
|
metadata = {
|
||||||
|
name = "kubelet-csr-approver";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
roleRef = {
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
name = "kubelet-csr-approver";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "ServiceAccount";
|
||||||
|
name = "kubelet-csr-approver";
|
||||||
|
namespace = "kube-system";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "v1";
|
||||||
|
kind = "ServiceAccount";
|
||||||
|
metadata = {
|
||||||
|
name = "kubelet-csr-approver";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "apps/v1";
|
||||||
|
kind = "Deployment";
|
||||||
|
metadata = {
|
||||||
|
name = "kubelet-csr-approver";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
spec = {
|
||||||
|
replicas = 1;
|
||||||
|
selector = {
|
||||||
|
matchLabels = {
|
||||||
|
app = "kubelet-csr-approver";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
template = {
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
app = "kubelet-csr-approver";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
spec = {
|
||||||
|
serviceAccountName = "kubelet-csr-approver";
|
||||||
|
containers = [
|
||||||
|
{
|
||||||
|
name = "kubelet-csr-approver";
|
||||||
|
image = "postfinance/kubelet-csr-approver:latest";
|
||||||
|
args = [
|
||||||
|
"-metrics-bind-address"
|
||||||
|
":8080"
|
||||||
|
"-health-probe-bind-address"
|
||||||
|
":8081"
|
||||||
|
];
|
||||||
|
livenessProbe = {
|
||||||
|
httpGet = {
|
||||||
|
path = "/healthz";
|
||||||
|
port = 8081;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
resources = {
|
||||||
|
requests = {
|
||||||
|
cpu = "100m";
|
||||||
|
memory = "200Mi";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
env = [
|
||||||
|
{
|
||||||
|
name = "PROVIDER_REGEX";
|
||||||
|
value = "^${config.networking.fqdnOrHostName}$";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "PROVIDER_IP_PREFIXES";
|
||||||
|
value = "10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.0/8,169.254.0.0/16,::1/128,fe80::/10,fc00::/7";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "MAX_EXPIRATION_SEC";
|
||||||
|
value = "31622400";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "BYPASS_DNS_RESOLUTION";
|
||||||
|
value = "true";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
tolerations = [
|
||||||
|
{
|
||||||
|
effect = "NoSchedule";
|
||||||
|
key = "node-role.kubernetes.io/control-plane";
|
||||||
|
operator = "Equal";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]
|
@@ -0,0 +1,21 @@
|
|||||||
|
{ ... }:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRoleBinding";
|
||||||
|
metadata = {
|
||||||
|
name = "system:kube-apiserver:kubelet-api-admin";
|
||||||
|
};
|
||||||
|
roleRef = {
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
name = "system:kubelet-api-admin";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "User";
|
||||||
|
name = "system:kube-apiserver";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
]
|
@@ -0,0 +1,289 @@
|
|||||||
|
{ ... }:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
apiVersion = "v1";
|
||||||
|
kind = "ServiceAccount";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
name = "metrics-server";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
"rbac.authorization.k8s.io/aggregate-to-admin" = "true";
|
||||||
|
"rbac.authorization.k8s.io/aggregate-to-edit" = "true";
|
||||||
|
"rbac.authorization.k8s.io/aggregate-to-view" = "true";
|
||||||
|
};
|
||||||
|
name = "system:aggregated-metrics-reader";
|
||||||
|
};
|
||||||
|
rules = [
|
||||||
|
{
|
||||||
|
apiGroups = [ "metrics.k8s.io" ];
|
||||||
|
resources = [
|
||||||
|
"pods"
|
||||||
|
"nodes"
|
||||||
|
];
|
||||||
|
verbs = [
|
||||||
|
"get"
|
||||||
|
"list"
|
||||||
|
"watch"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
name = "system:metrics-server";
|
||||||
|
};
|
||||||
|
rules = [
|
||||||
|
{
|
||||||
|
apiGroups = [ "" ];
|
||||||
|
resources = [ "nodes/metrics" ];
|
||||||
|
verbs = [ "get" ];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiGroups = [ "" ];
|
||||||
|
resources = [
|
||||||
|
"pods"
|
||||||
|
"nodes"
|
||||||
|
];
|
||||||
|
verbs = [
|
||||||
|
"get"
|
||||||
|
"list"
|
||||||
|
"watch"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "RoleBinding";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
name = "metrics-server-auth-reader";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
roleRef = {
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
kind = "Role";
|
||||||
|
name = "extension-apiserver-authentication-reader";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "ServiceAccount";
|
||||||
|
name = "metrics-server";
|
||||||
|
namespace = "kube-system";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRoleBinding";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
name = "metrics-server:system:auth-delegator";
|
||||||
|
};
|
||||||
|
roleRef = {
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
name = "system:auth-delegator";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "ServiceAccount";
|
||||||
|
name = "metrics-server";
|
||||||
|
namespace = "kube-system";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "rbac.authorization.k8s.io/v1";
|
||||||
|
kind = "ClusterRoleBinding";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
name = "system:metrics-server";
|
||||||
|
};
|
||||||
|
roleRef = {
|
||||||
|
apiGroup = "rbac.authorization.k8s.io";
|
||||||
|
kind = "ClusterRole";
|
||||||
|
name = "system:metrics-server";
|
||||||
|
};
|
||||||
|
subjects = [
|
||||||
|
{
|
||||||
|
kind = "ServiceAccount";
|
||||||
|
name = "metrics-server";
|
||||||
|
namespace = "kube-system";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "v1";
|
||||||
|
kind = "Service";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
name = "metrics-server";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
spec = {
|
||||||
|
ports = [
|
||||||
|
{
|
||||||
|
name = "https";
|
||||||
|
port = 443;
|
||||||
|
protocol = "TCP";
|
||||||
|
targetPort = "https";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
selector = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "apps/v1";
|
||||||
|
kind = "Deployment";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
name = "metrics-server";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
spec = {
|
||||||
|
selector = {
|
||||||
|
matchLabels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
strategy = {
|
||||||
|
rollingUpdate = {
|
||||||
|
maxUnavailable = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
template = {
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
spec = {
|
||||||
|
containers = [
|
||||||
|
{
|
||||||
|
args = [
|
||||||
|
"--cert-dir=/tmp"
|
||||||
|
"--secure-port=10250"
|
||||||
|
"--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname"
|
||||||
|
"--kubelet-use-node-status-port"
|
||||||
|
"--metric-resolution=15s"
|
||||||
|
];
|
||||||
|
image = "registry.k8s.io/metrics-server/metrics-server:v0.7.2";
|
||||||
|
imagePullPolicy = "IfNotPresent";
|
||||||
|
livenessProbe = {
|
||||||
|
failureThreshold = 3;
|
||||||
|
httpGet = {
|
||||||
|
path = "/livez";
|
||||||
|
port = "https";
|
||||||
|
scheme = "HTTPS";
|
||||||
|
};
|
||||||
|
periodSeconds = 10;
|
||||||
|
};
|
||||||
|
name = "metrics-server";
|
||||||
|
ports = [
|
||||||
|
{
|
||||||
|
containerPort = 10250;
|
||||||
|
name = "https";
|
||||||
|
protocol = "TCP";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
readinessProbe = {
|
||||||
|
failureThreshold = 3;
|
||||||
|
httpGet = {
|
||||||
|
path = "/readyz";
|
||||||
|
port = "https";
|
||||||
|
scheme = "HTTPS";
|
||||||
|
};
|
||||||
|
initialDelaySeconds = 20;
|
||||||
|
periodSeconds = 10;
|
||||||
|
};
|
||||||
|
resources = {
|
||||||
|
requests = {
|
||||||
|
cpu = "100m";
|
||||||
|
memory = "200Mi";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
securityContext = {
|
||||||
|
allowPrivilegeEscalation = false;
|
||||||
|
capabilities = {
|
||||||
|
drop = [ "ALL" ];
|
||||||
|
};
|
||||||
|
readOnlyRootFilesystem = true;
|
||||||
|
runAsNonRoot = true;
|
||||||
|
runAsUser = 1000;
|
||||||
|
seccompProfile = {
|
||||||
|
type = "RuntimeDefault";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
volumeMounts = [
|
||||||
|
{
|
||||||
|
mountPath = "/tmp";
|
||||||
|
name = "tmp-dir";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
nodeSelector = {
|
||||||
|
"kubernetes.io/os" = "linux";
|
||||||
|
};
|
||||||
|
priorityClassName = "system-cluster-critical";
|
||||||
|
serviceAccountName = "metrics-server";
|
||||||
|
volumes = [
|
||||||
|
{
|
||||||
|
emptyDir = { };
|
||||||
|
name = "tmp-dir";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
apiVersion = "apiregistration.k8s.io/v1";
|
||||||
|
kind = "APIService";
|
||||||
|
metadata = {
|
||||||
|
labels = {
|
||||||
|
k8s-app = "metrics-server";
|
||||||
|
};
|
||||||
|
name = "v1beta1.metrics.k8s.io";
|
||||||
|
};
|
||||||
|
spec = {
|
||||||
|
group = "metrics.k8s.io";
|
||||||
|
groupPriorityMinimum = 100;
|
||||||
|
insecureSkipTLSVerify = true;
|
||||||
|
service = {
|
||||||
|
name = "metrics-server";
|
||||||
|
namespace = "kube-system";
|
||||||
|
};
|
||||||
|
version = "v1beta1";
|
||||||
|
versionPriority = 100;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]
|
757
hosts/common/configs/system/kubernetes/options/default.nix
Normal file
757
hosts/common/configs/system/kubernetes/options/default.nix
Normal file
@@ -0,0 +1,757 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.services.kubernetes;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.kubernetes =
|
||||||
|
with lib;
|
||||||
|
with types;
|
||||||
|
let
|
||||||
|
mkCertOptions = name: {
|
||||||
|
key = mkOption {
|
||||||
|
description = "${name} key file.";
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
|
||||||
|
crt = mkOption {
|
||||||
|
description = "${name} certificate file.";
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
enable = mkEnableOption "kubernetes";
|
||||||
|
|
||||||
|
lib = mkOption {
|
||||||
|
description = "Kubernetes utility functions.";
|
||||||
|
type = raw;
|
||||||
|
readOnly = true;
|
||||||
|
default = {
|
||||||
|
mkKubeConfig =
|
||||||
|
name: ca: cert: key:
|
||||||
|
(pkgs.formats.json { }).generate "${name}-kubeconfig.json" {
|
||||||
|
apiVersion = "v1";
|
||||||
|
kind = "Config";
|
||||||
|
clusters = [
|
||||||
|
{
|
||||||
|
name = "local";
|
||||||
|
cluster = {
|
||||||
|
server = cfg.apiserver._address;
|
||||||
|
"certificate-authority" = ca;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
users = [
|
||||||
|
{
|
||||||
|
inherit name;
|
||||||
|
user = {
|
||||||
|
"client-certificate" = cert;
|
||||||
|
"client-key" = key;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
contexts = [
|
||||||
|
{
|
||||||
|
name = "local";
|
||||||
|
context = {
|
||||||
|
cluster = "local";
|
||||||
|
user = name;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
current-context = "local";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
roles = mkOption {
|
||||||
|
description = "Kubernetes role that this machine should take.";
|
||||||
|
type = listOf (enum [
|
||||||
|
"master"
|
||||||
|
"node"
|
||||||
|
]);
|
||||||
|
default = [
|
||||||
|
"master"
|
||||||
|
"node"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
address = mkOption {
|
||||||
|
description = "Kubernetes master server address.";
|
||||||
|
type = str;
|
||||||
|
default = "localhost";
|
||||||
|
};
|
||||||
|
|
||||||
|
cidr = mkOption {
|
||||||
|
description = "Kubernetes cluster CIDR.";
|
||||||
|
type = str;
|
||||||
|
default = "10.0.0.0/24";
|
||||||
|
};
|
||||||
|
|
||||||
|
cas = {
|
||||||
|
kubernetes = mkCertOptions "Kubernetes CA";
|
||||||
|
frontProxy = mkCertOptions "Front Proxy CA";
|
||||||
|
etcd = mkCertOptions "ETCD CA";
|
||||||
|
};
|
||||||
|
|
||||||
|
certs = {
|
||||||
|
apiserver = {
|
||||||
|
server = mkCertOptions "Kubernetes API Server";
|
||||||
|
kubeletClient = mkCertOptions "Kubernetes API Server Kubelet Client";
|
||||||
|
etcdClient = mkCertOptions "Kubernetes API Server ETCD Client";
|
||||||
|
};
|
||||||
|
|
||||||
|
etcd = {
|
||||||
|
server = mkCertOptions "ETCD Server";
|
||||||
|
peer = mkCertOptions "ETCD Peer";
|
||||||
|
};
|
||||||
|
|
||||||
|
frontProxy = mkCertOptions "Front Proxy Client";
|
||||||
|
|
||||||
|
serviceAccount = {
|
||||||
|
public = mkOption {
|
||||||
|
description = "Service account public key file.";
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
|
||||||
|
private = mkOption {
|
||||||
|
description = "Service account private key file.";
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
accounts = {
|
||||||
|
scheduler = mkCertOptions "Kubernetes Scheduler";
|
||||||
|
controllerManager = mkCertOptions "Kubernetes Controller Manager";
|
||||||
|
addonManager = mkCertOptions "Kubernetes Addon Manager";
|
||||||
|
proxy = mkCertOptions "Kubernetes Proxy";
|
||||||
|
admin = mkCertOptions "Kubernetes Admin";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
kubeconfigs = mkOption {
|
||||||
|
description = "Kubernetes kubeconfigs.";
|
||||||
|
type = attrsOf path;
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
apiserver = {
|
||||||
|
_address = mkOption {
|
||||||
|
description = "Kubernetes API server address.";
|
||||||
|
internal = true;
|
||||||
|
type = str;
|
||||||
|
};
|
||||||
|
|
||||||
|
address = mkOption {
|
||||||
|
description = "Kubernetes API server listening address.";
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
description = "Kubernetes API server listening port.";
|
||||||
|
type = port;
|
||||||
|
readOnly = true;
|
||||||
|
default = 6443;
|
||||||
|
};
|
||||||
|
|
||||||
|
bootstrapTokenFile = mkOption {
|
||||||
|
description = "Kubernetes API server bootstrap token file.";
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
kubelet = {
|
||||||
|
address = mkOption {
|
||||||
|
description = "Kubernetes kubelet listening address.";
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
description = "Kubernetes kubelet listening port.";
|
||||||
|
type = port;
|
||||||
|
readOnly = true;
|
||||||
|
default = 10250;
|
||||||
|
};
|
||||||
|
|
||||||
|
taints =
|
||||||
|
let
|
||||||
|
taintOptions =
|
||||||
|
{ name, ... }:
|
||||||
|
{
|
||||||
|
key = mkOption {
|
||||||
|
description = "Taint key.";
|
||||||
|
type = str;
|
||||||
|
default = name;
|
||||||
|
};
|
||||||
|
|
||||||
|
value = mkOption {
|
||||||
|
description = "Taint value.";
|
||||||
|
type = str;
|
||||||
|
};
|
||||||
|
|
||||||
|
effect = mkOption {
|
||||||
|
description = "Taint effect.";
|
||||||
|
type = enum [
|
||||||
|
"NoSchedule"
|
||||||
|
"PreferNoSchedule"
|
||||||
|
"NoExecute"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mkOption {
|
||||||
|
description = "Taints to apply to the node.";
|
||||||
|
type = attrsOf (submodule taintOptions);
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
bootstrapToken = mkOption {
|
||||||
|
description = "Kubelet bootstrap token file.";
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
|
||||||
|
seedImages = mkOption {
|
||||||
|
description = "Container images to preload on the system.";
|
||||||
|
type = listOf package;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
|
cidr = mkOption {
|
||||||
|
description = "Kubernetes pod CIDR.";
|
||||||
|
type = str;
|
||||||
|
default = "10.1.0.0/16";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
scheduler = {
|
||||||
|
address = mkOption {
|
||||||
|
description = "Kubernetes scheduler listening address.";
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "127.0.0.1";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
description = "Kubernetes scheduler listening port.";
|
||||||
|
type = port;
|
||||||
|
readOnly = true;
|
||||||
|
default = 10251;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
controllerManager = {
|
||||||
|
address = mkOption {
|
||||||
|
description = "Kubernetes controller manager listening address.";
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "127.0.0.1";
|
||||||
|
};
|
||||||
|
|
||||||
|
port = mkOption {
|
||||||
|
description = "Kubernetes controller manager listening port.";
|
||||||
|
type = port;
|
||||||
|
readOnly = true;
|
||||||
|
default = 10252;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
proxy = {
|
||||||
|
address = mkOption {
|
||||||
|
description = "Kubernetes proxy listening address.";
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "0.0.0.0";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
addonManager = {
|
||||||
|
addons = mkOption {
|
||||||
|
description = "Kubernetes addons.";
|
||||||
|
type = attrsOf (coercedTo (attrs) (a: [ a ]) (listOf attrs));
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
|
||||||
|
bootstrapAddons = mkOption {
|
||||||
|
description = "Kubernetes addons applied with cluster-admin permissions.";
|
||||||
|
type = attrsOf (coercedTo (attrs) (a: [ a ]) (listOf attrs));
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable (
|
||||||
|
lib.mkMerge [
|
||||||
|
# master or node
|
||||||
|
{
|
||||||
|
services.kubernetes = {
|
||||||
|
apiserver._address = "https://${cfg.address}:${toString cfg.apiserver.port}";
|
||||||
|
|
||||||
|
kubeconfigs.admin =
|
||||||
|
cfg.lib.mkKubeConfig "admin" cfg.cas.kubernetes.crt cfg.certs.accounts.admin.crt
|
||||||
|
cfg.certs.accounts.admin.key;
|
||||||
|
|
||||||
|
addonManager.bootstrapAddons = {
|
||||||
|
addonManager = import ./addons/addon-manager { };
|
||||||
|
bootstrap = import ./addons/bootstrap { inherit config; };
|
||||||
|
kubeletApiAdmin = import ./addons/kubelet-api-admin { };
|
||||||
|
metricsServer = import ./addons/metrics-server { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
boot = {
|
||||||
|
kernel.sysctl = {
|
||||||
|
"net.bridge.bridge-nf-call-iptables" = 1;
|
||||||
|
"net.ipv4.ip_forward" = 1;
|
||||||
|
"net.bridge.bridge-nf-call-ip6tables" = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
kernelModules = [
|
||||||
|
"br_netfilter"
|
||||||
|
"overlay"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
users = {
|
||||||
|
users.kubernetes = {
|
||||||
|
uid = config.ids.uids.kubernetes;
|
||||||
|
group = "kubernetes";
|
||||||
|
home = "/var/lib/kubernetes";
|
||||||
|
homeMode = "755";
|
||||||
|
createHome = true;
|
||||||
|
description = "Kubernetes user";
|
||||||
|
};
|
||||||
|
|
||||||
|
groups.kubernetes.gid = config.ids.gids.kubernetes;
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd = {
|
||||||
|
targets.kubernetes = {
|
||||||
|
description = "Kubernetes";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
tmpfiles.rules = [
|
||||||
|
"d /opt/cni/bin 0755 root root -"
|
||||||
|
"d /run/kubernetes 0755 kubernetes kubernetes -"
|
||||||
|
];
|
||||||
|
|
||||||
|
services = {
|
||||||
|
kubelet =
|
||||||
|
let
|
||||||
|
kubeletConfig = (pkgs.formats.json { }).generate "config.json" ({
|
||||||
|
apiVersion = "kubelet.config.k8s.io/v1beta1";
|
||||||
|
kind = "KubeletConfiguration";
|
||||||
|
address = cfg.kubelet.address;
|
||||||
|
port = cfg.kubelet.port;
|
||||||
|
authentication = {
|
||||||
|
x509.clientCAFile = cfg.cas.kubernetes.crt;
|
||||||
|
webhook = {
|
||||||
|
enabled = true;
|
||||||
|
cacheTTL = "10s";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
authorization.mode = "Webhook";
|
||||||
|
cgroupDriver = "systemd";
|
||||||
|
hairpinMode = "hairpin-veth";
|
||||||
|
registerNode = true;
|
||||||
|
containerRuntimeEndpoint = "unix:///run/containerd/containerd.sock";
|
||||||
|
failSwapOn = false;
|
||||||
|
memorySwap.swapBehavior = "LimitedSwap";
|
||||||
|
rotateCertificates = true;
|
||||||
|
serverTLSBootstrap = true;
|
||||||
|
featureGates = {
|
||||||
|
RotateKubeletServerCertificate = true;
|
||||||
|
NodeSwap = true;
|
||||||
|
};
|
||||||
|
healthzBindAddress = "127.0.0.1";
|
||||||
|
healthzPort = 10248;
|
||||||
|
});
|
||||||
|
|
||||||
|
taints = lib.strings.concatMapStringsSep "," (v: "${v.key}=${v.value}:${v.effect}") (
|
||||||
|
lib.attrsets.mapAttrsToList (n: v: v) cfg.kubelet.taints
|
||||||
|
);
|
||||||
|
|
||||||
|
generateKubeletBootstrapKubeconfig = lib.meta.getExe (
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "kubelet-bootstrap-kubeconfig";
|
||||||
|
runtimeInputs = with pkgs; [ coreutils ];
|
||||||
|
text = ''
|
||||||
|
mkdir -p /etc/kubernetes
|
||||||
|
cat > /etc/kubernetes/bootstrap-kubeconfig <<EOF
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Config
|
||||||
|
clusters:
|
||||||
|
- cluster:
|
||||||
|
certificate-authority: ${cfg.cas.kubernetes.crt}
|
||||||
|
server: ${cfg.apiserver._address}
|
||||||
|
name: local
|
||||||
|
contexts:
|
||||||
|
- context:
|
||||||
|
cluster: local
|
||||||
|
user: kubelet-bootstrap
|
||||||
|
name: bootstrap
|
||||||
|
current-context: bootstrap
|
||||||
|
preferences: {}
|
||||||
|
users:
|
||||||
|
- name: kubelet-bootstrap
|
||||||
|
user:
|
||||||
|
token: $(<${cfg.kubelet.bootstrapToken})
|
||||||
|
EOF
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
seedContainerImages = lib.meta.getExe (
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "seed-container-images";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
gzip
|
||||||
|
containerd
|
||||||
|
coreutils
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
${lib.strings.concatMapStrings (img: ''
|
||||||
|
echo "Seeding container image: ${img}"
|
||||||
|
${
|
||||||
|
if (lib.hasSuffix "gz" img) then
|
||||||
|
''zcat "${img}" | ctr -n k8s.io image import -''
|
||||||
|
else
|
||||||
|
''cat "${img}" | ctr -n k8s.io image import -''
|
||||||
|
}
|
||||||
|
'') cfg.kubelet.seedImages}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
description = "Kubernetes Kubelet";
|
||||||
|
wantedBy = [ "kubernetes.target" ];
|
||||||
|
after = [
|
||||||
|
"network.target"
|
||||||
|
"containerd.service"
|
||||||
|
"kube-apisever.service"
|
||||||
|
];
|
||||||
|
path = with pkgs; [
|
||||||
|
kubernetes
|
||||||
|
coreutils
|
||||||
|
util-linux
|
||||||
|
git
|
||||||
|
openssh
|
||||||
|
iproute2
|
||||||
|
ethtool
|
||||||
|
iptables
|
||||||
|
socat
|
||||||
|
thin-provisioning-tools
|
||||||
|
];
|
||||||
|
preStart = ''
|
||||||
|
${generateKubeletBootstrapKubeconfig}
|
||||||
|
${seedContainerImages}
|
||||||
|
'';
|
||||||
|
script = lib.strings.concatStringsSep " " (
|
||||||
|
[
|
||||||
|
"kubelet"
|
||||||
|
"--config=${kubeletConfig}"
|
||||||
|
"--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubeconfig"
|
||||||
|
"--kubeconfig=/var/lib/kubelet/kubeconfig"
|
||||||
|
"--cert-dir=/var/lib/kubelet/pki"
|
||||||
|
"--hostname-override=${lib.strings.toLower config.networking.fqdnOrHostName}"
|
||||||
|
"--kubeconfig=/etc/kubernetes/bootstrap-kubeconfig"
|
||||||
|
"--pod-infra-container-image=pause"
|
||||||
|
"--root-dir=/var/lib/kubelet"
|
||||||
|
]
|
||||||
|
++ lib.lists.optional (taints != "") [
|
||||||
|
"--register-with-taints=${taints}"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
serviceConfig = {
|
||||||
|
Slice = "kubernetes.slice";
|
||||||
|
CPUAccounting = true;
|
||||||
|
MemoryAccounting = true;
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = "1000ms";
|
||||||
|
WorkingDirectory = "/var/lib/kubelet";
|
||||||
|
};
|
||||||
|
unitConfig.StartLimitIntervalSec = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
kube-proxy = {
|
||||||
|
description = "Kubernetes Proxy";
|
||||||
|
wantedBy = [ "kubernetes.target" ];
|
||||||
|
after = [ "kube-apiserver.service" ];
|
||||||
|
path = with pkgs; [
|
||||||
|
kubernetes
|
||||||
|
iptables
|
||||||
|
conntrack-tools
|
||||||
|
];
|
||||||
|
script = lib.strings.concatStringsSep " " [
|
||||||
|
"kube-proxy"
|
||||||
|
"--bind-address=${cfg.proxy.address}"
|
||||||
|
"--cluster-cidr=${cfg.kubelet.cidr}"
|
||||||
|
"--hostname-override=${lib.strings.toLower config.networking.fqdnOrHostName}"
|
||||||
|
"--kubeconfig=${
|
||||||
|
cfg.lib.mkKubeConfig "kube-proxy" cfg.cas.kubernetes.crt cfg.certs.accounts.proxy.crt
|
||||||
|
cfg.certs.accounts.proxy.key
|
||||||
|
}"
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
Slice = "kubernetes.slice";
|
||||||
|
WorkingDirectory = "/var/lib/kubernetes";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 5;
|
||||||
|
};
|
||||||
|
unitConfig.StartLimitIntervalSec = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.firewall.enable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
# only master
|
||||||
|
(lib.mkIf (lib.all (m: m == "master") cfg.roles) {
|
||||||
|
services.kubernetes.kubelet.taints = {
|
||||||
|
unschedulable = {
|
||||||
|
value = "true";
|
||||||
|
effect = "NoSchedule";
|
||||||
|
};
|
||||||
|
"node-role.kubernetes.io/master" = {
|
||||||
|
value = "true";
|
||||||
|
effect = "NoSchedule";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
# master
|
||||||
|
(lib.mkIf (lib.elem "master" cfg.roles) {
|
||||||
|
services = {
|
||||||
|
etcd = {
|
||||||
|
enable = true;
|
||||||
|
name = cfg.address;
|
||||||
|
keyFile = cfg.certs.etcd.server.key;
|
||||||
|
certFile = cfg.certs.etcd.server.crt;
|
||||||
|
trustedCaFile = cfg.cas.etcd.crt;
|
||||||
|
peerKeyFile = cfg.certs.etcd.peer.key;
|
||||||
|
peerCertFile = cfg.certs.etcd.peer.crt;
|
||||||
|
peerTrustedCaFile = cfg.cas.etcd.crt;
|
||||||
|
clientCertAuth = true;
|
||||||
|
peerClientCertAuth = true;
|
||||||
|
listenClientUrls = [ "https://0.0.0.0:2379" ];
|
||||||
|
listenPeerUrls = [ "https://0.0.0.0:2380" ];
|
||||||
|
advertiseClientUrls = [ "https://${cfg.address}:2379" ];
|
||||||
|
initialCluster = [ "${cfg.address}=https://${cfg.address}:2380" ];
|
||||||
|
initialAdvertisePeerUrls = [ "https://${cfg.address}:2380" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services = {
|
||||||
|
kube-apiserver = {
|
||||||
|
description = "Kubernetes API Server";
|
||||||
|
wantedBy = [ "kubernetes.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
path = with pkgs; [ kubernetes ];
|
||||||
|
script = lib.strings.concatStringsSep " " [
|
||||||
|
"kube-apiserver"
|
||||||
|
"--allow-privileged=true"
|
||||||
|
"--authorization-mode=RBAC,Node"
|
||||||
|
"--bind-address=${cfg.apiserver.address}"
|
||||||
|
"--secure-port=${toString cfg.apiserver.port}"
|
||||||
|
"--client-ca-file=${cfg.cas.kubernetes.crt}"
|
||||||
|
"--tls-cert-file=${cfg.certs.apiserver.server.crt}"
|
||||||
|
"--tls-private-key-file=${cfg.certs.apiserver.server.key}"
|
||||||
|
"--enable-admission-plugins=${
|
||||||
|
lib.strings.concatStringsSep "," [
|
||||||
|
"NamespaceLifecycle"
|
||||||
|
"LimitRanger"
|
||||||
|
"ServiceAccount"
|
||||||
|
"ResourceQuota"
|
||||||
|
"DefaultStorageClass"
|
||||||
|
"DefaultTolerationSeconds"
|
||||||
|
"NodeRestriction"
|
||||||
|
]
|
||||||
|
}"
|
||||||
|
"--etcd-servers=${
|
||||||
|
lib.strings.concatStringsSep "," [
|
||||||
|
"https://${cfg.address}:2379"
|
||||||
|
"https://127.0.0.1:2379"
|
||||||
|
]
|
||||||
|
}"
|
||||||
|
"--etcd-cafile=${cfg.cas.etcd.crt}"
|
||||||
|
"--etcd-certfile=${cfg.certs.apiserver.etcdClient.crt}"
|
||||||
|
"--etcd-keyfile=${cfg.certs.apiserver.etcdClient.key}"
|
||||||
|
"--kubelet-certificate-authority=${cfg.cas.kubernetes.crt}"
|
||||||
|
"--kubelet-client-certificate=${cfg.certs.apiserver.kubeletClient.crt}"
|
||||||
|
"--kubelet-client-key=${cfg.certs.apiserver.kubeletClient.key}"
|
||||||
|
"--proxy-client-cert-file=${cfg.certs.frontProxy.crt}"
|
||||||
|
"--proxy-client-key-file=${cfg.certs.frontProxy.key}"
|
||||||
|
"--runtime-config=authentication.k8s.io/v1beta1=true"
|
||||||
|
"--api-audiences=api,https://kubernetes.default.svc"
|
||||||
|
"--service-account-issuer=https://kubernetes.default.svc"
|
||||||
|
"--service-account-signing-key-file=${cfg.certs.serviceAccount.private}"
|
||||||
|
"--service-account-key-file=${cfg.certs.serviceAccount.public}"
|
||||||
|
"--service-cluster-ip-range=${cfg.cidr}"
|
||||||
|
"--storage-backend=etcd3"
|
||||||
|
"--enable-bootstrap-token-auth=true"
|
||||||
|
"--token-auth-file=${cfg.apiserver.bootstrapTokenFile}"
|
||||||
|
"--requestheader-client-ca-file=${cfg.cas.frontProxy.crt}"
|
||||||
|
"--requestheader-allowed-names=front-proxy-client"
|
||||||
|
"--requestheader-extra-headers-prefix=X-Remote-Extra-"
|
||||||
|
"--requestheader-group-headers=X-Remote-Group"
|
||||||
|
"--requestheader-username-headers=X-Remote-User"
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
Slice = "kubernetes.slice";
|
||||||
|
WorkingDirectory = "/var/lib/kubernetes";
|
||||||
|
User = "kubernetes";
|
||||||
|
Group = "kubernetes";
|
||||||
|
AmbientCapabilities = "cap_net_bind_service";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 5;
|
||||||
|
};
|
||||||
|
|
||||||
|
unitConfig.StartLimitIntervalSec = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
kube-scheduler = {
|
||||||
|
description = "Kubernetes Scheduler";
|
||||||
|
wantedBy = [ "kubernetes.target" ];
|
||||||
|
after = [ "kube-apiserver.service" ];
|
||||||
|
path = with pkgs; [ kubernetes ];
|
||||||
|
script = lib.strings.concatStringsSep " " [
|
||||||
|
"kube-scheduler"
|
||||||
|
"--bind-address=${cfg.scheduler.address}"
|
||||||
|
"--secure-port=${toString cfg.scheduler.port}"
|
||||||
|
"--leader-elect=true"
|
||||||
|
"--kubeconfig=${
|
||||||
|
cfg.lib.mkKubeConfig "kube-scheduler" cfg.cas.kubernetes.crt cfg.certs.accounts.scheduler.crt
|
||||||
|
cfg.certs.accounts.scheduler.key
|
||||||
|
}"
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
Slice = "kubernetes.slice";
|
||||||
|
WorkingDirectory = "/var/lib/kubernetes";
|
||||||
|
User = "kubernetes";
|
||||||
|
Group = "kubernetes";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 5;
|
||||||
|
};
|
||||||
|
unitConfig.StartLimitIntervalSec = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
kube-controller-manager = {
|
||||||
|
description = "Kubernetes Controller Manager";
|
||||||
|
wantedBy = [ "kubernetes.target" ];
|
||||||
|
after = [ "kube-apiserver.service" ];
|
||||||
|
path = with pkgs; [ kubernetes ];
|
||||||
|
script = lib.strings.concatStringsSep " " [
|
||||||
|
"kube-controller-manager"
|
||||||
|
"--allocate-node-cidrs=true"
|
||||||
|
"--bind-address=${cfg.controllerManager.address}"
|
||||||
|
"--secure-port=${toString cfg.controllerManager.port}"
|
||||||
|
"--cluster-cidr=${cfg.kubelet.cidr}"
|
||||||
|
"--kubeconfig=${
|
||||||
|
cfg.lib.mkKubeConfig "kube-controller-manager" cfg.cas.kubernetes.crt
|
||||||
|
cfg.certs.accounts.controllerManager.crt
|
||||||
|
cfg.certs.accounts.controllerManager.key
|
||||||
|
}"
|
||||||
|
"--leader-elect=true"
|
||||||
|
"--root-ca-file=${cfg.cas.kubernetes.crt}"
|
||||||
|
"--service-account-private-key-file=${cfg.certs.serviceAccount.private}"
|
||||||
|
"--use-service-account-credentials"
|
||||||
|
"--client-ca-file=${cfg.cas.kubernetes.crt}"
|
||||||
|
"--cluster-signing-cert-file=${cfg.cas.kubernetes.crt}"
|
||||||
|
"--cluster-signing-key-file=${cfg.cas.kubernetes.key}"
|
||||||
|
"--requestheader-client-ca-file=${cfg.cas.frontProxy.crt}"
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
Slice = "kubernetes.slice";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 30;
|
||||||
|
WorkingDirectory = "/var/lib/kubernetes";
|
||||||
|
User = "kubernetes";
|
||||||
|
Group = "kubernetes";
|
||||||
|
};
|
||||||
|
unitConfig.StartLimitIntervalSec = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
kube-addon-manager =
|
||||||
|
let
|
||||||
|
mkAddons =
|
||||||
|
addons:
|
||||||
|
lib.attrsets.mapAttrsToList (
|
||||||
|
name: addon:
|
||||||
|
(pkgs.formats.json { }).generate "${name}.json" {
|
||||||
|
apiVersion = "v1";
|
||||||
|
kind = "List";
|
||||||
|
items = addon;
|
||||||
|
}
|
||||||
|
) addons;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
description = "Kubernetes Addon Manager";
|
||||||
|
wantedBy = [ "kubernetes.target" ];
|
||||||
|
after = [ "kube-apiserver.service" ];
|
||||||
|
environment = {
|
||||||
|
ADDON_PATH = pkgs.runCommand "kube-addons" { } ''
|
||||||
|
mkdir -p $out
|
||||||
|
${lib.strings.concatMapStringsSep "\n" (a: "ln -s ${a} $out/${baseNameOf a}") (
|
||||||
|
mkAddons cfg.addonManager.addons
|
||||||
|
)}
|
||||||
|
'';
|
||||||
|
KUBECONFIG =
|
||||||
|
cfg.lib.mkKubeConfig "addon-manager" cfg.cas.kubernetes.crt cfg.certs.accounts.addonManager.crt
|
||||||
|
cfg.certs.accounts.addonManager.key;
|
||||||
|
};
|
||||||
|
path = with pkgs; [
|
||||||
|
kubernetes
|
||||||
|
gawk
|
||||||
|
];
|
||||||
|
preStart = ''
|
||||||
|
export KUBECONFIG=${cfg.kubeconfigs.admin}
|
||||||
|
kubectl apply -f ${lib.strings.concatStringsSep " \\\n -f " (mkAddons cfg.addonManager.bootstrapAddons)}
|
||||||
|
'';
|
||||||
|
script = "kube-addons";
|
||||||
|
serviceConfig = {
|
||||||
|
Slice = "kubernetes.slice";
|
||||||
|
PermissionsStartOnly = true;
|
||||||
|
WorkingDirectory = "/var/lib/kubernetes";
|
||||||
|
User = "kubernetes";
|
||||||
|
Group = "kubernetes";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 10;
|
||||||
|
};
|
||||||
|
unitConfig.StartLimitIntervalSec = 0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
|
# node
|
||||||
|
(lib.mkIf (lib.elem "node" cfg.roles) {
|
||||||
|
virtualisation.containerd = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
version = 2;
|
||||||
|
root = "/var/lib/containerd";
|
||||||
|
state = "/run/containerd";
|
||||||
|
oom_score = 0;
|
||||||
|
grpc.address = "/run/containerd/containerd.sock";
|
||||||
|
plugins."io.containerd.grpc.v1.cri" = {
|
||||||
|
containerd.runtimes.runc = {
|
||||||
|
runtime_type = "io.containerd.runc.v2";
|
||||||
|
options.SystemdCgroup = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
293
hosts/common/configs/system/kubernetes/secrets/default.nix
Normal file
293
hosts/common/configs/system/kubernetes/secrets/default.nix
Normal file
@@ -0,0 +1,293 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
sops.secrets = {
|
||||||
|
"kubernetes/ca/kubernetes/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "users";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/ca/kubernetes/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "users";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/ca/front-proxy/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/ca/front-proxy/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/ca/etcd/crt" = {
|
||||||
|
owner = "etcd";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/ca/etcd/key" = {
|
||||||
|
owner = "etcd";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/apiserver/server/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/apiserver/server/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/apiserver/etcd-client/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/apiserver/etcd-client/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/apiserver/kubelet-client/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/apiserver/kubelet-client/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/front-proxy/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/front-proxy/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/etcd/server/crt" = {
|
||||||
|
owner = "etcd";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/etcd/server/key" = {
|
||||||
|
owner = "etcd";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/etcd/peer/crt" = {
|
||||||
|
owner = "etcd";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/etcd/peer/key" = {
|
||||||
|
owner = "etcd";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/sa/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/sa/pub" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/scheduler/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/scheduler/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/controller-manager/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/controller-manager/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/addon-manager/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/addon-manager/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/proxy/crt" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/proxy/key" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/admin/crt" = {
|
||||||
|
group = "kubernetes";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/admin/key" = {
|
||||||
|
group = "kubernetes";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/token/kubelet-bootstrap/token" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/token/kubelet-bootstrap/csv" = {
|
||||||
|
owner = "kubernetes";
|
||||||
|
group = "kubernetes";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.kubernetes = {
|
||||||
|
cas = {
|
||||||
|
kubernetes = {
|
||||||
|
key = config.sops.secrets."kubernetes/ca/kubernetes/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/ca/kubernetes/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
frontProxy = {
|
||||||
|
key = config.sops.secrets."kubernetes/ca/front-proxy/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/ca/front-proxy/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
etcd = {
|
||||||
|
key = config.sops.secrets."kubernetes/ca/etcd/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/ca/etcd/crt".path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
certs = {
|
||||||
|
apiserver = {
|
||||||
|
server = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/apiserver/server/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/apiserver/server/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
etcdClient = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/apiserver/etcd-client/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/apiserver/etcd-client/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
kubeletClient = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/apiserver/kubelet-client/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/apiserver/kubelet-client/crt".path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
etcd = {
|
||||||
|
server = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/etcd/server/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/etcd/server/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
peer = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/etcd/peer/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/etcd/peer/crt".path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
frontProxy = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/front-proxy/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/front-proxy/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
serviceAccount = {
|
||||||
|
private = config.sops.secrets."kubernetes/cert/sa/key".path;
|
||||||
|
public = config.sops.secrets."kubernetes/cert/sa/pub".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
accounts = {
|
||||||
|
scheduler = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/accounts/scheduler/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/accounts/scheduler/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
controllerManager = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/accounts/controller-manager/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/accounts/controller-manager/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
addonManager = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/accounts/addon-manager/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/accounts/addon-manager/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
proxy = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/accounts/proxy/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/accounts/proxy/crt".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
admin = {
|
||||||
|
key = config.sops.secrets."kubernetes/cert/accounts/admin/key".path;
|
||||||
|
crt = config.sops.secrets."kubernetes/cert/accounts/admin/crt".path;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
kubelet.bootstrapToken = config.sops.secrets."kubernetes/token/kubelet-bootstrap/token".path;
|
||||||
|
|
||||||
|
apiserver.bootstrapTokenFile = config.sops.secrets."kubernetes/token/kubelet-bootstrap/csv".path;
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services = {
|
||||||
|
kubelet.after = [ "sops-nix.service" ];
|
||||||
|
kube-apiserver.after = [ "sops-nix.service" ];
|
||||||
|
kube-controller-manager.after = [ "sops-nix.service" ];
|
||||||
|
kube-scheduler.after = [ "sops-nix.service" ];
|
||||||
|
kube-proxy.after = [ "sops-nix.service" ];
|
||||||
|
kube-addon-manager.after = [ "sops-nix.service" ];
|
||||||
|
etcd.after = [ "sops-nix.service" ];
|
||||||
|
};
|
||||||
|
}
|
207
hosts/common/configs/system/kubernetes/secrets/generate-secrets.sh
Executable file
207
hosts/common/configs/system/kubernetes/secrets/generate-secrets.sh
Executable file
@@ -0,0 +1,207 @@
|
|||||||
|
#!/usr/bin/env -S nix shell nixpkgs#openssl nixpkgs#yq-go nixpkgs#sops -c bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
generate_ca() {
|
||||||
|
local target_dir=$1
|
||||||
|
local ca_name=$2
|
||||||
|
local ca_days=$3
|
||||||
|
local cn=$4
|
||||||
|
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
local ca_key=${target_dir}/${ca_name}.key
|
||||||
|
local ca_cert=${target_dir}/${ca_name}.crt
|
||||||
|
|
||||||
|
openssl genrsa -out "${ca_key}" 2048
|
||||||
|
openssl req -x509 -new -nodes -key "${ca_key}" -days "${ca_days}" -out "${ca_cert}" -subj "/CN=${cn}"
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_alt_names() {
|
||||||
|
local hosts=("$@")
|
||||||
|
local dns=0
|
||||||
|
local ip=0
|
||||||
|
local alt_names=""
|
||||||
|
|
||||||
|
for host in "${hosts[@]}"; do
|
||||||
|
if [[ ${host} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
alt_names="${alt_names}IP.${ip} = ${host}\n"
|
||||||
|
((ip++))
|
||||||
|
else
|
||||||
|
alt_names="${alt_names}DNS.${dns} = ${host}\n"
|
||||||
|
((dns++))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo -e "${alt_names}"
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_cnf() {
|
||||||
|
local target_dir=$1
|
||||||
|
local cnf_name=$2
|
||||||
|
local cn=$3
|
||||||
|
local hosts=("${@:4}")
|
||||||
|
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
local cnf_file=${target_dir}/${cnf_name}.cnf
|
||||||
|
|
||||||
|
cat <<EOF > "${cnf_file}"
|
||||||
|
[req]
|
||||||
|
prompt = no
|
||||||
|
|
||||||
|
[ req_ext ]
|
||||||
|
subjectAltName = @alt_names
|
||||||
|
|
||||||
|
[ alt_names ]
|
||||||
|
$(generate_alt_names "${hosts[@]}")
|
||||||
|
|
||||||
|
[ v3_ext ]
|
||||||
|
authorityKeyIdentifier=keyid,issuer:always
|
||||||
|
basicConstraints=CA:FALSE
|
||||||
|
keyUsage=keyEncipherment,dataEncipherment,digitalSignature
|
||||||
|
extendedKeyUsage=serverAuth,clientAuth
|
||||||
|
subjectAltName=@alt_names
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_crt() {
|
||||||
|
local target_dir=$1
|
||||||
|
local cert_name=$2
|
||||||
|
local cert_days=$3
|
||||||
|
local cn=$4
|
||||||
|
local o=$5
|
||||||
|
local ca_key=$6
|
||||||
|
local ca_cert=$7
|
||||||
|
local hosts=("${@:8}")
|
||||||
|
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
local cert_key=${target_dir}/${cert_name}.key
|
||||||
|
local cert_csr=${target_dir}/${cert_name}.csr
|
||||||
|
local cert_cert=${target_dir}/${cert_name}.crt
|
||||||
|
|
||||||
|
openssl genrsa -out "${cert_key}" 2048
|
||||||
|
|
||||||
|
local subject="/CN=${cn}"
|
||||||
|
if [ -n "${o}" ]; then
|
||||||
|
subject="${subject}/O=${o}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${hosts}" ]; then
|
||||||
|
generate_cnf "${target_dir}" "${cert_name}" "${cn}" "${hosts[@]}"
|
||||||
|
openssl req -new -key "${cert_key}" -out "${cert_csr}" -subj "${subject}" -config "${target_dir}"/"${cert_name}".cnf
|
||||||
|
openssl x509 -req -in "${cert_csr}" -CA "${ca_cert}" -CAkey "${ca_key}" -CAcreateserial -out "${cert_cert}" -days "${cert_days}" -extfile "${target_dir}"/"${cert_name}".cnf -extensions v3_ext
|
||||||
|
else
|
||||||
|
openssl req -new -key "${cert_key}" -out "${cert_csr}" -subj "${subject}"
|
||||||
|
openssl x509 -req -in "${cert_csr}" -CA "${ca_cert}" -CAkey "${ca_key}" -CAcreateserial -out "${cert_cert}" -days "${cert_days}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_key_pair() {
|
||||||
|
local target_dir=$1
|
||||||
|
local key_name=$2
|
||||||
|
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
local private_key=${target_dir}/${key_name}.key
|
||||||
|
local public_key=${target_dir}/${key_name}.pub
|
||||||
|
|
||||||
|
openssl genrsa -out "${private_key}" 2048
|
||||||
|
openssl rsa -in "${private_key}" -pubout -out "${public_key}"
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_auth_token() {
|
||||||
|
local target_dir=$1
|
||||||
|
local token_name=$2
|
||||||
|
local user=$3
|
||||||
|
local id=$4
|
||||||
|
local groups=$5
|
||||||
|
|
||||||
|
mkdir -p "${target_dir}"
|
||||||
|
local token_file="${target_dir}/${token_name}.token"
|
||||||
|
local token_auth_file="${target_dir}/${token_name}.csv"
|
||||||
|
|
||||||
|
token="$(head -c 16 /dev/urandom | od -An -t x | tr -d ' ')"
|
||||||
|
echo "${token}" > "${token_file}"
|
||||||
|
echo "${token},${user},${id},\"${groups}\"" > "${token_auth_file}"
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFAULT_CA_DAYS=3650
|
||||||
|
|
||||||
|
if [[ -z "$SOPS_AGE_KEY_FILE" ]]; then
|
||||||
|
echo "Please set the SOPS_AGE_KEY_FILE environment variable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
hostname=${1:-$(hostname)}
|
||||||
|
|
||||||
|
if [ -z "${hostname}" ]; then
|
||||||
|
echo "Usage: $0 [hostname]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
generate_ca out/ca kubernetes ${DEFAULT_CA_DAYS} kubernetes-ca ""
|
||||||
|
generate_ca out/ca front-proxy ${DEFAULT_CA_DAYS} kubernetes-front-proxy-ca ""
|
||||||
|
generate_ca out/ca etcd ${DEFAULT_CA_DAYS} etcd-ca ""
|
||||||
|
|
||||||
|
generate_crt out/cert/apiserver server ${DEFAULT_CA_DAYS} kube-apiserver "" out/ca/kubernetes.key out/ca/kubernetes.crt "kubernetes" "kubernetes.default" "kubernetes.default.svc" "kubernetes.default.svc.cluster" "kubernetes.default.svc.cluster.local" "localhost" "10.0.0.1" "127.0.0.1"
|
||||||
|
generate_crt out/cert/apiserver etcd-client ${DEFAULT_CA_DAYS} kube-apiserver-etcd-client "" out/ca/etcd.key out/ca/etcd.crt ""
|
||||||
|
generate_crt out/cert/apiserver kubelet-client ${DEFAULT_CA_DAYS} kube-apiserver-kubelet-client "" out/ca/kubernetes.key out/ca/kubernetes.crt ""
|
||||||
|
generate_crt out/cert/etcd server ${DEFAULT_CA_DAYS} kube-etcd "" out/ca/etcd.key out/ca/etcd.crt "etcd.local" "etcd.cluster.local" "localhost" "127.0.0.1"
|
||||||
|
generate_crt out/cert/etcd peer ${DEFAULT_CA_DAYS} kube-etcd-peer "" out/ca/etcd.key out/ca/etcd.crt "etcd.local" "etcd.cluster.local" "localhost" "127.0.0.1"
|
||||||
|
generate_crt out/cert front-proxy ${DEFAULT_CA_DAYS} front-proxy-client "" out/ca/front-proxy.key out/ca/front-proxy.crt ""
|
||||||
|
|
||||||
|
generate_key_pair out/cert sa
|
||||||
|
|
||||||
|
generate_crt out/cert/accounts scheduler ${DEFAULT_CA_DAYS} system:kube-scheduler "" out/ca/kubernetes.key out/ca/kubernetes.crt ""
|
||||||
|
generate_crt out/cert/accounts controller-manager ${DEFAULT_CA_DAYS} system:kube-controller-manager "" out/ca/kubernetes.key out/ca/kubernetes.crt ""
|
||||||
|
generate_crt out/cert/accounts addon-manager ${DEFAULT_CA_DAYS} system:kube-addon-manager "" out/ca/kubernetes.key out/ca/kubernetes.crt ""
|
||||||
|
generate_crt out/cert/accounts proxy ${DEFAULT_CA_DAYS} system:kube-proxy "" out/ca/kubernetes.key out/ca/kubernetes.crt ""
|
||||||
|
generate_crt out/cert/accounts admin ${DEFAULT_CA_DAYS} kubernetes-admin system:masters out/ca/kubernetes.key out/ca/kubernetes.crt ""
|
||||||
|
generate_crt out/cert/accounts users ${DEFAULT_CA_DAYS} kubernetes-users system:masters out/ca/kubernetes.key out/ca/kubernetes.crt ""
|
||||||
|
|
||||||
|
generate_auth_token out/token kubelet-bootstrap "kubelet-bootstrap" 10001 "system:bootstrappers"
|
||||||
|
|
||||||
|
sops_config="../../../../../$(hostname)/secrets/sops.yaml"
|
||||||
|
secrets_file="../../../../../$(hostname)/secrets/secrets.yaml"
|
||||||
|
decrypted_secrets_file="../../../../../$(hostname)/secrets/.decrypted~secrets.yaml"
|
||||||
|
sops -d "${secrets_file}" > "${decrypted_secrets_file}"
|
||||||
|
|
||||||
|
yq -i '
|
||||||
|
del(.kubernetes) |
|
||||||
|
.kubernetes.ca.kubernetes.crt = load_str("out/ca/kubernetes.crt") |
|
||||||
|
.kubernetes.ca.kubernetes.key = load_str("out/ca/kubernetes.key") |
|
||||||
|
.kubernetes.ca.front-proxy.crt = load_str("out/ca/front-proxy.crt") |
|
||||||
|
.kubernetes.ca.front-proxy.key = load_str("out/ca/front-proxy.key") |
|
||||||
|
.kubernetes.ca.etcd.crt = load_str("out/ca/etcd.crt") |
|
||||||
|
.kubernetes.ca.etcd.key = load_str("out/ca/etcd.key") |
|
||||||
|
.kubernetes.cert.apiserver.server.crt = load_str("out/cert/apiserver/server.crt") |
|
||||||
|
.kubernetes.cert.apiserver.server.key = load_str("out/cert/apiserver/server.key") |
|
||||||
|
.kubernetes.cert.apiserver.etcd-client.crt = load_str("out/cert/apiserver/etcd-client.crt") |
|
||||||
|
.kubernetes.cert.apiserver.etcd-client.key = load_str("out/cert/apiserver/etcd-client.key") |
|
||||||
|
.kubernetes.cert.apiserver.kubelet-client.crt = load_str("out/cert/apiserver/kubelet-client.crt") |
|
||||||
|
.kubernetes.cert.apiserver.kubelet-client.key = load_str("out/cert/apiserver/kubelet-client.key") |
|
||||||
|
.kubernetes.cert.etcd.server.crt = load_str("out/cert/etcd/server.crt") |
|
||||||
|
.kubernetes.cert.etcd.server.key = load_str("out/cert/etcd/server.key") |
|
||||||
|
.kubernetes.cert.etcd.peer.crt = load_str("out/cert/etcd/peer.crt") |
|
||||||
|
.kubernetes.cert.etcd.peer.key = load_str("out/cert/etcd/peer.key") |
|
||||||
|
.kubernetes.cert.front-proxy.crt = load_str("out/cert/front-proxy.crt") |
|
||||||
|
.kubernetes.cert.front-proxy.key = load_str("out/cert/front-proxy.key") |
|
||||||
|
.kubernetes.cert.sa.key = load_str("out/cert/sa.key") |
|
||||||
|
.kubernetes.cert.sa.pub = load_str("out/cert/sa.pub") |
|
||||||
|
.kubernetes.cert.accounts.scheduler.crt = load_str("out/cert/accounts/scheduler.crt") |
|
||||||
|
.kubernetes.cert.accounts.scheduler.key = load_str("out/cert/accounts/scheduler.key") |
|
||||||
|
.kubernetes.cert.accounts.controller-manager.crt = load_str("out/cert/accounts/controller-manager.crt") |
|
||||||
|
.kubernetes.cert.accounts.controller-manager.key = load_str("out/cert/accounts/controller-manager.key") |
|
||||||
|
.kubernetes.cert.accounts.addon-manager.crt = load_str("out/cert/accounts/addon-manager.crt") |
|
||||||
|
.kubernetes.cert.accounts.addon-manager.key = load_str("out/cert/accounts/addon-manager.key") |
|
||||||
|
.kubernetes.cert.accounts.proxy.crt = load_str("out/cert/accounts/proxy.crt") |
|
||||||
|
.kubernetes.cert.accounts.proxy.key = load_str("out/cert/accounts/proxy.key") |
|
||||||
|
.kubernetes.cert.accounts.admin.crt = load_str("out/cert/accounts/admin.crt") |
|
||||||
|
.kubernetes.cert.accounts.admin.key = load_str("out/cert/accounts/admin.key") |
|
||||||
|
.kubernetes.cert.accounts.users.crt = load_str("out/cert/accounts/users.crt") |
|
||||||
|
.kubernetes.cert.accounts.users.key = load_str("out/cert/accounts/users.key") |
|
||||||
|
.kubernetes.token.kubelet-bootstrap.token = load_str("out/token/kubelet-bootstrap.token") |
|
||||||
|
.kubernetes.token.kubelet-bootstrap.csv = load_str("out/token/kubelet-bootstrap.csv")
|
||||||
|
' "${decrypted_secrets_file}"
|
||||||
|
|
||||||
|
sops --config "${sops_config}" -e "${decrypted_secrets_file}" > "${secrets_file}"
|
||||||
|
rm -rf ${decrypted_secrets_file} out
|
@@ -1,9 +1,4 @@
|
|||||||
{
|
{ config, pkgs, ... }:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
{
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
libvirtd = {
|
libvirtd = {
|
||||||
@@ -17,10 +12,7 @@
|
|||||||
spiceUSBRedirection.enable = true;
|
spiceUSBRedirection.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services.libvirtd-network-default = {
|
||||||
libvirtd.after = [ "NetworkManager.service" ];
|
|
||||||
|
|
||||||
libvirtd-network-default = {
|
|
||||||
description = "Start Default Virtual Network for Libvirt";
|
description = "Start Default Virtual Network for Libvirt";
|
||||||
script = "${config.virtualisation.libvirtd.package}/bin/virsh net-start default";
|
script = "${config.virtualisation.libvirtd.package}/bin/virsh net-start default";
|
||||||
preStop = "${config.virtualisation.libvirtd.package}/bin/virsh net-destroy default";
|
preStop = "${config.virtualisation.libvirtd.package}/bin/virsh net-destroy default";
|
||||||
@@ -31,7 +23,6 @@
|
|||||||
wantedBy = [ "libvirtd.service" ];
|
wantedBy = [ "libvirtd.service" ];
|
||||||
after = [ "libvirtd.service" ];
|
after = [ "libvirtd.service" ];
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
systemPackages = [ config.virtualisation.libvirtd.qemu.swtpm.package ];
|
systemPackages = [ config.virtualisation.libvirtd.qemu.swtpm.package ];
|
||||||
@@ -41,7 +32,7 @@
|
|||||||
"ovmf/edk2-i386-vars.fd".source =
|
"ovmf/edk2-i386-vars.fd".source =
|
||||||
"${config.virtualisation.libvirtd.qemu.package}/share/qemu/edk2-i386-vars.fd";
|
"${config.virtualisation.libvirtd.qemu.package}/share/qemu/edk2-i386-vars.fd";
|
||||||
};
|
};
|
||||||
persistence."/persist/state"."/var/lib/libvirt" = { };
|
persistence."/persist"."/var/lib/libvirt" = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.virt-manager.enable = true;
|
programs.virt-manager.enable = true;
|
||||||
|
10
hosts/common/configs/system/networking/default.nix
Normal file
10
hosts/common/configs/system/networking/default.nix
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
{
|
||||||
|
networking.networkmanager.enable = true;
|
||||||
|
|
||||||
|
environment.persistence."/persist"."/etc/NetworkManager/system-connections" = { };
|
||||||
|
|
||||||
|
systemd.services.NetworkManager.after = [
|
||||||
|
config.environment.persistence."/persist"."/etc/NetworkManager/system-connections".mount
|
||||||
|
];
|
||||||
|
}
|
@@ -1,10 +0,0 @@
|
|||||||
{ config, ... }:
|
|
||||||
{
|
|
||||||
networking.networkmanager.enable = true;
|
|
||||||
|
|
||||||
environment.persistence."/persist/state"."/etc/NetworkManager/system-connections" = { };
|
|
||||||
|
|
||||||
systemd.services.NetworkManager.after = [
|
|
||||||
config.environment.persistence."/persist/state"."/etc/NetworkManager/system-connections".mount
|
|
||||||
];
|
|
||||||
}
|
|
@@ -1,5 +1,3 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
if [[ "${EUID}" -ne 0 ]]; then
|
if [[ "${EUID}" -ne 0 ]]; then
|
||||||
echo "Please run the script as root."
|
echo "Please run the script as root."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -18,8 +16,13 @@ if [[ -e /mnt/btrfs && -n $(mountpoint -q /mnt/btrfs) ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$DEVICE" ]]; then
|
||||||
|
echo "Error: DEVICE variable is not set."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p /mnt/btrfs
|
mkdir -p /mnt/btrfs
|
||||||
mount "$DEVICE" /mnt/btrfs
|
mount "/dev/mapper/$DEVICE" /mnt/btrfs
|
||||||
|
|
||||||
if [[ -e /mnt/btrfs/@.bak ]]; then
|
if [[ -e /mnt/btrfs/@.bak ]]; then
|
||||||
if [[ -n "$(ls -A /mnt/btrfs/@.bak)" ]]; then
|
if [[ -n "$(ls -A /mnt/btrfs/@.bak)" ]]; then
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
iputils
|
iputils
|
||||||
jq
|
jq
|
||||||
nix
|
nix
|
||||||
sops
|
|
||||||
inputs.disko.packages.${system}.disko
|
inputs.disko.packages.${system}.disko
|
||||||
];
|
];
|
||||||
text = builtins.readFile ./install.sh;
|
text = builtins.readFile ./install.sh;
|
||||||
@@ -16,6 +15,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
home-manager.sharedModules = [
|
home-manager.sharedModules = [
|
||||||
{ programs.zsh.initContent = builtins.readFile ./install.completion.zsh; }
|
{
|
||||||
|
programs.zsh.initExtra = builtins.readFile ./install.completion.zsh;
|
||||||
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ _nix-install_completion() {
|
|||||||
'-m[Mode: 'install' or 'repair']:mode:(install repair)'
|
'-m[Mode: 'install' or 'repair']:mode:(install repair)'
|
||||||
'-h[Host to configure]:host:($(_list_hosts))'
|
'-h[Host to configure]:host:($(_list_hosts))'
|
||||||
'-k[Key file to copy to user config]:key:($(_list_keys))'
|
'-k[Key file to copy to user config]:key:($(_list_keys))'
|
||||||
|
'-p[LUKS password file to use for encryption]:password_file:_files'
|
||||||
'-c[Copy configuration to target]'
|
'-c[Copy configuration to target]'
|
||||||
'-r[Reboot after completion]'
|
'-r[Reboot after completion]'
|
||||||
)
|
)
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 flake -m install|repair -h host [-k key] [-p password_file] [-c] [-r]"
|
echo "Usage: $0 flake -m install|repair -h host [-k key] [-p password_file] [-c] [-r]"
|
||||||
echo
|
echo
|
||||||
@@ -8,6 +6,7 @@ usage() {
|
|||||||
echo " -m mode Mode: 'install' or 'repair'."
|
echo " -m mode Mode: 'install' or 'repair'."
|
||||||
echo " -h host Host to configure."
|
echo " -h host Host to configure."
|
||||||
echo " -k key Key file to copy to user config."
|
echo " -k key Key file to copy to user config."
|
||||||
|
echo " -p password_file LUKS password file to use for encryption."
|
||||||
echo " -c Copy configuration to target."
|
echo " -c Copy configuration to target."
|
||||||
echo " -r Reboot after completion."
|
echo " -r Reboot after completion."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -49,22 +48,34 @@ check_key() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_password_file() {
|
set_password_file() {
|
||||||
SOPS_AGE_KEY_FILE="$flake/secrets/$key/key.txt"
|
if [[ -n "$password_file" ]]; then
|
||||||
export SOPS_AGE_KEY_FILE
|
if [[ ! -f "$password_file" ]]; then
|
||||||
sops --decrypt --extract "['luks']" "$flake/hosts/$host/secrets/secrets.yaml" > /tmp/keyfile
|
echo "LUKS key file '$password_file' not found."
|
||||||
unset SOPS_AGE_KEY_FILE
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ln -sf "$(realpath "$password_file")" /tmp/installer.key
|
||||||
|
else
|
||||||
|
echo "Enter password for LUKS encryption:"
|
||||||
|
IFS= read -r -s password
|
||||||
|
echo "Enter password again to confirm: "
|
||||||
|
IFS= read -r -s password_check
|
||||||
|
[ "$password" != "$password_check" ]
|
||||||
|
echo -n "$password" > /tmp/installer.key
|
||||||
|
unset password password_check
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_disk() {
|
prepare_disk() {
|
||||||
local disko_mode="$1"
|
local disko_mode="$1"
|
||||||
mkdir -p /mnt
|
mkdir -p /mnt
|
||||||
root=$(mktemp -d /mnt/install.XXXXXX)
|
root=$(mktemp -d /mnt/install.XXXXXX)
|
||||||
disko -m "$disko_mode" --yes-wipe-all-disks --root-mountpoint "$root" "$flake/hosts/$host/format.nix"
|
disko -m "$disko_mode" --yes-wipe-all-disks --root-mountpoint "$root" "$flake/hosts/$host/format.nix" --arg device "\"$device\""
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_keys() {
|
copy_keys() {
|
||||||
mkdir -p "$root/persist/state/etc/ssh"
|
mkdir -p "$root/persist/etc/ssh"
|
||||||
cp -f "$flake/hosts/$host/secrets/ssh_host_ed25519_key" "$root/persist/state/etc/ssh/ssh_host_ed25519_key"
|
cp "$flake/hosts/$host/secrets/ssh_host_ed25519_key" "$root/persist/etc/ssh/ssh_host_ed25519_key"
|
||||||
|
|
||||||
for path in "$flake/hosts/$host/users"/*; do
|
for path in "$flake/hosts/$host/users"/*; do
|
||||||
if [[ -z "$key" ]]; then
|
if [[ -z "$key" ]]; then
|
||||||
@@ -73,17 +84,9 @@ copy_keys() {
|
|||||||
|
|
||||||
local user
|
local user
|
||||||
user=$(basename "$path")
|
user=$(basename "$path")
|
||||||
|
mkdir -p "$root/persist/home/$user/.config/sops-nix"
|
||||||
mkdir -p "$root/persist/state/home/$user/.config/sops-nix"
|
cp "$flake/secrets/$key/key.txt" "$root/persist/home/$user/.config/sops-nix/key.txt"
|
||||||
cp -f "$flake/secrets/$key/key.txt" "$root/persist/state/home/$user/.config/sops-nix/key.txt"
|
chown -R "$(cat "$flake/hosts/$host/users/$user/uid"):100" "$root/persist/home/$user"
|
||||||
|
|
||||||
owner=$(cat "$flake/hosts/$host/users/$user/uid")
|
|
||||||
group=100
|
|
||||||
chown "$owner:$group" \
|
|
||||||
"$root/persist/state/home/$user" \
|
|
||||||
"$root/persist/state/home/$user/.config" \
|
|
||||||
"$root/persist/state/home/$user/.config/sops-nix" \
|
|
||||||
"$root/persist/state/home/$user/.config/sops-nix/key.txt"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,9 +96,8 @@ install() {
|
|||||||
|
|
||||||
copy_config() {
|
copy_config() {
|
||||||
echo "Copying configuration..."
|
echo "Copying configuration..."
|
||||||
mkdir -p "$root/persist/user/etc/nixos"
|
rm -rf "$root/persist/etc/nixos"
|
||||||
rm -rf "$root/persist/user/etc/nixos"
|
cp -r "$flake" "$root/persist/etc/nixos"
|
||||||
cp -r "$flake" "$root/persist/user/etc/nixos"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
finish() {
|
finish() {
|
||||||
@@ -106,57 +108,66 @@ finish() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
rm -f /tmp/keyfile
|
rm -f /tmp/installer.key
|
||||||
if [[ -n "$host" ]]; then disko -m "unmount" "$flake/hosts/$host/format.nix"; fi
|
if [[ -n "$host" && -n "$device" ]]; then disko -m "unmount" "$flake/hosts/$host/format.nix" --arg device "\"$device\""; fi
|
||||||
if [[ -d "$root" ]]; then rmdir "$root"; fi
|
if [[ -d "$root" ]]; then rmdir "$root"; fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
check_root
|
||||||
check_root
|
check_network
|
||||||
check_network
|
|
||||||
|
|
||||||
if [[ "$#" -lt 1 ]]; then usage; fi
|
if [[ "$#" -lt 1 ]]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
flake="$(realpath "$1")"
|
flake="$(realpath "$1")"
|
||||||
check_flake
|
check_flake
|
||||||
shift
|
shift
|
||||||
|
|
||||||
mode=""
|
mode=""
|
||||||
host=""
|
host=""
|
||||||
key=""
|
key=""
|
||||||
copy_config_flag="false"
|
password_file=""
|
||||||
reboot_flag="false"
|
copy_config_flag="false"
|
||||||
|
reboot_flag="false"
|
||||||
|
|
||||||
while getopts "m:h:k:cr" opt; do
|
while getopts "m:h:k:p:cr" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
m) mode="$OPTARG" ;;
|
m) mode="$OPTARG" ;;
|
||||||
h) host="$OPTARG" ;;
|
h) host="$OPTARG" ;;
|
||||||
k) key="$OPTARG" ;;
|
k) key="$OPTARG" ;;
|
||||||
|
p) password_file="$OPTARG" ;;
|
||||||
c) copy_config_flag="true" ;;
|
c) copy_config_flag="true" ;;
|
||||||
r) reboot_flag="true" ;;
|
r) reboot_flag="true" ;;
|
||||||
*) usage ;;
|
*) usage ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "$mode" || -z "$host" ]]; then usage; fi
|
if [[ -z "$mode" || -z "$host" ]]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
check_host
|
check_host
|
||||||
check_key
|
check_key
|
||||||
set_password_file
|
until set_password_file; do echo "Passwords did not match, please try again."; done
|
||||||
|
|
||||||
case "$mode" in
|
device=$(grep -oP '(?<=device = ")[^"]+' "$flake/hosts/$host/default.nix")
|
||||||
install) prepare_disk "destroy,format,mount";;
|
|
||||||
repair) prepare_disk "mount";;
|
case "$mode" in
|
||||||
|
install)
|
||||||
|
prepare_disk "destroy,format,mount"
|
||||||
|
copy_keys
|
||||||
|
install
|
||||||
|
if [[ "$copy_config_flag" == "true" ]]; then copy_config; fi
|
||||||
|
if [[ "$reboot_flag" == "true" ]]; then finish; fi
|
||||||
|
;;
|
||||||
|
repair)
|
||||||
|
prepare_disk "mount"
|
||||||
|
install
|
||||||
|
if [[ "$reboot_flag" == "true" ]]; then finish; fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid mode: $mode"
|
echo "Invalid mode: $mode"
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
copy_keys
|
|
||||||
install
|
|
||||||
[[ "$copy_config_flag" == "true" ]] && copy_config
|
|
||||||
[[ "$reboot_flag" == "true" ]] && finish
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
programs.nix-ld.enable = true;
|
programs.nix-ld = {
|
||||||
|
enable = true;
|
||||||
|
libraries = [ ];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
nixpkgs.overlays = [
|
|
||||||
(final: prev: {
|
|
||||||
nix-update = prev.nix-update.overrideAttrs (oldAttrs: {
|
|
||||||
patches = oldAttrs.patches or [ ] ++ [ ./source-attribute.patch ];
|
|
||||||
});
|
|
||||||
})
|
|
||||||
];
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [ nix-update ];
|
|
||||||
}
|
|
@@ -1,127 +0,0 @@
|
|||||||
diff --git a/nix_update/__init__.py b/nix_update/__init__.py
|
|
||||||
index 89bbe45..93f9322 100644
|
|
||||||
--- a/nix_update/__init__.py
|
|
||||||
+++ b/nix_update/__init__.py
|
|
||||||
@@ -124,6 +124,12 @@ def parse_args(args: list[str]) -> Options:
|
|
||||||
default=[],
|
|
||||||
)
|
|
||||||
|
|
||||||
+ parser.add_argument(
|
|
||||||
+ "--src-attr",
|
|
||||||
+ help="Src attribute",
|
|
||||||
+ default="src",
|
|
||||||
+ )
|
|
||||||
+
|
|
||||||
a = parser.parse_args(args)
|
|
||||||
extra_flags = ["--extra-experimental-features", "flakes nix-command"]
|
|
||||||
if a.system:
|
|
||||||
@@ -146,6 +152,7 @@ def parse_args(args: list[str]) -> Options:
|
|
||||||
version=a.version,
|
|
||||||
version_preference=VersionPreference.from_str(a.version),
|
|
||||||
attribute=a.attribute,
|
|
||||||
+ source_attribute=a.src_attr,
|
|
||||||
test=a.test,
|
|
||||||
version_regex=a.version_regex,
|
|
||||||
review=a.review,
|
|
||||||
diff --git a/nix_update/eval.py b/nix_update/eval.py
|
|
||||||
index 1767056..f85ea69 100644
|
|
||||||
--- a/nix_update/eval.py
|
|
||||||
+++ b/nix_update/eval.py
|
|
||||||
@@ -105,12 +105,19 @@ class Package:
|
|
||||||
def eval_expression(
|
|
||||||
escaped_import_path: str,
|
|
||||||
attr: str,
|
|
||||||
+ source_attr: str,
|
|
||||||
flake: bool,
|
|
||||||
system: str | None,
|
|
||||||
override_filename: str | None,
|
|
||||||
) -> str:
|
|
||||||
system = f'"{system}"' if system else "builtins.currentSystem"
|
|
||||||
|
|
||||||
+ source_attrs = source_attr.rpartition(".")
|
|
||||||
+ source_attr_last = source_attrs[-1] or source_attr
|
|
||||||
+ source_attr_all_but_last = (
|
|
||||||
+ f".{source_attrs[0]}" if source_attr_last != source_attr else ""
|
|
||||||
+ )
|
|
||||||
+
|
|
||||||
if flake:
|
|
||||||
sanitize_position = (
|
|
||||||
f"""
|
|
||||||
@@ -164,8 +171,8 @@ let
|
|
||||||
raw_version_position
|
|
||||||
else if pkg ? isPhpExtension then
|
|
||||||
raw_version_position
|
|
||||||
- else if (builtins.unsafeGetAttrPos "src" pkg) != null then
|
|
||||||
- sanitizePosition (builtins.unsafeGetAttrPos "src" pkg)
|
|
||||||
+ else if (builtins.unsafeGetAttrPos "{source_attr_last}" pkg) != null then
|
|
||||||
+ sanitizePosition (builtins.unsafeGetAttrPos "{source_attr_last}" pkg{source_attr_all_but_last})
|
|
||||||
else
|
|
||||||
sanitizePosition (positionFromMeta pkg);
|
|
||||||
in {{
|
|
||||||
@@ -174,11 +181,11 @@ in {{
|
|
||||||
inherit raw_version_position;
|
|
||||||
filename = position.file;
|
|
||||||
line = position.line;
|
|
||||||
- urls = pkg.src.urls or null;
|
|
||||||
- url = pkg.src.url or null;
|
|
||||||
- rev = pkg.src.rev or null;
|
|
||||||
- tag = pkg.src.tag or null;
|
|
||||||
- hash = pkg.src.outputHash or null;
|
|
||||||
+ urls = pkg.{source_attr}.urls or null;
|
|
||||||
+ url = pkg.{source_attr}.url or null;
|
|
||||||
+ rev = pkg.{source_attr}.rev or null;
|
|
||||||
+ tag = pkg.{source_attr}.tag or null;
|
|
||||||
+ hash = pkg.{source_attr}.outputHash or null;
|
|
||||||
go_modules = pkg.goModules.outputHash or null;
|
|
||||||
go_modules_old = pkg.go-modules.outputHash or null;
|
|
||||||
cargo_deps = pkg.cargoDeps.outputHash or null;
|
|
||||||
@@ -205,7 +212,7 @@ in {{
|
|
||||||
mix_deps = pkg.mixFodDeps.outputHash or null;
|
|
||||||
tests = builtins.attrNames (pkg.passthru.tests or {{}});
|
|
||||||
has_update_script = {has_update_script};
|
|
||||||
- src_homepage = pkg.src.meta.homepage or null;
|
|
||||||
+ src_homepage = pkg.{source_attr}.meta.homepage or null;
|
|
||||||
changelog = pkg.meta.changelog or null;
|
|
||||||
maintainers = pkg.meta.maintainers or null;
|
|
||||||
}}"""
|
|
||||||
@@ -215,6 +222,7 @@ def eval_attr(opts: Options) -> Package:
|
|
||||||
expr = eval_expression(
|
|
||||||
opts.escaped_import_path,
|
|
||||||
opts.escaped_attribute,
|
|
||||||
+ opts.source_attribute,
|
|
||||||
opts.flake,
|
|
||||||
opts.system,
|
|
||||||
opts.override_filename,
|
|
||||||
diff --git a/nix_update/options.py b/nix_update/options.py
|
|
||||||
index 2d07b77..ab5c305 100644
|
|
||||||
--- a/nix_update/options.py
|
|
||||||
+++ b/nix_update/options.py
|
|
||||||
@@ -8,6 +8,7 @@ from .version.version import VersionPreference
|
|
||||||
@dataclass
|
|
||||||
class Options:
|
|
||||||
attribute: str
|
|
||||||
+ source_attribute: str = "src"
|
|
||||||
flake: bool = False
|
|
||||||
version: str = "stable"
|
|
||||||
version_preference: VersionPreference = VersionPreference.STABLE
|
|
||||||
@@ -33,4 +34,7 @@ class Options:
|
|
||||||
|
|
||||||
def __post_init__(self) -> None:
|
|
||||||
self.escaped_attribute = ".".join(map(json.dumps, self.attribute.split(".")))
|
|
||||||
+ self.escaped_source_attribute = ".".join(
|
|
||||||
+ map(json.dumps, self.source_attribute.split("."))
|
|
||||||
+ )
|
|
||||||
self.escaped_import_path = json.dumps(self.import_path)
|
|
||||||
diff --git a/nix_update/update.py b/nix_update/update.py
|
|
||||||
index 82b7bc5..464bf3d 100644
|
|
||||||
--- a/nix_update/update.py
|
|
||||||
+++ b/nix_update/update.py
|
|
||||||
@@ -155,7 +155,7 @@ def git_prefetch(x: tuple[str, tuple[str, str]]) -> tuple[str, str]:
|
|
||||||
|
|
||||||
|
|
||||||
def update_src_hash(opts: Options, filename: str, current_hash: str) -> None:
|
|
||||||
- target_hash = nix_prefetch(opts, "src")
|
|
||||||
+ target_hash = nix_prefetch(opts, opts.source_attribute)
|
|
||||||
replace_hash(filename, current_hash, target_hash)
|
|
||||||
|
|
||||||
|
|
@@ -1,20 +1,9 @@
|
|||||||
{ config, inputs, ... }:
|
{ config, inputs, ... }:
|
||||||
{
|
{
|
||||||
sops = {
|
sops.secrets."nix/accessTokens/github" = {
|
||||||
secrets = {
|
sopsFile = ../../../../../secrets/personal/secrets.yaml;
|
||||||
"git/credentials/github.com/public/username".sopsFile =
|
|
||||||
../../../../../secrets/personal/secrets.yaml;
|
|
||||||
"git/credentials/github.com/public/password".sopsFile =
|
|
||||||
../../../../../secrets/personal/secrets.yaml;
|
|
||||||
};
|
|
||||||
|
|
||||||
templates.nix-access-tokens = {
|
|
||||||
content = ''
|
|
||||||
access-tokens = github.com=${config.sops.placeholder."git/credentials/github.com/public/password"}
|
|
||||||
'';
|
|
||||||
group = "users";
|
group = "users";
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
nix = {
|
nix = {
|
||||||
settings = {
|
settings = {
|
||||||
@@ -23,18 +12,14 @@
|
|||||||
"nix-command"
|
"nix-command"
|
||||||
"flakes"
|
"flakes"
|
||||||
];
|
];
|
||||||
download-buffer-size = 524288000;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
channel.enable = false;
|
registry.self.flake = inputs.self;
|
||||||
|
|
||||||
gc.automatic = true;
|
gc.automatic = true;
|
||||||
optimise.automatic = true;
|
optimise.automatic = true;
|
||||||
|
|
||||||
registry.self.flake = inputs.self;
|
|
||||||
|
|
||||||
extraOptions = ''
|
extraOptions = ''
|
||||||
!include ${config.sops.templates.nix-access-tokens.path}
|
!include ${config.sops.secrets."nix/accessTokens/github".path}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
{ inputs, system, ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
imports = [ inputs.nur.modules.nixos.default ];
|
imports = [ inputs.nur.modules.nixos.default ];
|
||||||
|
|
||||||
nixpkgs = {
|
nixpkgs.config.allowUnfree = true;
|
||||||
hostPlatform = system;
|
|
||||||
config.allowUnfree = true;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@@ -8,16 +8,12 @@
|
|||||||
};
|
};
|
||||||
pulse.enable = true;
|
pulse.enable = true;
|
||||||
jack.enable = true;
|
jack.enable = true;
|
||||||
extraConfig.pipewire-pulse.pipewire-pulse = {
|
extraConfig.pipewire-pulse = {
|
||||||
"pulse.cmd" = [
|
pulse.cmd = [
|
||||||
{
|
{
|
||||||
cmd = "load-module";
|
cmd = "load-module";
|
||||||
args = "module-switch-on-connect";
|
args = "module-switch-on-connect";
|
||||||
}
|
}
|
||||||
{
|
|
||||||
cmd = "load-module";
|
|
||||||
args = "module-combine-sink";
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
{ pkgs, inputs, ... }:
|
|
||||||
{
|
|
||||||
imports = [ inputs.quadlet-nix.nixosModules.quadlet ];
|
|
||||||
|
|
||||||
virtualisation = {
|
|
||||||
podman.enable = true;
|
|
||||||
|
|
||||||
containers = {
|
|
||||||
enable = true;
|
|
||||||
storage.settings.storage.driver = "btrfs";
|
|
||||||
};
|
|
||||||
|
|
||||||
quadlet.autoEscape = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
environment = {
|
|
||||||
persistence."/persist/state"."/var/lib/containers".create = "directory";
|
|
||||||
|
|
||||||
systemPackages = with pkgs; [
|
|
||||||
podman-compose
|
|
||||||
kompose
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
@@ -1,4 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
powerManagement.enable = true;
|
|
||||||
}
|
|
5
hosts/common/configs/system/powertop/default.nix
Normal file
5
hosts/common/configs/system/powertop/default.nix
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [ powertop ];
|
||||||
|
powerManagement.powertop.enable = true;
|
||||||
|
}
|
@@ -18,19 +18,19 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.persistence."/persist/state" = {
|
environment.persistence."/persist" = {
|
||||||
"/var/lib/cups/ppd" = { };
|
"/var/lib/cups/ppd" = { };
|
||||||
"/var/lib/cups/printers.conf" = { };
|
"/var/lib/cups/printers.conf" = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd = {
|
systemd = {
|
||||||
services.cups.after = [
|
services.cups.after = [
|
||||||
config.environment.persistence."/persist/state"."/var/lib/cups/ppd".mount
|
config.environment.persistence."/persist"."/var/lib/cups/ppd".mount
|
||||||
config.environment.persistence."/persist/state"."/var/lib/cups/printers.conf".mount
|
config.environment.persistence."/persist"."/var/lib/cups/printers.conf".mount
|
||||||
];
|
];
|
||||||
sockets.cups.after = [
|
sockets.cups.after = [
|
||||||
config.environment.persistence."/persist/state"."/var/lib/cups/ppd".mount
|
config.environment.persistence."/persist"."/var/lib/cups/ppd".mount
|
||||||
config.environment.persistence."/persist/state"."/var/lib/cups/printers.conf".mount
|
config.environment.persistence."/persist"."/var/lib/cups/printers.conf".mount
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +0,0 @@
|
|||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
smartmontools
|
|
||||||
nvme-cli
|
|
||||||
];
|
|
||||||
}
|
|
@@ -8,27 +8,13 @@
|
|||||||
imports = [ inputs.sops-nix.nixosModules.sops ];
|
imports = [ inputs.sops-nix.nixosModules.sops ];
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
persistence."/persist/state"."/etc/ssh/ssh_host_ed25519_key" = { };
|
persistence."/persist"."/etc/ssh/ssh_host_ed25519_key" = { };
|
||||||
|
systemPackages = with pkgs; [ sops ];
|
||||||
systemPackages = with pkgs; [
|
|
||||||
sops
|
|
||||||
age
|
|
||||||
ssh-to-age
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sops = {
|
sops.age = {
|
||||||
defaultSopsFile = ../../../../. + "/${config.networking.hostName}/secrets/secrets.yaml";
|
|
||||||
|
|
||||||
age = {
|
|
||||||
generateKey = true;
|
generateKey = true;
|
||||||
|
sshKeyPaths = [ config.environment.persistence."/persist"."/etc/ssh/ssh_host_ed25519_key".source ];
|
||||||
keyFile = "/var/lib/sops-nix/key.txt";
|
keyFile = "/var/lib/sops-nix/key.txt";
|
||||||
|
|
||||||
sshKeyPaths =
|
|
||||||
if config.environment.impermanence.enable then
|
|
||||||
[ config.environment.persistence."/persist/state"."/etc/ssh/ssh_host_ed25519_key".source ]
|
|
||||||
else
|
|
||||||
[ "/etc/ssh/ssh_host_ed25519_key" ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
programs.ssh.startAgent = true;
|
|
||||||
}
|
|
@@ -1,23 +1,12 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
programs.ssh.knownHosts = {
|
programs.ssh = {
|
||||||
|
startAgent = true;
|
||||||
|
|
||||||
|
knownHosts = {
|
||||||
installer.publicKeyFile = ../../../../installer/secrets/ssh_host_ed25519_key.pub;
|
installer.publicKeyFile = ../../../../installer/secrets/ssh_host_ed25519_key.pub;
|
||||||
|
eirene.publicKeyFile = ../../../../eirene/secrets/ssh_host_ed25519_key.pub;
|
||||||
elara.publicKeyFile = ../../../../elara/secrets/ssh_host_ed25519_key.pub;
|
elara.publicKeyFile = ../../../../elara/secrets/ssh_host_ed25519_key.pub;
|
||||||
himalia.publicKeyFile = ../../../../himalia/secrets/ssh_host_ed25519_key.pub;
|
|
||||||
|
|
||||||
jupiter = {
|
|
||||||
publicKeyFile = ../../../../jupiter/secrets/ssh_host_ed25519_key.pub;
|
|
||||||
extraHostNames = [ "karaolidis.com" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
jupiter-sish = {
|
|
||||||
publicKeyFile = ../../../../jupiter/users/storm/configs/console/podman/sish/ssh_host_ed25519_key.pub;
|
|
||||||
extraHostNames = [ "karaolidis.com" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
jupiter-vps = {
|
|
||||||
publicKeyFile = ../../../../jupiter-vps/secrets/ssh_host_ed25519_key.pub;
|
|
||||||
extraHostNames = [ "vps.karaolidis.com" ];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
environment = {
|
|
||||||
enableAllTerminfo = true;
|
|
||||||
persistence."/persist/state"."/var/lib/fail2ban" = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
services = {
|
|
||||||
openssh = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
PasswordAuthentication = false;
|
|
||||||
PrintMotd = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
fail2ban = {
|
|
||||||
enable = true;
|
|
||||||
bantime = "24h";
|
|
||||||
bantime-increment = {
|
|
||||||
enable = true;
|
|
||||||
maxtime = "720h";
|
|
||||||
overalljails = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
@@ -1,4 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
security.pam.services.sudo.nodelay = true;
|
|
||||||
}
|
|
@@ -1,4 +1,17 @@
|
|||||||
{ ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
system.stateVersion = "24.11";
|
system = {
|
||||||
|
autoUpgrade = {
|
||||||
|
enable = true;
|
||||||
|
flake = inputs.self.outPath;
|
||||||
|
flags = [
|
||||||
|
"--update-input"
|
||||||
|
"nixpkgs"
|
||||||
|
"-L"
|
||||||
|
];
|
||||||
|
dates = "02:00";
|
||||||
|
};
|
||||||
|
|
||||||
|
stateVersion = "24.11";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
case "$2" in
|
case "$2" in
|
||||||
connectivity-change)
|
connectivity-change)
|
||||||
if timezone=$(curl --fail https://ipapi.co/timezone); then
|
if timezone=$(curl --fail https://ipapi.co/timezone); then
|
||||||
|
12
hosts/common/configs/system/tlp/default.nix
Normal file
12
hosts/common/configs/system/tlp/default.nix
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
services.tlp = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
CPU_SCALING_GOVERNOR_ON_AC = "performance";
|
||||||
|
CPU_SCALING_GOVERNOR_ON_BAT = "powersave";
|
||||||
|
CPU_ENERGY_PERF_POLICY_ON_AC = "performance";
|
||||||
|
CPU_ENERGY_PERF_POLICY_ON_BAT = "power";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
4
hosts/common/configs/system/tree/default.nix
Normal file
4
hosts/common/configs/system/tree/default.nix
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [ tree ];
|
||||||
|
}
|
@@ -1,8 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
services.upower = {
|
|
||||||
enable = true;
|
|
||||||
allowRiskyCriticalPowerAction = true;
|
|
||||||
criticalPowerAction = "Ignore";
|
|
||||||
};
|
|
||||||
}
|
|
4
hosts/common/configs/system/wget/default.nix
Normal file
4
hosts/common/configs/system/wget/default.nix
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [ wget ];
|
||||||
|
}
|
@@ -6,9 +6,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
persistence."/persist/state"."/var/lib/zsh" = { };
|
persistence."/persist"."/var/lib/zsh" = { };
|
||||||
pathsToLink = [ "/share/zsh" ];
|
pathsToLink = [ "/share/zsh" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.tmpfiles.rules = [ "d /var/lib/zsh 0755 root root" ];
|
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
users.users.${user}.extraGroups = [ "adbusers" ];
|
users.users.${user}.extraGroups = [ "adbusers" ];
|
||||||
|
|
||||||
environment.persistence."/persist/state" = {
|
environment.persistence."/persist" = {
|
||||||
"${home}/.local/share/android/adbkey" = { };
|
"${home}/.local/share/android/adbkey" = { };
|
||||||
"${home}/.local/share/android/adbkey.pub" = { };
|
"${home}/.local/share/android/adbkey.pub" = { };
|
||||||
};
|
};
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
user ? throw "user argument is required",
|
user ? throw "user argument is required",
|
||||||
home ? throw "home argument is required",
|
home ? throw "home argument is required",
|
||||||
}:
|
}:
|
||||||
{ pkgs, ... }:
|
{ lib, pkgs, ... }:
|
||||||
{
|
{
|
||||||
home-manager.users.${user}.home.packages = with pkgs; [ ouch ];
|
home-manager.users.${user}.programs.bashmount.enable = true;
|
||||||
}
|
}
|
@@ -8,4 +8,6 @@
|
|||||||
"video"
|
"video"
|
||||||
"inputs"
|
"inputs"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
home-manager.users.${user}.home.packages = with pkgs; [ brightnessctl ];
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
update_ms = 1000;
|
update_ms = 1000;
|
||||||
proc_tree = true;
|
proc_tree = true;
|
||||||
cpu_single_graph = true;
|
cpu_single_graph = true;
|
||||||
disks_filter = "/ /nix /persist";
|
disks_filter = "/ /nix /persist /cache";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
user ? throw "user argument is required",
|
|
||||||
home ? throw "home argument is required",
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
hmConfig = config.home-manager.users.${user};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
home-manager.users.${user} = {
|
|
||||||
home.packages = with pkgs; [ dive ];
|
|
||||||
|
|
||||||
xdg.configFile."dive/config.yaml" = lib.mkIf (
|
|
||||||
config.virtualisation.podman.enable || hmConfig.services.podman.enable
|
|
||||||
) { source = (pkgs.formats.yaml { }).generate "config.yaml" { container-engine = "podman"; }; };
|
|
||||||
};
|
|
||||||
}
|
|
55
hosts/common/configs/user/console/docker/default.nix
Normal file
55
hosts/common/configs/user/console/docker/default.nix
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
user ? throw "user argument is required",
|
||||||
|
home ? throw "home argument is required",
|
||||||
|
rootless ? true,
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
lib.mkMerge [
|
||||||
|
{
|
||||||
|
virtualisation.docker.rootless = {
|
||||||
|
enable = rootless;
|
||||||
|
setSocketVariable = true;
|
||||||
|
enableOnBoot = false;
|
||||||
|
storageDriver = "btrfs";
|
||||||
|
|
||||||
|
daemon.settings = {
|
||||||
|
experimental = true;
|
||||||
|
ipv6 = true;
|
||||||
|
fixed-cidr-v6 = "fd00::/80";
|
||||||
|
};
|
||||||
|
|
||||||
|
autoPrune = {
|
||||||
|
enable = true;
|
||||||
|
flags = [ "--all" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
home-manager.users.${user}.home = {
|
||||||
|
packages = with pkgs; [ docker-compose ];
|
||||||
|
|
||||||
|
sessionVariables = {
|
||||||
|
DOCKER_CONFIG = "${home}/.config/docker";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(lib.mkIf rootless {
|
||||||
|
environment.persistence."/persist"."${home}/.local/share/docker" = { };
|
||||||
|
|
||||||
|
systemd.user = {
|
||||||
|
services.docker.after = [
|
||||||
|
config.environment.persistence."/persist"."${home}/.local/share/docker".mount
|
||||||
|
];
|
||||||
|
sockets.docker.after = [
|
||||||
|
config.environment.persistence."/persist"."${home}/.local/share/docker".mount
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
(lib.mkIf (!rootless) {
|
||||||
|
users.users.${user}.extraGroups = [ "docker" ];
|
||||||
|
})
|
||||||
|
]
|
@@ -4,8 +4,5 @@
|
|||||||
}:
|
}:
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
home-manager.users.${user}.home.packages = with pkgs; [
|
home-manager.users.${user}.home.packages = with pkgs; [ ffmpeg ];
|
||||||
ffmpeg
|
|
||||||
mediainfo
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
git interpret-trailers --if-exists doNothing --trailer \
|
git interpret-trailers --if-exists doNothing --trailer \
|
||||||
"Signed-off-by: $(git config user.name) <$(git config user.email)>" \
|
"Signed-off-by: $(git config user.name) <$(git config user.email)>" \
|
||||||
--in-place "$1"
|
--in-place "$1"
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
|
|
||||||
install -d -m 700 "$GNUPGHOME"
|
install -d -m 700 "$GNUPGHOME"
|
||||||
|
|
||||||
KEYS="$HOME/.config/sops-nix/secrets/gpg"
|
KEYS="$HOME/.config/sops-nix/secrets/gpg"
|
||||||
|
@@ -9,7 +9,9 @@
|
|||||||
programs.dconf.enable = true;
|
programs.dconf.enable = true;
|
||||||
|
|
||||||
home-manager = {
|
home-manager = {
|
||||||
extraSpecialArgs = { inherit inputs; };
|
extraSpecialArgs = {
|
||||||
|
inherit inputs;
|
||||||
|
};
|
||||||
backupFileExtension = "bak";
|
backupFileExtension = "bak";
|
||||||
useUserPackages = true;
|
useUserPackages = true;
|
||||||
useGlobalPkgs = true;
|
useGlobalPkgs = true;
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
user ? throw "user argument is required",
|
|
||||||
home ? throw "home argument is required",
|
|
||||||
}:
|
|
||||||
{ pkgs, ... }:
|
|
||||||
{
|
|
||||||
home-manager.users.${user}.home.packages = with pkgs; [
|
|
||||||
iproute2
|
|
||||||
iptables
|
|
||||||
ipset
|
|
||||||
ethtool
|
|
||||||
tcpdump
|
|
||||||
ipcalc
|
|
||||||
];
|
|
||||||
}
|
|
@@ -9,20 +9,52 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(final: prev: {
|
||||||
|
k9s = prev.k9s.overrideAttrs (oldAttrs: {
|
||||||
|
patches = oldAttrs.patches or [ ] ++ [ ./remove-splash.patch ];
|
||||||
|
});
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
environment.persistence = {
|
environment.persistence = {
|
||||||
"/persist/user"."${home}/.kube" = { };
|
"/persist"."${home}/.kube" = { };
|
||||||
"/persist/cache"."${home}/.kube/cache" = { };
|
"/cache"."${home}/.kube/cache" = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
users.users.${user}.extraGroups = [ "kubernetes" ];
|
||||||
|
|
||||||
|
sops.secrets = {
|
||||||
|
"kubernetes/cert/accounts/${user}/crt" = {
|
||||||
|
key = "kubernetes/cert/accounts/users/crt";
|
||||||
|
group = "users";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
|
||||||
|
"kubernetes/cert/accounts/${user}/key" = {
|
||||||
|
key = "kubernetes/cert/accounts/users/key";
|
||||||
|
group = "users";
|
||||||
|
mode = "0440";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.kubernetes.kubeconfigs.${user} =
|
||||||
|
config.services.kubernetes.lib.mkKubeConfig user config.sops.secrets."kubernetes/ca/kubernetes/crt".path
|
||||||
|
config.sops.secrets."kubernetes/cert/accounts/${user}/crt".path
|
||||||
|
config.sops.secrets."kubernetes/cert/accounts/${user}/key".path;
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
home.packages = with pkgs; [
|
home = {
|
||||||
|
packages = with pkgs; [
|
||||||
kubectl
|
kubectl
|
||||||
kustomize
|
kustomize
|
||||||
kubernetes-helm
|
kubernetes-helm
|
||||||
kompose
|
kompose
|
||||||
kind
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
file.".kube/local".source = config.services.kubernetes.kubeconfigs.${user};
|
||||||
|
};
|
||||||
|
|
||||||
programs = {
|
programs = {
|
||||||
k9s = {
|
k9s = {
|
||||||
enable = true;
|
enable = true;
|
||||||
@@ -35,20 +67,19 @@
|
|||||||
ui = {
|
ui = {
|
||||||
skin = "matugen";
|
skin = "matugen";
|
||||||
logoless = true;
|
logoless = true;
|
||||||
splashless = true;
|
|
||||||
reactive = true;
|
reactive = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
zsh = {
|
zsh = {
|
||||||
initContent = ''
|
initExtra = ''
|
||||||
kubeswitch() {
|
kubeswitch() {
|
||||||
local target="$HOME/.kube/$1"
|
local target="$HOME/.kube/$1"
|
||||||
local config="$HOME/.kube/config"
|
local config="$HOME/.kube/config"
|
||||||
|
|
||||||
if [[ -f "$target" && "$target" != "$config" ]]; then
|
if [[ -f "$target" && "$target" != "$config" ]]; then
|
||||||
ln -srf "$target" "$config"
|
ln -sf "$target" "$config"
|
||||||
echo "Switched kube context to $1"
|
echo "Switched kube context to $1"
|
||||||
p10k reload
|
p10k reload
|
||||||
else
|
else
|
||||||
@@ -70,6 +101,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
theme.template.".config/k9s/skins/matugen.yaml".source = ./theme.yaml;
|
theme.template."${home}/.config/k9s/skins/matugen.yaml".source = ./theme.yaml;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
123
hosts/common/configs/user/console/kubernetes/remove-splash.patch
Normal file
123
hosts/common/configs/user/console/kubernetes/remove-splash.patch
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
diff --git a/internal/ui/splash.go b/internal/ui/splash.go
|
||||||
|
index bfe58e46..21683c53 100644
|
||||||
|
--- a/internal/ui/splash.go
|
||||||
|
+++ b/internal/ui/splash.go
|
||||||
|
@@ -3,14 +3,6 @@
|
||||||
|
|
||||||
|
package ui
|
||||||
|
|
||||||
|
-import (
|
||||||
|
- "fmt"
|
||||||
|
- "strings"
|
||||||
|
-
|
||||||
|
- "github.com/derailed/k9s/internal/config"
|
||||||
|
- "github.com/derailed/tview"
|
||||||
|
-)
|
||||||
|
-
|
||||||
|
// LogoSmall K9s small log.
|
||||||
|
var LogoSmall = []string{
|
||||||
|
` ____ __.________ `,
|
||||||
|
@@ -30,42 +22,3 @@ var LogoBig = []string{
|
||||||
|
`|____|__ \ /____//____ >\______ /_______ \___|`,
|
||||||
|
` \/ \/ \/ \/ `,
|
||||||
|
}
|
||||||
|
-
|
||||||
|
-// Splash represents a splash screen.
|
||||||
|
-type Splash struct {
|
||||||
|
- *tview.Flex
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-// NewSplash instantiates a new splash screen with product and company info.
|
||||||
|
-func NewSplash(styles *config.Styles, version string) *Splash {
|
||||||
|
- s := Splash{Flex: tview.NewFlex()}
|
||||||
|
- s.SetBackgroundColor(styles.BgColor())
|
||||||
|
-
|
||||||
|
- logo := tview.NewTextView()
|
||||||
|
- logo.SetDynamicColors(true)
|
||||||
|
- logo.SetTextAlign(tview.AlignCenter)
|
||||||
|
- s.layoutLogo(logo, styles)
|
||||||
|
-
|
||||||
|
- vers := tview.NewTextView()
|
||||||
|
- vers.SetDynamicColors(true)
|
||||||
|
- vers.SetTextAlign(tview.AlignCenter)
|
||||||
|
- s.layoutRev(vers, version, styles)
|
||||||
|
-
|
||||||
|
- s.SetDirection(tview.FlexRow)
|
||||||
|
- s.AddItem(logo, 10, 1, false)
|
||||||
|
- s.AddItem(vers, 1, 1, false)
|
||||||
|
-
|
||||||
|
- return &s
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-func (s *Splash) layoutLogo(t *tview.TextView, styles *config.Styles) {
|
||||||
|
- logo := strings.Join(LogoBig, fmt.Sprintf("\n[%s::b]", styles.Body().LogoColor))
|
||||||
|
- fmt.Fprintf(t, "%s[%s::b]%s\n",
|
||||||
|
- strings.Repeat("\n", 2),
|
||||||
|
- styles.Body().LogoColor,
|
||||||
|
- logo)
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-func (s *Splash) layoutRev(t *tview.TextView, rev string, styles *config.Styles) {
|
||||||
|
- fmt.Fprintf(t, "[%s::b]Revision [red::b]%s", styles.Body().FgColor, rev)
|
||||||
|
-}
|
||||||
|
diff --git a/internal/ui/splash_test.go b/internal/ui/splash_test.go
|
||||||
|
deleted file mode 100644
|
||||||
|
index 69b4b50d..00000000
|
||||||
|
--- a/internal/ui/splash_test.go
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,22 +0,0 @@
|
||||||
|
-// SPDX-License-Identifier: Apache-2.0
|
||||||
|
-// Copyright Authors of K9s
|
||||||
|
-
|
||||||
|
-package ui_test
|
||||||
|
-
|
||||||
|
-import (
|
||||||
|
- "testing"
|
||||||
|
-
|
||||||
|
- "github.com/derailed/k9s/internal/config"
|
||||||
|
- "github.com/derailed/k9s/internal/ui"
|
||||||
|
- "github.com/stretchr/testify/assert"
|
||||||
|
-)
|
||||||
|
-
|
||||||
|
-func TestNewSplash(t *testing.T) {
|
||||||
|
- s := ui.NewSplash(config.NewStyles(), "bozo")
|
||||||
|
-
|
||||||
|
- x, y, w, h := s.GetRect()
|
||||||
|
- assert.Equal(t, 0, x)
|
||||||
|
- assert.Equal(t, 0, y)
|
||||||
|
- assert.Equal(t, 15, w)
|
||||||
|
- assert.Equal(t, 10, h)
|
||||||
|
-}
|
||||||
|
diff --git a/internal/view/app.go b/internal/view/app.go
|
||||||
|
index 4ac7e7c2..2b3a3fc5 100644
|
||||||
|
--- a/internal/view/app.go
|
||||||
|
+++ b/internal/view/app.go
|
||||||
|
@@ -35,7 +35,6 @@ import (
|
||||||
|
var ExitStatus = ""
|
||||||
|
|
||||||
|
const (
|
||||||
|
- splashDelay = 1 * time.Second
|
||||||
|
clusterRefresh = 15 * time.Second
|
||||||
|
clusterInfoWidth = 50
|
||||||
|
clusterInfoPad = 15
|
||||||
|
@@ -165,8 +164,7 @@ func (a *App) layout(ctx context.Context) {
|
||||||
|
}
|
||||||
|
main.AddItem(flash, 1, 1, false)
|
||||||
|
|
||||||
|
- a.Main.AddPage("main", main, true, false)
|
||||||
|
- a.Main.AddPage("splash", ui.NewSplash(a.Styles, a.version), true, true)
|
||||||
|
+ a.Main.AddPage("main", main, true, true)
|
||||||
|
a.toggleHeader(!a.Config.K9s.IsHeadless(), !a.Config.K9s.IsLogoless())
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -520,10 +518,7 @@ func (a *App) Run() error {
|
||||||
|
a.Resume()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
- <-time.After(splashDelay)
|
||||||
|
a.QueueUpdateDraw(func() {
|
||||||
|
- a.Main.SwitchToPage("main")
|
||||||
|
- // if command bar is already active, focus it
|
||||||
|
if a.CmdBuff().IsActive() {
|
||||||
|
a.SetFocus(a.Prompt())
|
||||||
|
}
|
@@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
user ? throw "user argument is required",
|
|
||||||
home ? throw "home argument is required",
|
|
||||||
}:
|
|
||||||
{ lib, pkgs, ... }:
|
|
||||||
{
|
|
||||||
environment.persistence = {
|
|
||||||
"/persist/state"."${home}/.config/ncspot/userstate.cbor" = { };
|
|
||||||
"/persist/cache"."${home}/.cache/ncspot" = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
|
||||||
programs.ncspot.enable = true;
|
|
||||||
|
|
||||||
theme = {
|
|
||||||
template.".config/ncspot/config.toml".source = ./theme.toml;
|
|
||||||
|
|
||||||
reloadExtraConfig = "${
|
|
||||||
lib.meta.getExe (
|
|
||||||
pkgs.writeShellApplication {
|
|
||||||
name = "reload-ncspot";
|
|
||||||
runtimeInputs = with pkgs; [ netcat ];
|
|
||||||
text = ''
|
|
||||||
printf "reload\n" | nc -W 1 -U "''${XDG_RUNTIME_DIR:-/run/user/$UID}/ncspot/ncspot.sock"
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
)
|
|
||||||
} &";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
use_nerdfont = true
|
|
||||||
volnorm = true
|
|
||||||
default_keybindings = true
|
|
||||||
library_tabs = [ "albums", "artists", "playlists", "browse" ]
|
|
||||||
|
|
||||||
[theme]
|
|
||||||
background = "{{colors.surface.default.hex}}"
|
|
||||||
primary = "{{colors.on_surface.default.hex}}"
|
|
||||||
secondary = "{{colors.inverse_surface.default.hex}}"
|
|
||||||
title = "{{colors.primary.default.hex}}"
|
|
||||||
playing = "{{colors.primary.default.hex}}"
|
|
||||||
playing_bg = "{{colors.surface.default.hex}}"
|
|
||||||
highlight = "{{colors.on_primary.default.hex}}"
|
|
||||||
highlight_bg = "{{colors.primary.default.hex}}"
|
|
||||||
playing_selected = "{{colors.on_primary.default.hex}}"
|
|
||||||
error = "{{colors.on_error.default.hex}}"
|
|
||||||
error_bg = "{{colors.error.default.hex}}"
|
|
||||||
statusbar = "{{colors.primary.default.hex}}"
|
|
||||||
statusbar_progress = "{{colors.primary.default.hex}}"
|
|
||||||
statusbar_bg = "{{colors.surface.default.hex}}"
|
|
||||||
cmdline = "{{colors.on_surface.default.hex}}"
|
|
||||||
cmdline_bg = "{{colors.surface.default.hex}}"
|
|
||||||
search_match = "{{colors.tertiary.default.hex}}"
|
|
@@ -12,7 +12,7 @@
|
|||||||
home-manager.users.${user}.programs.zsh = {
|
home-manager.users.${user}.programs.zsh = {
|
||||||
shellAliases.nd = "nix-develop";
|
shellAliases.nd = "nix-develop";
|
||||||
|
|
||||||
initContent =
|
initExtra =
|
||||||
let
|
let
|
||||||
devShells = lib.strings.concatStringsSep " " (
|
devShells = lib.strings.concatStringsSep " " (
|
||||||
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells.${system}
|
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells.${system}
|
||||||
@@ -35,16 +35,7 @@
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "$devshell" ]]; then
|
if [[ -z "$devshell" ]]; then
|
||||||
if [ ! -f flake.nix ]; then
|
if [ ! -f flake.nix ]; then cp "${./template.nix}" flake.nix; fi
|
||||||
cp "${./template.nix}" flake.nix
|
|
||||||
chmod 755 flake.nix
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! treefmt.nix ]; then
|
|
||||||
cp "${./treefmt.nix}" treefmt.nix
|
|
||||||
chmod 755 treefmt.nix
|
|
||||||
fi
|
|
||||||
|
|
||||||
nix develop -c "$SHELL"
|
nix develop -c "$SHELL"
|
||||||
else
|
else
|
||||||
nix develop self#"$devshell" -c "$SHELL"
|
nix develop self#"$devshell" -c "$SHELL"
|
||||||
|
@@ -8,35 +8,23 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
flake-utils = {
|
flake-utils = {
|
||||||
type = "github";
|
url = "github:numtide/flake-utils";
|
||||||
owner = "numtide";
|
|
||||||
repo = "flake-utils";
|
|
||||||
ref = "main";
|
|
||||||
};
|
|
||||||
|
|
||||||
treefmt-nix = {
|
|
||||||
type = "github";
|
|
||||||
owner = "numtide";
|
|
||||||
repo = "treefmt-nix";
|
|
||||||
ref = "main";
|
|
||||||
|
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ self, nixpkgs, ... }@inputs:
|
{ nixpkgs, ... }@inputs:
|
||||||
inputs.flake-utils.lib.eachDefaultSystem (
|
inputs.flake-utils.lib.eachDefaultSystem (
|
||||||
system:
|
system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
treefmt = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells.default = pkgs.mkShell { packages = with pkgs; [ ]; };
|
devShells.default = pkgs.mkShell {
|
||||||
|
packages = [ ];
|
||||||
|
};
|
||||||
|
|
||||||
formatter = treefmt.config.build.wrapper;
|
formatter = pkgs.nixfmt-rfc-style;
|
||||||
checks.formatting = treefmt.config.build.check self;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +0,0 @@
|
|||||||
{ ... }:
|
|
||||||
{
|
|
||||||
projectRootFile = "flake.nix";
|
|
||||||
|
|
||||||
programs = {
|
|
||||||
nixfmt = {
|
|
||||||
enable = true;
|
|
||||||
strict = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
global = {
|
|
||||||
excludes = [ ".envrc" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
@@ -10,35 +10,19 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
home-manager.users.${user}.programs = {
|
home-manager.users.${user} = {
|
||||||
|
programs = {
|
||||||
direnv = {
|
direnv = {
|
||||||
enable = true;
|
enable = true;
|
||||||
silent = true;
|
silent = true;
|
||||||
nix-direnv.enable = true;
|
nix-direnv.enable = true;
|
||||||
enableZshIntegration = true;
|
enableZshIntegration = true;
|
||||||
|
|
||||||
config = {
|
|
||||||
global.warn_timeout = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
# https://github.com/direnv/direnv/wiki/Customizing-cache-location
|
|
||||||
stdlib = ''
|
|
||||||
declare -A direnv_layout_dirs
|
|
||||||
direnv_layout_dir() {
|
|
||||||
local hash path
|
|
||||||
echo "''${direnv_layout_dirs[$PWD]:=$(
|
|
||||||
hash="$(sha1sum - <<< "$PWD" | head -c40)"
|
|
||||||
path="''${PWD//[^a-zA-Z0-9]/-}"
|
|
||||||
echo "${home}/.cache/direnv/layouts/''${hash}''${path}"
|
|
||||||
)}"
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
zsh = {
|
zsh = {
|
||||||
shellAliases.nde = "nix-direnv";
|
shellAliases.nde = "nix-direnv";
|
||||||
|
|
||||||
initContent =
|
initExtra =
|
||||||
let
|
let
|
||||||
devShells = lib.strings.concatStringsSep " " (
|
devShells = lib.strings.concatStringsSep " " (
|
||||||
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells.${system}
|
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells.${system}
|
||||||
@@ -52,7 +36,7 @@
|
|||||||
while getopts "s:h" opt; do
|
while getopts "s:h" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
s)
|
s)
|
||||||
devshell="$OPTARG"
|
devshell=$OPTARG
|
||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
hide=true
|
hide=true
|
||||||
@@ -65,33 +49,19 @@
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "$devshell" ]]; then
|
if [[ -z "$devshell" ]]; then
|
||||||
if "$hide"; then
|
echo "use flake" > .envrc
|
||||||
echo "use flake path:." > .envrc;
|
if [ ! -f flake.nix ]; then cp "${../nix-develop/template.nix}" flake.nix; fi
|
||||||
else
|
|
||||||
echo "use flake" > .envrc;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f flake.nix ]; then
|
|
||||||
cp "${../nix-develop/template.nix}" flake.nix
|
|
||||||
chmod 755 flake.nix
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f treefmt.nix ]; then
|
|
||||||
cp "${../nix-develop/treefmt.nix}" treefmt.nix
|
|
||||||
chmod 755 treefmt.nix
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "use flake self#$devshell" > .envrc
|
echo "use flake self#$devshell" > .envrc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if "$hide" && git rev-parse --is-inside-work-tree &>/dev/null; then
|
if hide && git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||||
local top
|
local top
|
||||||
top="$(git rev-parse --show-toplevel)"
|
top=$(git rev-parse --show-toplevel)
|
||||||
if ! grep -q "^\.envrc$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "$(realpath --relative-to="$top" .envrc)" >> "$top/.git/info/exclude"; fi
|
if ! grep -q "^\.envrc$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "$(realpath --relative-to="$top" .envrc)" >> "$top/.git/info/exclude"; fi
|
||||||
if [ -z "$devshell" ]; then
|
if [ -z "$devshell" ]; then
|
||||||
if ! grep -q "^flake.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.nix" >> "$top/.git/info/exclude"; fi
|
if ! grep -q "^flake.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.nix" >> "$top/.git/info/exclude"; fi
|
||||||
if ! grep -q "^flake.lock$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.lock" >> "$top/.git/info/exclude"; fi
|
if ! grep -q "^flake.lock$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "flake.lock" >> "$top/.git/info/exclude"; fi
|
||||||
if ! grep -q "^treefmt.nix$" "$top/.gitignore" "$top/.git/info/exclude"; then echo "treefmt.nix" >> "$top/.git/info/exclude"; fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -114,8 +84,30 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# https://github.com/direnv/direnv/wiki/Customizing-cache-location
|
||||||
|
xdg.configFile = {
|
||||||
|
"direnv/direnvrc".text = ''
|
||||||
|
declare -A direnv_layout_dirs
|
||||||
|
direnv_layout_dir() {
|
||||||
|
local hash path
|
||||||
|
echo "''${direnv_layout_dirs[$PWD]:=$(
|
||||||
|
hash="$(sha1sum - <<< "$PWD" | head -c40)"
|
||||||
|
path="''${PWD//[^a-zA-Z0-9]/-}"
|
||||||
|
echo "${home}/.cache/direnv/layouts/''${hash}''${path}"
|
||||||
|
)}"
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
"direnv/direnv.toml".source = (
|
||||||
|
(pkgs.formats.toml { }).generate "direnv.toml" {
|
||||||
|
global.warn_timeout = 0;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
environment.persistence = {
|
environment.persistence = {
|
||||||
"/persist/state"."${home}/.local/share/direnv/allow" = { };
|
"/persist"."${home}/.local/share/direnv/allow" = { };
|
||||||
"/persist/cache"."${home}/.cache/direnv" = { };
|
"/cache"."${home}/.cache/direnv" = { };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -2,16 +2,12 @@
|
|||||||
user ? throw "user argument is required",
|
user ? throw "user argument is required",
|
||||||
home ? throw "home argument is required",
|
home ? throw "home argument is required",
|
||||||
}:
|
}:
|
||||||
{ pkgs, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
environment.persistence."/persist/cache"."${home}/.cache/nix" = { };
|
environment.persistence."/cache"."${home}/.cache/nix" = { };
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user}.programs.zsh.shellAliases = {
|
||||||
home.packages = with pkgs; [ nurl ];
|
|
||||||
|
|
||||||
programs.zsh.shellAliases = {
|
|
||||||
nrs = "sudo nixos-rebuild switch --flake .#$(hostname) --show-trace";
|
nrs = "sudo nixos-rebuild switch --flake .#$(hostname) --show-trace";
|
||||||
nrb = "sudo nixos-rebuild boot --flake .#$(hostname) --show-trace";
|
nrb = "sudo nixos-rebuild boot --flake .#$(hostname) --show-trace";
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@@ -2,10 +2,9 @@
|
|||||||
user ? throw "user argument is required",
|
user ? throw "user argument is required",
|
||||||
home ? throw "home argument is required",
|
home ? throw "home argument is required",
|
||||||
}:
|
}:
|
||||||
{ ... }:
|
{ inputs, ... }:
|
||||||
{
|
{
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
services.ssh-agent.enable = true;
|
imports = [ inputs.nur.modules.homeManager.default ];
|
||||||
programs.ssh.addKeysToAgent = "yes";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
@@ -4,17 +4,16 @@
|
|||||||
}:
|
}:
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{
|
{
|
||||||
environment.persistence."/persist/state"."${home}/.local/state/wireplumber" = { };
|
environment.persistence."/persist"."${home}/.local/state/wireplumber" = { };
|
||||||
|
|
||||||
systemd.user.services.wireplumber.after = [
|
systemd.user.services.wireplumber.after = [
|
||||||
config.environment.persistence."/persist/state"."${home}/.local/state/wireplumber".mount
|
config.environment.persistence."/persist"."${home}/.local/state/wireplumber".mount
|
||||||
];
|
];
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
wireplumber
|
wireplumber
|
||||||
playerctl
|
playerctl
|
||||||
easyeffects
|
|
||||||
];
|
];
|
||||||
|
|
||||||
services.playerctld.enable = true;
|
services.playerctld.enable = true;
|
||||||
|
@@ -1,33 +0,0 @@
|
|||||||
{
|
|
||||||
user ? throw "user argument is required",
|
|
||||||
home ? throw "home argument is required",
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
inputs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
environment.persistence."/persist/state"."${home}/.local/share/containers".create = "directory";
|
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
|
||||||
imports = [ inputs.quadlet-nix.homeManagerModules.quadlet ];
|
|
||||||
|
|
||||||
services.podman = {
|
|
||||||
enable = true;
|
|
||||||
settings.storage.storage.driver = "btrfs";
|
|
||||||
};
|
|
||||||
|
|
||||||
virtualisation.quadlet.autoEscape = true;
|
|
||||||
|
|
||||||
home = {
|
|
||||||
packages = with pkgs; [
|
|
||||||
podman-compose
|
|
||||||
kompose
|
|
||||||
];
|
|
||||||
|
|
||||||
sessionVariables.REGISTRY_AUTH_FILE = "${home}/.config/containers/auth.json";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
21
hosts/common/configs/user/console/ranger/default.nix
Normal file
21
hosts/common/configs/user/console/ranger/default.nix
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
user ? throw "user argument is required",
|
||||||
|
home ? throw "home argument is required",
|
||||||
|
}:
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
environment.persistence."/cache"."${home}/.cache/ranger" = { };
|
||||||
|
|
||||||
|
home-manager.users.${user}.programs = {
|
||||||
|
ranger = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
preview_images = true;
|
||||||
|
preview_images_method = "kitty";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
zsh.p10k.extraRightPromptElements = [ "ranger" ];
|
||||||
|
};
|
||||||
|
}
|
@@ -4,14 +4,14 @@
|
|||||||
}:
|
}:
|
||||||
{ config, inputs, ... }:
|
{ config, inputs, ... }:
|
||||||
{
|
{
|
||||||
environment.persistence."/persist/state"."${home}/.config/sops-nix/key.txt" = { };
|
environment.persistence."/persist"."${home}/.config/sops-nix/key.txt" = { };
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
imports = [ inputs.sops-nix.homeManagerModules.sops ];
|
imports = [ inputs.sops-nix.homeManagerModules.sops ];
|
||||||
|
|
||||||
sops.age.keyFile =
|
sops.age.keyFile =
|
||||||
config.environment.persistence."/persist/state"."${home}/.config/sops-nix/key.txt".source;
|
config.environment.persistence."/persist"."${home}/.config/sops-nix/key.txt".source;
|
||||||
home.sessionVariables.SOPS_AGE_KEY_FILE =
|
home.sessionVariables.SOPS_AGE_KEY_FILE =
|
||||||
config.environment.persistence."/persist/state"."${home}/.config/sops-nix/key.txt".source;
|
config.environment.persistence."/persist"."${home}/.config/sops-nix/key.txt".source;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,24 @@
|
|||||||
user ? throw "user argument is required",
|
user ? throw "user argument is required",
|
||||||
home ? throw "home argument is required",
|
home ? throw "home argument is required",
|
||||||
}:
|
}:
|
||||||
{ ... }:
|
|
||||||
{
|
{
|
||||||
home-manager.users.${user}.programs.ssh.enable = true;
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
home-manager.users.${user} = {
|
||||||
|
programs.ssh = {
|
||||||
|
enable = true;
|
||||||
|
addKeysToAgent = "yes";
|
||||||
|
userKnownHostsFile = lib.strings.concatStringsSep " " [
|
||||||
|
../../../../../installer/secrets/ssh_host_ed25519_key.pub
|
||||||
|
../../../../../eirene/secrets/ssh_host_ed25519_key.pub
|
||||||
|
../../../../../elara/secrets/ssh_host_ed25519_key.pub
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.ssh-agent.enable = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
}:
|
}:
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{
|
{
|
||||||
environment.persistence."/persist/user" = {
|
environment.persistence."/persist" = {
|
||||||
"${home}/Desktop" = { };
|
"${home}/Desktop" = { };
|
||||||
"${home}/Documents" = { };
|
"${home}/Documents" = { };
|
||||||
"${home}/Downloads" = { };
|
"${home}/Downloads" = { };
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
|
imports = [ (import ./options.nix { inherit home; }) ];
|
||||||
|
|
||||||
xdg = {
|
xdg = {
|
||||||
enable = true;
|
enable = true;
|
||||||
mimeApps.enable = true;
|
mimeApps.enable = true;
|
||||||
|
112
hosts/common/configs/user/console/xdg/options.nix
Normal file
112
hosts/common/configs/user/console/xdg/options.nix
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
{
|
||||||
|
home ? throw "home argument is required",
|
||||||
|
}:
|
||||||
|
{ config, lib, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.xdg;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.xdg =
|
||||||
|
with lib;
|
||||||
|
with types;
|
||||||
|
{
|
||||||
|
relativeCacheHome = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = ".cache";
|
||||||
|
description = "Relative path to directory holding application caches.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeConfigHome = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = ".config";
|
||||||
|
description = "Relative path to directory holding application configurations.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeDataHome = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = ".local/share";
|
||||||
|
description = "Relative path to directory holding application data.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeStateHome = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = ".local/state";
|
||||||
|
description = "Relative path to directory holding application states.";
|
||||||
|
};
|
||||||
|
|
||||||
|
userDirs = {
|
||||||
|
relativeDesktop = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "Desktop";
|
||||||
|
description = "Relative path to the Desktop directory.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeDocuments = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "Documents";
|
||||||
|
description = "Relative path to the Documents directory.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeDownload = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "Downloads";
|
||||||
|
description = "Relative path to the Downloads directory.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeMusic = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "Music";
|
||||||
|
description = "Relative path to the Music directory.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativePictures = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "Pictures";
|
||||||
|
description = "Relative path to the Pictures directory.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeTemplates = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "Templates";
|
||||||
|
description = "Relative path to the Templates directory.";
|
||||||
|
};
|
||||||
|
|
||||||
|
relativeVideos = mkOption {
|
||||||
|
type = str;
|
||||||
|
readOnly = true;
|
||||||
|
default = "Videos";
|
||||||
|
description = "Relative path to the Videos directory.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.xdg =
|
||||||
|
with lib;
|
||||||
|
with cfg;
|
||||||
|
{
|
||||||
|
cacheHome = mkDefault "${home}/${relativeCacheHome}";
|
||||||
|
configHome = mkDefault "${home}/${relativeConfigHome}";
|
||||||
|
dataHome = mkDefault "${home}/${relativeDataHome}";
|
||||||
|
stateHome = mkDefault "${home}/${relativeStateHome}";
|
||||||
|
|
||||||
|
userDirs = with userDirs; {
|
||||||
|
desktop = mkDefault "${home}/${relativeDesktop}";
|
||||||
|
documents = mkDefault "${home}/${relativeDocuments}";
|
||||||
|
download = mkDefault "${home}/${relativeDownload}";
|
||||||
|
music = mkDefault "${home}/${relativeMusic}";
|
||||||
|
pictures = mkDefault "${home}/${relativePictures}";
|
||||||
|
templates = mkDefault "${home}/${relativeTemplates}";
|
||||||
|
videos = mkDefault "${home}/${relativeVideos}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@@ -1,208 +0,0 @@
|
|||||||
{
|
|
||||||
user ? throw "user argument is required",
|
|
||||||
home ? throw "home argument is required",
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
inputs,
|
|
||||||
system,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
hmConfig = config.home-manager.users.${user};
|
|
||||||
selfPkgs = inputs.self.packages.${system};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
home-manager.users.${user} = {
|
|
||||||
programs = {
|
|
||||||
yazi = {
|
|
||||||
enable = true;
|
|
||||||
enableZshIntegration = true;
|
|
||||||
|
|
||||||
settings = {
|
|
||||||
mgr = {
|
|
||||||
show_hidden = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
opener = {
|
|
||||||
edit =
|
|
||||||
[
|
|
||||||
{
|
|
||||||
run = "${hmConfig.programs.neovim.finalPackage}/bin/nvim \"$@\"";
|
|
||||||
desc = "nvim";
|
|
||||||
block = true;
|
|
||||||
}
|
|
||||||
]
|
|
||||||
++ lib.lists.optional hmConfig.programs.vscode.enable {
|
|
||||||
run = "${hmConfig.programs.vscode.package}/bin/code \"$@\"";
|
|
||||||
desc = "code";
|
|
||||||
orphan = true;
|
|
||||||
};
|
|
||||||
open = [
|
|
||||||
{
|
|
||||||
run = "uwsm app -- xdg-open \"$1\"";
|
|
||||||
desc = "Open";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
reveal = [
|
|
||||||
{
|
|
||||||
run = "uwsm app -- xdg-open \"$(dirname \"$1\")\"";
|
|
||||||
desc = "Reveal";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
extract = [
|
|
||||||
{
|
|
||||||
run = "ouch d -y \"$@\"";
|
|
||||||
desc = "Extract here with ouch";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
play = [
|
|
||||||
{
|
|
||||||
run = "uwsm app -- mpv \"$@\"";
|
|
||||||
orphan = true;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
plugin = {
|
|
||||||
prepend_preloaders = [
|
|
||||||
{
|
|
||||||
mime = "{audio,video,image}/*";
|
|
||||||
run = "mediainfo";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/subrip";
|
|
||||||
run = "mediainfo";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
prepend_previewers = [
|
|
||||||
{
|
|
||||||
mime = "{audio,video,image}/*";
|
|
||||||
run = "mediainfo";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/subrip";
|
|
||||||
run = "mediainfo";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/*zip";
|
|
||||||
run = "ouch";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/x-tar";
|
|
||||||
run = "ouch";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/x-bzip2";
|
|
||||||
run = "ouch";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/x-7z-compressed";
|
|
||||||
run = "ouch";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/x-rar";
|
|
||||||
run = "ouch";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/x-xz";
|
|
||||||
run = "ouch";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
mime = "application/xz";
|
|
||||||
run = "ouch";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
keymap = {
|
|
||||||
mgr.prepend_keymap = [
|
|
||||||
{
|
|
||||||
on = "<Enter>";
|
|
||||||
run = "plugin smart-enter";
|
|
||||||
desc = "Enter the child directory, or open the file";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
on = ";";
|
|
||||||
run = "plugin custom-shell -- auto --interactive";
|
|
||||||
desc = "Run a shell command";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
on = ":";
|
|
||||||
run = "plugin custom-shell -- auto --interactive --block";
|
|
||||||
desc = "Run a shell command (block until finishes)";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
on = "!";
|
|
||||||
run = "shell \"$SHELL\" --block";
|
|
||||||
desc = "Open $SHELL here";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
on = "C";
|
|
||||||
run = "plugin ouch";
|
|
||||||
desc = "Compress";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
on = "M";
|
|
||||||
run = "plugin chmod";
|
|
||||||
desc = "Chmod on selected files";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
on = "<C-m>";
|
|
||||||
run = "plugin mount";
|
|
||||||
desc = "Open the mount menu";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
initLua = ''
|
|
||||||
Status:children_add(function(self)
|
|
||||||
local h = self._current.hovered
|
|
||||||
if not h or not h.link_to then
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
return " -> " .. tostring(h.link_to)
|
|
||||||
end, 3300, Status.LEFT)
|
|
||||||
|
|
||||||
Status:children_add(function()
|
|
||||||
local h = cx.active.current.hovered
|
|
||||||
if not h then
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
return ui.Line {
|
|
||||||
ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)),
|
|
||||||
":",
|
|
||||||
ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)),
|
|
||||||
" ",
|
|
||||||
}
|
|
||||||
end, 500, Status.RIGHT)
|
|
||||||
'';
|
|
||||||
|
|
||||||
plugins = with pkgs.yaziPlugins; {
|
|
||||||
inherit
|
|
||||||
smart-enter
|
|
||||||
chmod
|
|
||||||
ouch
|
|
||||||
mount
|
|
||||||
mediainfo
|
|
||||||
;
|
|
||||||
|
|
||||||
custom-shell = selfPkgs.yazi-plugin-custom-shell;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
zsh = {
|
|
||||||
shellAliases.y = "yazi";
|
|
||||||
p10k.extraRightPromptElements = [ "yazi" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
theme.template.".config/yazi/theme.toml".source = ./theme.toml;
|
|
||||||
};
|
|
||||||
}
|
|
@@ -1,101 +0,0 @@
|
|||||||
[mgr]
|
|
||||||
cwd = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
|
|
||||||
preview_hovered = { }
|
|
||||||
|
|
||||||
find_keyword = { fg = "{{colors.tertiary.default.hex}}", bold = true, italic = true, underline = true }
|
|
||||||
find_position = { fg = "{{colors.tertiary.default.hex}}", bg = "reset", bold = true, italic = true }
|
|
||||||
|
|
||||||
marker_selected = { fg = "{{colors.primary.default.hex}}", bg = "{{colors.primary.default.hex}}" }
|
|
||||||
marker_copied = { fg = "{{colors.secondary.default.hex}}", bg = "{{colors.secondary.default.hex}}" }
|
|
||||||
marker_cut = { fg = "{{colors.secondary.default.hex}}", bg = "{{colors.secondary.default.hex}}" }
|
|
||||||
marker_marked = { fg = "{{colors.tertiary.default.hex}}", bg = "{{colors.tertiary.default.hex}}" }
|
|
||||||
|
|
||||||
count_selected = { fg = "{{colors.on_primary.default.hex}}", bg = "{{colors.primary.default.hex}}" }
|
|
||||||
count_copied = { fg = "{{colors.on_secondary.default.hex}}", bg = "{{colors.secondary.default.hex}}" }
|
|
||||||
count_cut = { fg = "{{colors.on_secondary.default.hex}}", bg = "{{colors.secondary.default.hex}}" }
|
|
||||||
|
|
||||||
border_style = { fg = "{{colors.outline.default.hex}}" }
|
|
||||||
|
|
||||||
[tabs]
|
|
||||||
active = { fg = "{{colors.on_primary.default.hex}}", bg = "{{colors.primary.default.hex}}", bold = true }
|
|
||||||
inactive = { fg = "{{colors.on_surface_variant.default.hex}}", bg = "{{colors.surface_dim.default.hex}}" }
|
|
||||||
|
|
||||||
sep_inner = { open = "", close = "" }
|
|
||||||
sep_outer = { open = "", close = "" }
|
|
||||||
|
|
||||||
[mode]
|
|
||||||
normal_main = { fg = "{{colors.on_primary.default.hex}}", bg = "{{colors.primary.default.hex}}", bold = true }
|
|
||||||
normal_alt = { fg = "{{colors.on_primary_container.default.hex}}", bg = "{{colors.primary_container.default.hex}}" }
|
|
||||||
|
|
||||||
select_main = { fg = "{{colors.on_secondary.default.hex}}", bg = "{{colors.secondary.default.hex}}", bold = true }
|
|
||||||
select_alt = { fg = "{{colors.on_secondary_container.default.hex}}", bg = "{{colors.secondary_container.default.hex}}" }
|
|
||||||
|
|
||||||
unset_main = { fg = "{{colors.on_tertiary.default.hex}}", bg = "{{colors.tertiary.default.hex}}", bold = true }
|
|
||||||
unset_alt = { fg = "{{colors.on_tertiary_container.default.hex}}", bg = "{{colors.tertiary_container.default.hex}}" }
|
|
||||||
|
|
||||||
[status]
|
|
||||||
sep_left = { open = "", close = "" }
|
|
||||||
sep_right = { open = "", close = "" }
|
|
||||||
|
|
||||||
perm_sep = { fg = "{{colors.scrim.default.hex}}" }
|
|
||||||
perm_type = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
perm_read = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
perm_write = { fg = "{{colors.secondary.default.hex}}" }
|
|
||||||
perm_exec = { fg = "{{colors.tertiary.default.hex}}" }
|
|
||||||
|
|
||||||
progress_label = { bold = true }
|
|
||||||
progress_normal = { fg = "{{colors.primary.default.hex}}", bg = "{{colors.primary_container.default.hex}}" }
|
|
||||||
progress_error = { fg = "{{colors.error.default.hex}}", bg = "{{colors.error_container.default.hex}}" }
|
|
||||||
|
|
||||||
[which]
|
|
||||||
mask = { bg = "{{colors.surface.default.hex}}" }
|
|
||||||
cand = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
rest = { fg = "{{colors.primary_container.default.hex}}" }
|
|
||||||
desc = { fg = "{{colors.on_surface.default.hex}}" }
|
|
||||||
separator_style = { fg = "{{colors.scrim.default.hex}}" }
|
|
||||||
|
|
||||||
[confirm]
|
|
||||||
border = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
title = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
|
|
||||||
[spot]
|
|
||||||
border = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
title = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
|
|
||||||
tbl_col = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
tbl_cell = { fg = "{{colors.secondary.default.hex}}", reversed = true }
|
|
||||||
|
|
||||||
[notify]
|
|
||||||
title_info = { fg = "{{colors.info.default.hex}}" }
|
|
||||||
title_warn = { fg = "{{colors.warning.default.hex}}" }
|
|
||||||
title_error = { fg = "{{colors.error.default.hex}}" }
|
|
||||||
|
|
||||||
[pick]
|
|
||||||
border = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
active = { fg = "{{colors.secondary.default.hex}}", bold = true }
|
|
||||||
|
|
||||||
[input]
|
|
||||||
border = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
|
|
||||||
[cmp]
|
|
||||||
border = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
|
|
||||||
[tasks]
|
|
||||||
border = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
hovered = { fg = "{{colors.secondary.default.hex}}", bold = true }
|
|
||||||
|
|
||||||
[help]
|
|
||||||
on = { fg = "{{colors.primary.default.hex}}" }
|
|
||||||
run = { fg = "{{colors.secondary.default.hex}}" }
|
|
||||||
footer = { fg = "{{colors.surface.default.hex}}", bg = "{{colors.on_surface.default.hex}}" }
|
|
||||||
|
|
||||||
[icon]
|
|
||||||
prepend_dirs = [
|
|
||||||
{ name = ".cache", text = "" },
|
|
||||||
{ name = ".local", text = "" },
|
|
||||||
{ name = "Games", text = "" },
|
|
||||||
{ name = "git", text = "" },
|
|
||||||
{ name = "Templates", text = "" },
|
|
||||||
{ name = "VMs", text = "" },
|
|
||||||
]
|
|
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
user ? throw "user argument is required",
|
|
||||||
home ? throw "home argument is required",
|
|
||||||
}:
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
environment.persistence."/persist/state"."${home}/.local/share/zoxide" = { };
|
|
||||||
|
|
||||||
home-manager.users.${user}.programs.zoxide = {
|
|
||||||
enable = true;
|
|
||||||
enableZshIntegration = true;
|
|
||||||
};
|
|
||||||
}
|
|
@@ -5,13 +5,15 @@
|
|||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{
|
{
|
||||||
environment = {
|
environment = {
|
||||||
persistence."/persist/state"."${home}/.local/share/zsh" = { };
|
persistence."/persist"."${home}/.local/share/zsh" = { };
|
||||||
# If we set this under home-manager.users.${user}.home.sessionVariables,
|
# If we set this under home-manager.users.${user}.home.sessionVariables,
|
||||||
# it runs too late in the init process and zsh fails.
|
# it runs too late in the init process and zsh fails.
|
||||||
sessionVariables.ZDOTDIR = "$HOME/.config/zsh";
|
sessionVariables.ZDOTDIR = "$HOME/.config/zsh";
|
||||||
};
|
};
|
||||||
|
|
||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
|
imports = [ ./options.nix ];
|
||||||
|
|
||||||
programs.zsh = {
|
programs.zsh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
dotDir = ".config/zsh";
|
dotDir = ".config/zsh";
|
||||||
@@ -31,7 +33,7 @@
|
|||||||
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
|
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
initContent = ''
|
initExtra = ''
|
||||||
source ${./.p10k.zsh}
|
source ${./.p10k.zsh}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@@ -18,7 +18,7 @@ in
|
|||||||
with lib;
|
with lib;
|
||||||
with cfg;
|
with cfg;
|
||||||
{
|
{
|
||||||
initContent = ''
|
initExtra = ''
|
||||||
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(${strings.concatStringsSep " " p10k.extraRightPromptElements})
|
export P10K_EXTRA_RIGHT_PROMPT_ELEMENTS=(${strings.concatStringsSep " " p10k.extraRightPromptElements})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
user ? throw "user argument is required",
|
|
||||||
home ? throw "home argument is required",
|
|
||||||
}:
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
imports = [ ./options.nix ];
|
|
||||||
|
|
||||||
home-manager.users.${user}.imports = [
|
|
||||||
./console/zsh/options.nix
|
|
||||||
./gui/clipbook/options.nix
|
|
||||||
./gui/hyprland/options.nix
|
|
||||||
(import ./gui/theme/options.nix { inherit user home; })
|
|
||||||
./gui/vscode/options.nix
|
|
||||||
];
|
|
||||||
}
|
|
@@ -1,12 +1,10 @@
|
|||||||
import { App } from "astal/gtk3";
|
import { App } from "astal/gtk3"
|
||||||
import { monitorFile } from "astal/file";
|
import Bar from "./widget/Bar"
|
||||||
import { exec } from "astal/process";
|
import { monitorFile } from "astal/file"
|
||||||
import GLib from "gi://GLib";
|
import { exec } from "astal/process"
|
||||||
import Left from "./widget/Left";
|
import GLib from "gi://GLib"
|
||||||
import Center from "./widget/Center";
|
|
||||||
import Right from "./widget/Right";
|
|
||||||
|
|
||||||
const HOME = GLib.getenv("HOME");
|
const HOME = GLib.getenv("HOME")
|
||||||
const css = `${HOME}/.config/astal/theme.css`;
|
const css = `${HOME}/.config/astal/theme.css`;
|
||||||
const scss = `${HOME}/.config/astal/theme.sass`;
|
const scss = `${HOME}/.config/astal/theme.sass`;
|
||||||
|
|
||||||
@@ -20,10 +18,6 @@ exec(`sassc ${scss} ${css}`);
|
|||||||
App.start({
|
App.start({
|
||||||
css,
|
css,
|
||||||
main() {
|
main() {
|
||||||
App.get_monitors().map((monitor) => {
|
App.get_monitors().map(Bar)
|
||||||
Left(monitor);
|
|
||||||
Center(monitor);
|
|
||||||
Right(monitor);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
|
@@ -1,26 +1,26 @@
|
|||||||
export const SRC: string;
|
export const SRC: string
|
||||||
|
|
||||||
declare module "inline:*" {
|
declare module "inline:*" {
|
||||||
const content: string;
|
const content: string
|
||||||
export default content;
|
export default content
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module "*.scss" {
|
declare module "*.scss" {
|
||||||
const content: string;
|
const content: string
|
||||||
export default content;
|
export default content
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module "*.sass" {
|
declare module "*.sass" {
|
||||||
const content: string;
|
const content: string
|
||||||
export default content;
|
export default content
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module "*.blp" {
|
declare module "*.blp" {
|
||||||
const content: string;
|
const content: string
|
||||||
export default content;
|
export default content
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module "*.css" {
|
declare module "*.css" {
|
||||||
const content: string;
|
const content: string
|
||||||
export default content;
|
export default content
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,3 @@
|
|||||||
import { Gdk } from "astal/gtk3";
|
|
||||||
import Hyprland from "gi://AstalHyprland";
|
|
||||||
|
|
||||||
export const range = (length: number, start = 1) => {
|
export const range = (length: number, start = 1) => {
|
||||||
return Array.from({ length }, (n, i) => i + start);
|
return Array.from({ length }, (n, i) => i + start);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getHyprlandMonitor = (gdkmonitor: Gdk.Monitor) => {
|
|
||||||
const hyprland = Hyprland.get_default();
|
|
||||||
const display = Gdk.Display.get_default()!;
|
|
||||||
const screen = display.get_default_screen();
|
|
||||||
for (let i = 0; i < display.get_n_monitors(); ++i) {
|
|
||||||
if (gdkmonitor === display.get_monitor(i))
|
|
||||||
return hyprland.get_monitor_by_name(screen.get_monitor_plug_name(i)!);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
@@ -7,6 +7,6 @@
|
|||||||
"module": "ES2022",
|
"module": "ES2022",
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"jsxImportSource": "astal/gtk3"
|
"jsxImportSource": "astal/gtk3",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user