Skip to content

Commit 8057d37

Browse files
committed
hosts: add some examples
1 parent 7bda05a commit 8057d37

File tree

9 files changed

+252
-9
lines changed

9 files changed

+252
-9
lines changed

Readme.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ For cloud servers, you can use the [bin456789/reinstall](https://github.com/bin4
3737
bash <(curl -L https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh) dd --img=https://github.com/qbisi/nixos-images/releases/download/20240912/nixos-x86_64-generic-btrfs-scsi.raw.xz && reboot
3838
```
3939

40+
## Custom your own configuration
41+
42+
See [Hosts readme](./hosts/readme.md).
43+
4044
## Building the Image Yourself
4145

4246
For advanced users looking to build a custom NixOS image from this Nix-based flake source, follow the steps below:
@@ -54,10 +58,10 @@ Ensure you have the following installed:
5458

5559
### Build Process
5660

57-
Use the following command to build your desired NixOS image. Replace ${device} and ${mediatype} with the appropriate values (e.g., nixos-x86_64-generic-btrfs for device type and scsi for media type):
61+
Use the following command to build your desired NixOS image. Replace ${device} with the appropriate values (e.g., nixos-x86_64-generic-btrfs for device type):
5862

5963
```bash
60-
nix build github:qbisi/nixos-images#images.${device}-${mediatype}
64+
nix build github:qbisi/nixos-images#images.${device}
6165
```
6266

6367
Once the build is complete, the resulting image will be located in the result directory:

devices/aarch64-linux/nixos-rockchip-cdhx-rb30-uboot-btrfs.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ in
3535
};
3636

3737
boot = {
38-
kernelPackages = pkgs.linuxPackages_latest;
38+
# kernelPackages = pkgs.linuxPackages_latest;
3939
kernelParams = [
4040
"net.ifnames=0"
4141
"console=tty1"

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
];
2020
imports = [
2121
./devices
22+
./hosts
2223
./lib
2324
./modules
2425
./pkgs

hosts/aarch64-linux/cdhx-rb30.nix

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
config,
3+
pkgs,
4+
lib,
5+
modulesPath,
6+
self,
7+
inputs,
8+
...
9+
}:
10+
{
11+
deployment = {
12+
targetHost = "cdhx-rb30";
13+
buildOnTarget = false;
14+
tags = [ "rk3399" ];
15+
};
16+
17+
nixpkgs.config = {
18+
allowUnfree = true;
19+
};
20+
21+
imports = [
22+
../../devices/aarch64-linux/nixos-rockchip-cdhx-rb30-uboot-btrfs.nix
23+
../../modules/config/desktop.nix
24+
];
25+
26+
users.users.nixos = {
27+
password = "nixos";
28+
# use mkpasswd to generate hashedPassword
29+
# hashedPassword = "$y$j9T$20Q2FTEqEYm1hzP10L1UA.$HLsxMJKmYnIHM2kGVJrLHh0dCtMz.TSVlWb0S2Ja29C";
30+
isNormalUser = true;
31+
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
32+
openssh.authorizedKeys.keys = [ ];
33+
};
34+
35+
users.users.root = {
36+
password = "root";
37+
openssh.authorizedKeys.keys = [
38+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIc0M/36MG2YkGTPpx7nEc3gILV9VbovrRga1ig1P69b"
39+
];
40+
};
41+
42+
services.openssh = {
43+
enable = true;
44+
};
45+
46+
environment.systemPackages = with pkgs; [
47+
vim
48+
wget
49+
htop
50+
git
51+
neofetch
52+
vscode-fhs
53+
];
54+
55+
nix.settings = {
56+
experimental-features = [
57+
"nix-command"
58+
"flakes"
59+
];
60+
trusted-users = [ "@wheel" ];
61+
};
62+
63+
system.stateVersion = "24.11";
64+
}

hosts/default.nix

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{ self
2+
, inputs
3+
, lib
4+
, ...
5+
}:
6+
let
7+
inherit (lib) nixosSystem cartesianProduct;
8+
inherit (self.lib) genAttrs' listNixName;
9+
x86_64-hosts = cartesianProduct {
10+
name = listNixName ./x86_64-linux;
11+
system = [ "x86_64-linux" ];
12+
};
13+
aarch64-hosts = cartesianProduct {
14+
name = listNixName ./aarch64-linux;
15+
system = [ "aarch64-linux" ];
16+
};
17+
hosts = x86_64-hosts ++ aarch64-hosts;
18+
in
19+
{
20+
flake = {
21+
nixosConfigurations = genAttrs' hosts (
22+
host:
23+
(nixosSystem {
24+
inherit (host) system;
25+
specialArgs = {
26+
inherit inputs self;
27+
pkgs-self = self.legacyPackages.${host.system};
28+
};
29+
modules = [
30+
"${self}/hosts/${host.system}/${host.name}.nix"
31+
self.nixosModules.default
32+
inputs.colmena.nixosModules.deploymentOptions
33+
];
34+
})
35+
);
36+
colmena =
37+
(genAttrs' hosts (host: {
38+
imports = [
39+
# SSH to llmnr hosts need retry to wait for hostname resolution.
40+
# Requires colmena version > 0.5.0.
41+
# { deployment.sshOptions = [ "-o" "ConnectionAttempts=2" ]; }
42+
"${self}/hosts/${host.system}/${host.name}.nix"
43+
self.nixosModules.default
44+
];
45+
}))
46+
// {
47+
meta = {
48+
nixpkgs = import inputs.nixpkgs { system = "x86_64-linux"; };
49+
machinesFile = "/etc/nix/machines";
50+
nodeNixpkgs = genAttrs' hosts
51+
(host: (import inputs.nixpkgs { inherit (host) system; }));
52+
nodeSpecialArgs = genAttrs' hosts
53+
(host: { inherit inputs self; pkgs-self = self.legacyPackages.${host.system}; });
54+
};
55+
};
56+
};
57+
}

hosts/readme.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Rebuild or Deploy you own nixos configuration
2+
3+
This document is for people unfamiliar with nix/nixpkgs/nixos and want to set their own configuration of nixos on sbc, pc or vps.
4+
5+
## Through nixos-rebuild
6+
7+
```
8+
git clone https://github.com/qbisi/nixos-images ~/nixos-images
9+
nixos-rebuild switch --flake ~/nixos-images
10+
```

hosts/x86_64-linux/azure-b1s.nix

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{ config
2+
, pkgs
3+
, lib
4+
, self
5+
, inputs
6+
, ...
7+
}:
8+
{
9+
deployment = {
10+
buildOnTarget = true;
11+
tags = [ "vps" ];
12+
};
13+
14+
imports = [
15+
../../devices/x86_64-linux/nixos-x86_64-uefi-btrfs.nix
16+
];
17+
18+
boot.initrd.availableKernelModules = [ "sd_mod" ];
19+
20+
virtualisation.hypervGuest.enable = true;
21+
22+
networking.hostName = "azure-b1s";
23+
24+
swapDevices = [
25+
{
26+
device = "/swap/swapfile";
27+
size = 1024;
28+
}
29+
];
30+
31+
system.stateVersion = "24.11";
32+
}

modules/config/desktop.nix

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{ pkgs, ... }:
2+
{
3+
hardware = {
4+
graphics.enable = true;
5+
bluetooth.enable = true;
6+
};
7+
8+
services.desktopManager.plasma6.enable = true;
9+
services.displayManager.sddm = {
10+
enable = true;
11+
wayland.enable = true;
12+
};
13+
14+
systemd.sleep.extraConfig = ''
15+
# disable hibernation
16+
# doc : https://archived.forum.manjaro.org/t/turn-off-disable-hibernate-completely/139939
17+
AllowHibernation=no
18+
AllowHybridSleep=no
19+
AllowSuspendThenHibernate=no
20+
'';
21+
services.logind.extraConfig = ''
22+
HibernateKeyIgnoreInhibited=no
23+
'';
24+
25+
environment.systemPackages = with pkgs; [
26+
firefox
27+
];
28+
29+
30+
fonts.packages = with pkgs; [
31+
noto-fonts
32+
# noto-fonts-cjk-sans
33+
# noto-fonts-cjk-serif
34+
source-han-sans
35+
source-han-serif
36+
# sarasa-gothic
37+
source-code-pro
38+
hack-font
39+
jetbrains-mono
40+
];
41+
42+
fonts.fontconfig = {
43+
defaultFonts = {
44+
emoji = [ "Noto Color Emoji" ];
45+
monospace = [
46+
"Noto Sans Mono CJK SC"
47+
"Sarasa Mono SC"
48+
"DejaVu Sans Mono"
49+
];
50+
sansSerif = [
51+
"Noto Sans CJK SC"
52+
"Source Han Sans SC"
53+
"DejaVu Sans"
54+
];
55+
serif = [
56+
"Noto Serif CJK SC"
57+
"Source Han Serif SC"
58+
"DejaVu Serif"
59+
];
60+
};
61+
};
62+
63+
i18n.supportedLocales = [
64+
"en_US.UTF-8/UTF-8"
65+
"zh_CN.UTF-8/UTF-8"
66+
];
67+
68+
i18n.inputMethod = {
69+
enable = true;
70+
type = "fcitx5";
71+
fcitx5.addons = with pkgs; [
72+
fcitx5-rime
73+
];
74+
};
75+
}

0 commit comments

Comments
 (0)