Skip to content

Commit 183e188

Browse files
feat(flake): added vm configurations
super basic but seems to be working just fine
1 parent f14671b commit 183e188

File tree

13 files changed

+353
-0
lines changed

13 files changed

+353
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# See /modules/nixos/* for actual settings
2+
# This file is just *top-level* configuration.
3+
{
4+
inputs,
5+
pkgs,
6+
...
7+
}:
8+
{
9+
imports = [
10+
# hardware setup
11+
# see https://github.com/NixOS/nixos-hardware/blob/master/raspberry-pi/4/default.nixh
12+
inputs.nixos-generators.nixosModules.all-formats
13+
./hardware-configuration.nix
14+
./system
15+
];
16+
17+
users.users.justinhoang = {
18+
# If you do, you can skip setting a root password by passing
19+
# '--no-root-passwd' to nixos-install. Be sure to change it (using
20+
# passwd) after rebooting!
21+
initialHashedPassword = "$y$j9T$sXZCGwjtugZIt/C2nU8bk/$D36OrIe3eyGSM7rPysbQI1OyT56TdtJZtcvnOne2Ge0";
22+
isNormalUser = true;
23+
extraGroups = [ "wheel" ];
24+
};
25+
26+
environment.systemPackages =
27+
let
28+
inherit (pkgs.stdenv.hostPlatform) system;
29+
in
30+
[
31+
# add basic nixvim config
32+
inputs.nixvim-config.packages.${system}.minimal
33+
];
34+
35+
# This option defines the first version of NixOS you have installed on this particular machine,
36+
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
37+
#
38+
# Most users should NEVER change this value after the initial install, for any reason,
39+
# even if you've upgraded your system to a new NixOS release.
40+
#
41+
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
42+
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
43+
# to actually do that.
44+
#
45+
# This value being lower than the current NixOS release does NOT mean your system is
46+
# out of date, out of support, or vulnerable.
47+
#
48+
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
49+
# and migrated your data accordingly.
50+
#
51+
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
52+
hardware.enableRedistributableFirmware = true;
53+
system.stateVersion = "24.11"; # Did you read the comment?
54+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Do not modify this file! It was generated by ‘nixos-generate-config’
2+
# and may be overwritten by future invocations. Please make changes
3+
# to /etc/nixos/configuration.nix instead.
4+
{
5+
lib,
6+
modulesPath,
7+
...
8+
}:
9+
10+
{
11+
imports = [
12+
(modulesPath + "/installer/scan/not-detected.nix")
13+
];
14+
15+
boot = {
16+
initrd.availableKernelModules = [ ];
17+
initrd.kernelModules = [ ];
18+
kernelModules = [ ];
19+
extraModulePackages = [ ];
20+
};
21+
22+
fileSystems."/" = {
23+
device = "/dev/disk/by-label/NIXOS_SD";
24+
fsType = "ext4";
25+
options = [ "noatime" ];
26+
};
27+
28+
swapDevices = [ ];
29+
30+
# Note that the disk partitioning and logical volume scheme is managed with
31+
# disko under ./disko.nix
32+
33+
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
34+
# (the default) this is the recommended approach. When using systemd-networkd it's
35+
# still possible to use this option, but it's recommended to use it in conjunction
36+
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
37+
networking.useDHCP = lib.mkDefault true;
38+
# networking.interfaces.docker0.useDHCP = lib.mkDefault true;
39+
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
40+
41+
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
42+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# A module that automatically imports everything else in the parent folder.
2+
{
3+
imports =
4+
with builtins;
5+
map (fn: ./${fn}) (filter (fn: fn != "default.nix") (attrNames (readDir ./.)));
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
time.timeZone = "America/Denver";
3+
services.xserver = {
4+
xkb.layout = "us";
5+
xkb.variant = "";
6+
};
7+
i18n = {
8+
defaultLocale = "en_US.UTF-8";
9+
extraLocaleSettings = {
10+
LC_ADDRESS = "en_US.UTF-8";
11+
LC_IDENTIFICATION = "en_US.UTF-8";
12+
LC_MEASUREMENT = "en_US.UTF-8";
13+
LC_MONETARY = "en_US.UTF-8";
14+
LC_NAME = "en_US.UTF-8";
15+
LC_NUMERIC = "en_US.UTF-8";
16+
LC_PAPER = "en_US.UTF-8";
17+
LC_TELEPHONE = "en_US.UTF-8";
18+
LC_TIME = "en_US.UTF-8";
19+
};
20+
};
21+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
# Define the hostname
3+
networking = {
4+
hostName = "vm";
5+
hostId = "13ad9831";
6+
networkmanager.enable = true;
7+
firewall = {
8+
enable = true;
9+
allowPing = true;
10+
};
11+
};
12+
# This setups a SSH server. Very important if you're setting up a headless system.
13+
# Feel free to remove if you don't need it.
14+
services.openssh = {
15+
enable = true;
16+
settings = {
17+
# Opinionated: forbid root login through SSH.
18+
PermitRootLogin = "no";
19+
# Opinionated: use keys only.
20+
# Remove if you want to SSH using passwords
21+
PasswordAuthentication = true;
22+
};
23+
};
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
# https://nixos.wiki/wiki/Storage_optimization
3+
4+
nix = {
5+
# Optimize the storage once in a while
6+
optimise.automatic = true;
7+
optimise.dates = [
8+
# Optional; allows customizing optimisation schedule
9+
"00:00"
10+
"12:00"
11+
];
12+
13+
# Optimise on each build -- results in slower build :)
14+
settings.auto-optimise-store = true;
15+
16+
# Automatic garbage collection
17+
gc = {
18+
automatic = true;
19+
dates = "weekly";
20+
options = "--delete-older-than 30d";
21+
};
22+
};
23+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# See /modules/nixos/* for actual settings
2+
# This file is just *top-level* configuration.
3+
{
4+
inputs,
5+
pkgs,
6+
...
7+
}:
8+
{
9+
imports = [
10+
# hardware setup
11+
# see https://github.com/NixOS/nixos-hardware/blob/master/raspberry-pi/4/default.nixh
12+
inputs.nixos-generators.nixosModules.all-formats
13+
./hardware-configuration.nix
14+
./system
15+
];
16+
17+
users.users.justinhoang = {
18+
# If you do, you can skip setting a root password by passing
19+
# '--no-root-passwd' to nixos-install. Be sure to change it (using
20+
# passwd) after rebooting!
21+
initialHashedPassword = "$y$j9T$sXZCGwjtugZIt/C2nU8bk/$D36OrIe3eyGSM7rPysbQI1OyT56TdtJZtcvnOne2Ge0";
22+
isNormalUser = true;
23+
extraGroups = [ "wheel" ];
24+
};
25+
26+
environment.systemPackages =
27+
let
28+
inherit (pkgs.stdenv.hostPlatform) system;
29+
in
30+
[
31+
# add basic nixvim config
32+
inputs.nixvim-config.packages.${system}.minimal
33+
];
34+
35+
# This option defines the first version of NixOS you have installed on this particular machine,
36+
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
37+
#
38+
# Most users should NEVER change this value after the initial install, for any reason,
39+
# even if you've upgraded your system to a new NixOS release.
40+
#
41+
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
42+
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
43+
# to actually do that.
44+
#
45+
# This value being lower than the current NixOS release does NOT mean your system is
46+
# out of date, out of support, or vulnerable.
47+
#
48+
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
49+
# and migrated your data accordingly.
50+
#
51+
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
52+
hardware.enableRedistributableFirmware = true;
53+
system.stateVersion = "24.11"; # Did you read the comment?
54+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Do not modify this file! It was generated by ‘nixos-generate-config’
2+
# and may be overwritten by future invocations. Please make changes
3+
# to /etc/nixos/configuration.nix instead.
4+
{
5+
lib,
6+
modulesPath,
7+
...
8+
}:
9+
10+
{
11+
imports = [
12+
(modulesPath + "/installer/scan/not-detected.nix")
13+
];
14+
15+
boot = {
16+
initrd.availableKernelModules = [ ];
17+
initrd.kernelModules = [ ];
18+
kernelModules = [ ];
19+
extraModulePackages = [ ];
20+
};
21+
22+
fileSystems."/" = {
23+
device = "/dev/disk/by-label/NIXOS_SD";
24+
fsType = "ext4";
25+
options = [ "noatime" ];
26+
};
27+
28+
swapDevices = [ ];
29+
30+
# Note that the disk partitioning and logical volume scheme is managed with
31+
# disko under ./disko.nix
32+
33+
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
34+
# (the default) this is the recommended approach. When using systemd-networkd it's
35+
# still possible to use this option, but it's recommended to use it in conjunction
36+
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
37+
networking.useDHCP = lib.mkDefault true;
38+
# networking.interfaces.docker0.useDHCP = lib.mkDefault true;
39+
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
40+
41+
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
42+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# A module that automatically imports everything else in the parent folder.
2+
{
3+
imports =
4+
with builtins;
5+
map (fn: ./${fn}) (filter (fn: fn != "default.nix") (attrNames (readDir ./.)));
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
time.timeZone = "America/Denver";
3+
services.xserver = {
4+
xkb.layout = "us";
5+
xkb.variant = "";
6+
};
7+
i18n = {
8+
defaultLocale = "en_US.UTF-8";
9+
extraLocaleSettings = {
10+
LC_ADDRESS = "en_US.UTF-8";
11+
LC_IDENTIFICATION = "en_US.UTF-8";
12+
LC_MEASUREMENT = "en_US.UTF-8";
13+
LC_MONETARY = "en_US.UTF-8";
14+
LC_NAME = "en_US.UTF-8";
15+
LC_NUMERIC = "en_US.UTF-8";
16+
LC_PAPER = "en_US.UTF-8";
17+
LC_TELEPHONE = "en_US.UTF-8";
18+
LC_TIME = "en_US.UTF-8";
19+
};
20+
};
21+
}

0 commit comments

Comments
 (0)