feat: modules
This commit is contained in:
22
nixos/module/default.nix
Normal file
22
nixos/module/default.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
flake,
|
||||
self,
|
||||
inputs,
|
||||
nixpkgs,
|
||||
}:
|
||||
with builtins;
|
||||
with nixpkgs.lib;
|
||||
with self.lib;
|
||||
let
|
||||
# Combine hectic modules into one
|
||||
hectic.imports = attrValues (
|
||||
readModulesRecursive' ./hectic { inherit flake self inputs; }
|
||||
);
|
||||
# Read generic modules seperately
|
||||
generic = readModulesRecursive'
|
||||
./generic
|
||||
{ inherit flake self inputs; };
|
||||
in generic // {
|
||||
inherit hectic;
|
||||
default = hectic;
|
||||
}
|
||||
1
nixos/module/generic/placeholder.nix
Normal file
1
nixos/module/generic/placeholder.nix
Normal file
@@ -0,0 +1 @@
|
||||
{ ... }: {}
|
||||
37
nixos/module/hectic/archetype/base.nix
Normal file
37
nixos/module/hectic/archetype/base.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
inputs,
|
||||
flake,
|
||||
self,
|
||||
}: {
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.hectic.archetype.base;
|
||||
in {
|
||||
options.hectic.archetype.base.enable = lib.mkEnableOption "Enable archetupe.dev";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.zsh.shellAliases = self.lib.sharedShellAliases;
|
||||
programs.zsh.enable = true;
|
||||
users.defaultUserShell = pkgs.zsh;
|
||||
|
||||
# Enable flakes and new 'nix' command
|
||||
nix.settings.experimental-features = "nix-command flakes";
|
||||
|
||||
networking.firewall.enable = true;
|
||||
|
||||
environment = {
|
||||
defaultPackages = [];
|
||||
systemPackages = (with self.packages.${pkgs.system}; [
|
||||
nvim-pager
|
||||
]);
|
||||
variables = {
|
||||
PAGER = with self.packages.${pkgs.system}; "${nvim-pager}/bin/pager";
|
||||
};
|
||||
};
|
||||
|
||||
system.stateVersion = "25.05";
|
||||
};
|
||||
}
|
||||
1
nixos/module/hectic/archetype/common.nix
Normal file
1
nixos/module/hectic/archetype/common.nix
Normal file
@@ -0,0 +1 @@
|
||||
{ ... }: {}
|
||||
63
nixos/module/hectic/archetype/dev.nix
Normal file
63
nixos/module/hectic/archetype/dev.nix
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
inputs,
|
||||
flake,
|
||||
self,
|
||||
}: {
|
||||
pkgs,
|
||||
modulesPath,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.hectic.archetype.dev;
|
||||
in {
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
options.hectic.archetype.dev.enable = lib.mkEnableOption "Enable archetupe.dev";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
hectic.archetype.base.enable = true;
|
||||
|
||||
services.getty.autologinUser = "root";
|
||||
|
||||
virtualisation.vmVariant.virtualisation = {
|
||||
qemu.options = [
|
||||
"-nographic"
|
||||
"-display curses"
|
||||
"-append console=ttyS0"
|
||||
"-serial mon:stdio"
|
||||
"-vga qxl"
|
||||
];
|
||||
forwardPorts = [
|
||||
{
|
||||
from = "host";
|
||||
host.port = 40500;
|
||||
guest.port = 22;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
};
|
||||
};
|
||||
|
||||
environment = {
|
||||
systemPackages =
|
||||
(with pkgs; [
|
||||
curl
|
||||
neovim
|
||||
yq-go
|
||||
jq
|
||||
htop-vim
|
||||
])
|
||||
++ (with self.packages.${pkgs.system}; [
|
||||
prettify-log
|
||||
]);
|
||||
};
|
||||
};
|
||||
}
|
||||
29
nixos/module/hectic/hardware/hetzner-cloud.nix
Normal file
29
nixos/module/hectic/hardware/hetzner-cloud.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
inputs,
|
||||
flake,
|
||||
self,
|
||||
}:
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.hectic.hardware.hetzner-cloud;
|
||||
in {
|
||||
options.hectic.hardware.hetzner-cloud.enable = lib.mkEnableOption "Enable hetzner-cloud hardware configurations";
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
boot.loader.grub.device = "/dev/sda";
|
||||
boot.initrd.availableKernelModules = [
|
||||
"ata_piix"
|
||||
"uhci_hcd"
|
||||
"xen_blkfront"
|
||||
] ++ (if pkgs.system != "aarch64-linux" then [ "vmw_pvscsi" ] else []);
|
||||
boot.initrd.kernelModules = ["nvme"];
|
||||
fileSystems."/" = {
|
||||
device = "/dev/sda1";
|
||||
fsType = "ext4";
|
||||
};
|
||||
};
|
||||
}
|
||||
37
nixos/module/hectic/hardware/lenovo-legion.nix
Normal file
37
nixos/module/hectic/hardware/lenovo-legion.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
...
|
||||
}:
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.hectic.hardware.lenovo-legion;
|
||||
hasDisko = false;
|
||||
in {
|
||||
options.hectic.hardware.lenovo-legion = {
|
||||
enable = lib.mkEnableOption "Enable lenovo-legion hardware configurations";
|
||||
swapSize = lib.mkOption {
|
||||
type = lib.types.either (lib.types.enum [ "100%" ]) (lib.types.strMatching "[0-9]+[KMGTP]?");
|
||||
default = "0";
|
||||
description = ''
|
||||
Size of the partition, in sgdisk format.
|
||||
sets end automatically with the + prefix
|
||||
can be 100% for the whole remaining disk, will be done last in that case.
|
||||
'';
|
||||
};
|
||||
device = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "0";
|
||||
description = ''
|
||||
Size of the partition, in sgdisk format.
|
||||
sets end automatically with the + prefix
|
||||
can be 100% for the whole remaining disk, will be done last in that case.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
};
|
||||
}
|
||||
19
nixos/system/devvm|manual/default.nix
Normal file
19
nixos/system/devvm|manual/default.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
flake,
|
||||
self,
|
||||
inputs,
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
inherit (self.legacyPackages."${system}") pkgs;
|
||||
|
||||
# Use folder name as name of this system
|
||||
name = builtins.baseNameOf ./.;
|
||||
|
||||
in pkgs.lib.nixosSystem {
|
||||
inherit pkgs;
|
||||
modules = [
|
||||
{ networking.hostName = name; }
|
||||
(import ./${name}.nix { inherit flake self inputs; })
|
||||
];
|
||||
}
|
||||
89
nixos/system/devvm|manual/devvm|manual.nix
Normal file
89
nixos/system/devvm|manual/devvm|manual.nix
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
inputs,
|
||||
flake,
|
||||
self,
|
||||
}: {
|
||||
lib,
|
||||
pkgs,
|
||||
modulesPath,
|
||||
config,
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
self.nixosModules.hectic
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
hectic = {
|
||||
archetype.dev.enable = true;
|
||||
hardware.hetzner-cloud.enable = true;
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs.writers; [
|
||||
(writeMinCBin "minc-hello-world" ["<stdio.h>"] /*c*/ ''
|
||||
printf("hello world\n");
|
||||
'')
|
||||
(writeMinCBin "minc-env" ["<stdio.h>" "<stdlib.h>"] /*c*/ ''
|
||||
char *env_name;
|
||||
if (argc > 1) {
|
||||
env_name = argv[1];
|
||||
} else {
|
||||
env_name = "HOME";
|
||||
}
|
||||
char *value = getenv(env_name);
|
||||
if (value) {
|
||||
printf("%s: %s\n", env_name, value);
|
||||
} else {
|
||||
printf("Environment variable %s not found.\n", env_name);
|
||||
}
|
||||
'')
|
||||
(writeMinCBin "minc-env-check" ["<stdio.h>" "<stdlib.h>"] /*c*/ ''
|
||||
char *env_name;
|
||||
if (argc > 1) {
|
||||
env_name = argv[1];
|
||||
} else {
|
||||
env_name = "HOME";
|
||||
}
|
||||
|
||||
char *value = getenv(env_name);
|
||||
if (value) {
|
||||
char buffer[128];
|
||||
sprintf(buffer, "echo $%s\n", env_name);
|
||||
system(buffer);
|
||||
} else {
|
||||
printf("Environment variable %s not found.\n", env_name);
|
||||
}
|
||||
'')
|
||||
];
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICrbBG+U07f7OKvOxYIGYCaNvyozzxQF+I9Fb5TYZErK yukkop vm-postgres''
|
||||
];
|
||||
|
||||
programs.zsh.shellAliases = self.lib.sharedShellAliasesForDevVm;
|
||||
|
||||
virtualisation = {
|
||||
vmVariant = {
|
||||
systemd.services.fix-root-perms = {
|
||||
description = "Fix root directory permissions";
|
||||
after = [ "local-fs.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.coreutils}/bin/chmod 755 /";
|
||||
};
|
||||
};
|
||||
virtualisation = {
|
||||
diskSize = 1024*6;
|
||||
diskImage = null;
|
||||
forwardPorts = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
networking.firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [
|
||||
80
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user